Message ID | 20171102161203.4704-1-mark.rutland@arm.com |
---|---|
State | Accepted |
Commit | 7a7003b1da010d2b0d1dc8bf21c10f5c73b389f1 |
Headers | show |
Series | arm64: ensure __dump_instr() checks addr_limit | expand |
On Thu, Nov 02, 2017 at 04:12:03PM +0000, Mark Rutland wrote: > It's possible for a user to deliberately trigger __dump_instr with a > chosen kernel address. > > Let's avoid problems resulting from this by using get_user() rather than > __get_user(), ensuring that we don't erroneously access kernel memory. > > Where we use __dump_instr() on kernel text, we already switch to > KERNEL_DS, so this shouldn't adversely affect those cases. > > Signed-off-by: Mark Rutland <mark.rutland@arm.com> > Fixes: 60ffc30d5652810d ("arm64: Exception handling") > Cc: Catalin Marinas <catalin.marinas@arm.com> > Cc: Will Deacon <will.deacon@arm.com> > Cc: stable@vger.kernel.org > --- > arch/arm64/kernel/traps.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Acked-by: Will Deacon <will.deacon@arm.com> Catalin, can you take this as a fix please? Will > diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c > index 5ea4b85aee0e..8383af15a759 100644 > --- a/arch/arm64/kernel/traps.c > +++ b/arch/arm64/kernel/traps.c > @@ -118,7 +118,7 @@ static void __dump_instr(const char *lvl, struct pt_regs *regs) > for (i = -4; i < 1; i++) { > unsigned int val, bad; > > - bad = __get_user(val, &((u32 *)addr)[i]); > + bad = get_user(val, &((u32 *)addr)[i]); > > if (!bad) > p += sprintf(p, i == 0 ? "(%08x) " : "%08x ", val); > -- > 2.11.0 >
On Thu, Nov 02, 2017 at 04:12:03PM +0000, Mark Rutland wrote: > It's possible for a user to deliberately trigger __dump_instr with a > chosen kernel address. > > Let's avoid problems resulting from this by using get_user() rather than > __get_user(), ensuring that we don't erroneously access kernel memory. > > Where we use __dump_instr() on kernel text, we already switch to > KERNEL_DS, so this shouldn't adversely affect those cases. > > Signed-off-by: Mark Rutland <mark.rutland@arm.com> > Fixes: 60ffc30d5652810d ("arm64: Exception handling") > Cc: Catalin Marinas <catalin.marinas@arm.com> > Cc: Will Deacon <will.deacon@arm.com> > Cc: stable@vger.kernel.org Queued for 4.14. Thanks. -- Catalin
diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index 5ea4b85aee0e..8383af15a759 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -118,7 +118,7 @@ static void __dump_instr(const char *lvl, struct pt_regs *regs) for (i = -4; i < 1; i++) { unsigned int val, bad; - bad = __get_user(val, &((u32 *)addr)[i]); + bad = get_user(val, &((u32 *)addr)[i]); if (!bad) p += sprintf(p, i == 0 ? "(%08x) " : "%08x ", val);
It's possible for a user to deliberately trigger __dump_instr with a chosen kernel address. Let's avoid problems resulting from this by using get_user() rather than __get_user(), ensuring that we don't erroneously access kernel memory. Where we use __dump_instr() on kernel text, we already switch to KERNEL_DS, so this shouldn't adversely affect those cases. Signed-off-by: Mark Rutland <mark.rutland@arm.com> Fixes: 60ffc30d5652810d ("arm64: Exception handling") Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Will Deacon <will.deacon@arm.com> Cc: stable@vger.kernel.org --- arch/arm64/kernel/traps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.11.0