Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp3737602rdh; Fri, 29 Sep 2023 00:25:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHZpDSKjKq9gMyhgfJpWFF+Hod4pjPYZ8brm8fGuzx8eR/3Vcjs4+DeIUWLc62LNtumkViG X-Received: by 2002:a17:902:e54a:b0:1c4:387a:3259 with SMTP id n10-20020a170902e54a00b001c4387a3259mr4225057plf.46.1695972312862; Fri, 29 Sep 2023 00:25:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695972312; cv=none; d=google.com; s=arc-20160816; b=r2RJv6cX/4iAgmR73DMNSdRvyG4q0KvDPScbbDwPboDROysF59bp8lZ1F5QdNMaBZm 2VJAH2SyDMBxgsLKRbY4PitMWneOgqxRuN6dB0D9HGzy3XruAo9+yt/TTBkCWMnYw8xl jO77JEVxC6YkSvc4fVw/2avuPlzxxLPrKNjrwXXykfkArdsjkqrf6PjMQCndEaZP8a5/ 7zBqruSOMmip1Wen2mcsghIanjTnspjlIn3laYydjb91d1AoB6pUm16CCZJ5T/kFqWsH gpYinZnClk77U5KWSPZGjnaJN6IFeVx3sr90eNUGW6NRur0kaERKGe3yEcrRyKnGXiTj LqAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=BODh2zKZR2Vosf8eclYvE6Ck0nAE7c62B1OaOI3h6GU=; fh=aCdOimC/PRWdFquqGOr5GaYEVGqhosc6QGtUkKHrSCA=; b=ejpARzJSBdUfo2hYSAGs1zGwxO7+BsSyQ9Ld1zDZtHtzw20Qu27a3zFEqmvYpOhuGK wR6xoAbc/IEh4E1aE6JjicHTdwH8WJWezMVqnqAqW62PPoCgD1ZUSwVXxABT2qD/ZqvF xwfM3bEYns8lTO0wJKMIBd1Gioh5UHDMNE7cH7TiSHqw4MWC0VlCrji63llEWpUKhvpj qSZv6vKeH0+yaeLhOTIiV1VNVXER4ugHYaxoXLQATF9RtQWUG74oTkFbfBnW7DhqZdwb DethaFEkjeMzKr4YV3GFAQ9x1QG6j3wkQ5FzKLufDRGfCS6VqrGQXpnxLOA8f8mnGZRE dp9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Bj2RVsFR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id p18-20020a170902e75200b001c07bac13d0si21684100plf.383.2023.09.29.00.25.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 00:25:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Bj2RVsFR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id CF8238087504; Thu, 28 Sep 2023 23:05:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232689AbjI2GFh (ORCPT + 99 others); Fri, 29 Sep 2023 02:05:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229577AbjI2GFf (ORCPT ); Fri, 29 Sep 2023 02:05:35 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93D8E92; Thu, 28 Sep 2023 23:05:33 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 895CBC433C9; Fri, 29 Sep 2023 06:05:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1695967533; bh=ApOaP/9oDp2rTN1MoBE5BwHQoNPxIFZOt3ooiC/inEE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Bj2RVsFRjqIrzSw1UWOT77b0SUWLKRghuoHYc/LJkFyuxYQVcBkatPheuVq18y/Jc nkbREEB5jsx8AAW4g6M7mbMKp0FHO0/Z1w4jLZ9nZelNp9z6lX01GcHsI6sGbCHN3q 2EiVWKFdzMkCx8/rQSDwWOKs014FI+QVSjXI+dCs= Date: Fri, 29 Sep 2023 08:05:30 +0200 From: Greg KH To: Edward AD Cc: alex@ghiti.fr, alexghiti@rivosinc.com, aou@eecs.berkeley.edu, conor@kernel.org, guoren@kernel.org, jirislaby@kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-serial@vger.kernel.org, liushixin2@huawei.com, palmer@dabbelt.com, paul.walmsley@sifive.com, syzbot+8d2757d62d403b2d9275@syzkaller.appspotmail.com, syzkaller-bugs@googlegroups.com Subject: Re: [PATCH] riscv: fix out of bounds in walk_stackframe Message-ID: <2023092907-anybody-irregular-a30e@gregkh> References: <20230928231239.2144579-2-twuufnxlz@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230928231239.2144579-2-twuufnxlz@gmail.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 28 Sep 2023 23:05:53 -0700 (PDT) On Fri, Sep 29, 2023 at 07:12:40AM +0800, Edward AD 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@syzkaller.appspotmail.com > Link: https://lore.kernel.org/all/0000000000000170df0605ccf91a@google.com/T/ > Signed-off-by: Edward AD > --- > 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 > Hi, This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree. You are receiving this message because of the following common error(s) as indicated below: - Your patch contains warnings and/or errors noticed by the scripts/checkpatch.pl tool. - You have marked a patch with a "Fixes:" tag for a commit that is in an older released kernel, yet you do not have a cc: stable line in the signed-off-by area at all, which means that the patch will not be applied to any older kernel releases. To properly fix this, please follow the documented rules in the Documetnation/process/stable-kernel-rules.rst file for how to resolve this. If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers. thanks, greg k-h's patch email bot