[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHVXubhG2c=ShFHF4hMMFm8=BYDTyDUduOizujbUWQBW+55wTw@mail.gmail.com>
Date: Fri, 29 Sep 2023 10:25:59 +0200
From: Alexandre Ghiti <alexghiti@...osinc.com>
To: Edward AD <twuufnxlz@...il.com>
Cc: alex@...ti.fr, aou@...s.berkeley.edu, conor@...nel.org,
gregkh@...uxfoundation.org, guoren@...nel.org,
jirislaby@...nel.org, linux-kernel@...r.kernel.org,
linux-riscv@...ts.infradead.org, linux-serial@...r.kernel.org,
liushixin2@...wei.com, palmer@...belt.com,
paul.walmsley@...ive.com,
syzbot+8d2757d62d403b2d9275@...kaller.appspotmail.com,
syzkaller-bugs@...glegroups.com
Subject: Re: [PATCH] riscv: fix out of bounds in walk_stackframe
Hi Edward,
On Fri, Sep 29, 2023 at 1:12 AM Edward AD <twuufnxlz@...il.com> wrote:
>
> Add vmalloc and kernel addresses check to prevent invalid access.
>
> Closes: https://lore.kernel.org/all/20230926105949.1025995-2-twuufnxlz@gmail.com/
> Fixes: 5d8544e2d007 ("RISC-V: Generic library routines and assembly")
> Reported-and-test-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 | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/arch/riscv/kernel/stacktrace.c b/arch/riscv/kernel/stacktrace.c
> index 64a9c093aef9..031a4a35c1d0 100644
> --- a/arch/riscv/kernel/stacktrace.c
> +++ b/arch/riscv/kernel/stacktrace.c
> @@ -54,6 +54,9 @@ void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
> break;
> /* Unwind stack frame */
> frame = (struct stackframe *)fp - 1;
> + if ((is_vmalloc_addr(frame) && !pfn_valid(page_to_pfn(vmalloc_to_page(frame)))) ||
> + !virt_addr_valid(frame))
> + break;
> sp = fp;
> if (regs && (regs->epc == pc) && (frame->fp & 0x7)) {
> fp = frame->ra;
> --
> 2.25.1
>
I'm still not convinced this will fix the kasan out-of-bounds
accesses, the page can be valid but the read can happen at an offset
not initialized and trigger such errors right? I still think there is
something weird about the stack frame, as to me this should not happen
(but admittedly I don't know much about that).
Powered by blists - more mailing lists