Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5fae3d7b authored by Hanumant Singh's avatar Hanumant Singh Committed by Matt Wagantall
Browse files

arm: Dump only kernel region and avoid dumping in user mode



Dump of memory surrounding register values can leak
kernel information in case of a user level fault.
Also virt_addr_valid() confirms whether a given virtual
address linearly maps to a kernel physical address.
Thus it offers a more exhaustive test for valid kernel
space then a check for is_vmalloc().

Change-Id: Ie394ec26e5ff7fd7bed1e7308a55b0033eddfe7c
Signed-off-by: default avatarHanumant Singh <hanumant@codeaurora.org>
[joshc: adapted to apply to android-3.14, which meant adding
virt_addr_valid() in condition instead of replacing is_vmalloc()]
Signed-off-by: default avatarJosh Cartwright <joshc@codeaurora.org>
parent 88553a7f
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -330,7 +330,8 @@ static void show_data(unsigned long addr, int nbytes, const char *name)
		printk("%04lx ", (unsigned long)p & 0xffff);
		for (j = 0; j < 8; j++) {
			u32	data;
			if (probe_kernel_address(p, data)) {
			if (!virt_addr_valid(p) ||
			    probe_kernel_address(p, data)) {
				printk(" ********");
			} else {
				printk(" %08x", data);
@@ -343,10 +344,6 @@ static void show_data(unsigned long addr, int nbytes, const char *name)

static void show_extra_register_data(struct pt_regs *regs, int nbytes)
{
	mm_segment_t fs;

	fs = get_fs();
	set_fs(KERNEL_DS);
	show_data(regs->ARM_pc - nbytes, nbytes * 2, "PC");
	show_data(regs->ARM_lr - nbytes, nbytes * 2, "LR");
	show_data(regs->ARM_sp - nbytes, nbytes * 2, "SP");
@@ -363,7 +360,6 @@ static void show_extra_register_data(struct pt_regs *regs, int nbytes)
	show_data(regs->ARM_r8 - nbytes, nbytes * 2, "R8");
	show_data(regs->ARM_r9 - nbytes, nbytes * 2, "R9");
	show_data(regs->ARM_r10 - nbytes, nbytes * 2, "R10");
	set_fs(fs);
}

void __show_regs(struct pt_regs *regs)
@@ -427,7 +423,7 @@ void __show_regs(struct pt_regs *regs)
		printk("Control: %08x%s\n", ctrl, buf);
	}
#endif

	if (get_fs() == get_ds())
		show_extra_register_data(regs, 128);
}