lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d0f12692-f0df-9535-922a-f0578c713547@ghiti.fr>
Date:   Thu, 28 Sep 2023 10:02:22 +0200
From:   Alexandre Ghiti <alex@...ti.fr>
To:     Edward AD <twuufnxlz@...il.com>, conor@...nel.org
Cc:     syzbot+8d2757d62d403b2d9275@...kaller.appspotmail.com,
        gregkh@...uxfoundation.org, jirislaby@...nel.org,
        linux-kernel@...r.kernel.org, linux-serial@...r.kernel.org,
        syzkaller-bugs@...glegroups.com, paul.walmsley@...ive.com,
        palmer@...belt.com, aou@...s.berkeley.edu, guoren@...nel.org,
        alexghiti@...osinc.com, liushixin2@...wei.com,
        linux-riscv@...ts.infradead.org
Subject: Re: [PATCH] riscv: fix out of bounds in walk_stackframe

Hi Edward,

On 26/09/2023 13:43, Edward AD wrote:
> Increase the check on the frame after assigning its value. This is to prevent
> frame access from crossing boundaries.
>
> Closes: https://lore.kernel.org/all/20230926105949.1025995-2-twuufnxlz@gmail.com/
> Fixes: 5d8544e2d007 ("RISC-V: Generic library routines and assembly")
> Reported-and-tested-by: syzbot+8d2757d62d403b2d9275@...kaller.appspotmail.com
> Link: https://lore.kernel.org/all/0000000000000170df0605ccf91a@google.com/T/
> Signed-off-by: Edward AD <twuufnxlz@...il.com>
> ---
>   arch/riscv/kernel/stacktrace.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/arch/riscv/kernel/stacktrace.c b/arch/riscv/kernel/stacktrace.c
> index 64a9c093aef9..53bd18672329 100644
> --- a/arch/riscv/kernel/stacktrace.c
> +++ b/arch/riscv/kernel/stacktrace.c
> @@ -54,6 +54,8 @@ void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
>   			break;
>   		/* Unwind stack frame */
>   		frame = (struct stackframe *)fp - 1;
> +		if (!virt_addr_valid(frame))
> +			break;
>   		sp = fp;
>   		if (regs && (regs->epc == pc) && (frame->fp & 0x7)) {
>   			fp = frame->ra;


virt_addr_valid() works on kernel linear addresses, not on vmalloc 
addresses, which is the case hereĀ  (0xff20000006d37c38 belongs to the 
vmalloc region: see 
https://elixir.bootlin.com/linux/latest/source/Documentation/riscv/vm-layout.rst#L125). 
So this fix can't work.

I'm a bit surprised though of this out-of-bounds access since 
CONFIG_FRAME_POINTER is enabled, so there may be a real issue here (the 
console output is horrible, lots of backtraces, which is weird), so it 
may be worth digging into that.

Thanks,

Alex


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ