Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp3104399rdh; Thu, 28 Sep 2023 02:45:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHkhvFdD0nMbFR5yOPlUVA3lZUSgbf1pEPFVvbgiqFHpVWf+jcckQuOX9L/TSRV5embZWI+ X-Received: by 2002:a17:90a:df82:b0:277:6a7b:b904 with SMTP id p2-20020a17090adf8200b002776a7bb904mr546511pjv.15.1695894353035; Thu, 28 Sep 2023 02:45:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695894353; cv=none; d=google.com; s=arc-20160816; b=aesyeYoXJgy/TjPSbeN8rUjco7Mr5AzPSg7tb59c38MZpdBL9L2MEvUANF8UoKF0mT D/0fXjlmNHC21sLlEl+D+28ejA/UuYtu11r9iRbSY/4XRqvSFRtyCY/6BjbLU6dQAx7z sv82zEvTYQCcR++CwxcZqu1r6AXb18HTIQMHHF/mCJ9QMArSpjeQ3mKXzQZkmYxuU/4H GK7GsRExMN/6KXDQC53U6pl+La5959VpK797iCIsPmevdietZlGt4JR/2mcoDIw+Q8kl 3kj/yT0hSqM99DmktSe5n9bCxKig2lk97riOhi9AUEWk4XGN1+Ha1gwJy30FmrBiJHTv MMRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id; bh=xfghrPB+jpJHatxUANBZCGIOCtjmi3NQ2Y/c+qgqBis=; fh=JbAFyQRvs9JJtcLFHOKivx1telCurvVD39uk7f4/Qu8=; b=WRVjfYJ64BQYXlAyzMX7zrpHG8CgXr9GdJzxell6oVpJx+mAwJnREnjTMwSjNP2Ps1 +qLgeTiw2OAh1zKpes75vwz8lPJJPIeOMVGunJFBeIGQUnoRoamB2O3RJONNSrg0SfIM 5b4urZdyhJvbsdXHIeOZi461u7I6t7VOY/5tLw2ZA0SYGVpb0025oC4LJ/74e5v+HF33 ZL4jOLKckhkWhEzDGNHJ+/IY3fWeABgIQesu+aRhyAA1m1oDqAIuE2HE4YCMTY2zoHyK brCNGrXJHj2QlDEAHWfRHEx5FMit94TtezqmnTOW7iy0wUixLFzdChBbFqBRu0W6Sw7V es/g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id ob16-20020a17090b391000b0026800178358si13561710pjb.144.2023.09.28.02.45.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 02:45:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id E01128097140; Thu, 28 Sep 2023 01:16:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230372AbjI1IQI (ORCPT + 99 others); Thu, 28 Sep 2023 04:16:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229605AbjI1IQH (ORCPT ); Thu, 28 Sep 2023 04:16:07 -0400 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78CEB95; Thu, 28 Sep 2023 01:16:05 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id B68FBC0007; Thu, 28 Sep 2023 08:15:56 +0000 (UTC) Message-ID: Date: Thu, 28 Sep 2023 10:15:56 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH] riscv: fix out of bounds in walk_stackframe Content-Language: en-US From: Alexandre Ghiti To: Edward AD , conor@kernel.org Cc: syzbot+8d2757d62d403b2d9275@syzkaller.appspotmail.com, gregkh@linuxfoundation.org, jirislaby@kernel.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, syzkaller-bugs@googlegroups.com, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, guoren@kernel.org, alexghiti@rivosinc.com, liushixin2@huawei.com, linux-riscv@lists.infradead.org References: <0000000000000170df0605ccf91a@google.com> <20230926114343.1061739-2-twuufnxlz@gmail.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-GND-Sasl: alex@ghiti.fr X-Spam-Status: No, score=-2.2 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Thu, 28 Sep 2023 01:16:20 -0700 (PDT) Oh and BTW, any idea why linux-riscv was not in CC for the initial report? On 28/09/2023 10:02, Alexandre Ghiti wrote: > 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@syzkaller.appspotmail.com >> Link: >> https://lore.kernel.org/all/0000000000000170df0605ccf91a@google.com/T/ >> Signed-off-by: Edward AD >> --- >>   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 > > > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv