Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp4713186rwb; Tue, 20 Sep 2022 19:17:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6vxguvwtudXvbkzGMSZixrJkUgsUYm7GIYHp1Tf90RPGh7sj4cR14qQThx6oWr+ZgQJP+k X-Received: by 2002:a17:906:ef90:b0:77c:7227:705 with SMTP id ze16-20020a170906ef9000b0077c72270705mr18688341ejb.565.1663726643168; Tue, 20 Sep 2022 19:17:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663726643; cv=none; d=google.com; s=arc-20160816; b=0lMV9cU7QR98DSEVbLNc9hMMIMa3tDe9NxHakJSDC1+BF0NTVfp4PjbBbEJ+UvP7IF aLsz5/MehUvuttjBgYV0urLEklBXDEao7R8dsYYsyVOyaQ1nHM6IS+eybZ9HrwRPnwAr /0JgcduXD2dxbz3aUh9hntJm+kdrhwZ99xRiS64JmiV3kjAdMyxB8gXHJGHDl73k7ptq SAFdIG7sne8GaGoT7K08DTjgsL9TtTUoov/H7qmDx1l0IPI1xtfcIxazTo0Y1gq8fXWT VpV4t0oqQR2mJOU2J6mhcCNnr0XnR9Kw7YrdHLwOpHfFQEm4CBFJy1ikjaR5C14rLgbL WKDQ== 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:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=HM26CP/TfuVN7pdz4NljKy66V6yWcOrSegnskocDCZc=; b=xc/T3fyQO9wGEcvhXZC/KYcLrgd2dSTkjMg7FjRid6fjmRf1nDT7P5vOGam2xikV8+ UnZ8FxqRNVytJJdbcqnAQZvftAnw51h6wP0W0Or945kQjQlWT4K4kwFZcm5vWa8s95oe LsF8eKEol29rJ86Wj03gFL9vTKlwf9D0326dvl11BFoGj9zLRV0LmO95zAcHO19i11lA lUu4XzhDsFld5afpb0DxmWlqBcCZzCRxaIYJ8QZMSmJ7xhvgp8hnJm+97SKuOp14n8ay UpNuci/hKWCGReFv20Vn/40TA0fEy8MKDPFO5/PMwxM1xDYX5byxZ28oDJFRwgZKA/OU VzLw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e16-20020a170906249000b0076f0940cb28si1092716ejb.175.2022.09.20.19.16.57; Tue, 20 Sep 2022 19:17:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231411AbiIUBfx (ORCPT + 99 others); Tue, 20 Sep 2022 21:35:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230499AbiIUBfo (ORCPT ); Tue, 20 Sep 2022 21:35:44 -0400 Received: from out199-18.us.a.mail.aliyun.com (out199-18.us.a.mail.aliyun.com [47.90.199.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F06D4F3AB for ; Tue, 20 Sep 2022 18:35:40 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R271e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045170;MF=xianting.tian@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0VQLO8FC_1663724135; Received: from 30.225.65.96(mailfrom:xianting.tian@linux.alibaba.com fp:SMTPD_---0VQLO8FC_1663724135) by smtp.aliyun-inc.com; Wed, 21 Sep 2022 09:35:36 +0800 Message-ID: <452ee5c6-2d1c-16ad-96d1-b0a9e807ff3f@linux.alibaba.com> Date: Wed, 21 Sep 2022 09:35:35 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: arch/riscv/kernel/traps.c:48 die() warn: variable dereferenced before check 'regs' (see line 46) To: Palmer Dabbelt Cc: dan.carpenter@oracle.com, kbuild@lists.01.org, lkp@intel.com, kbuild-all@lists.01.org, linux-kernel@vger.kernel.org, guoren@kernel.org References: From: Xianting Tian In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2022/9/21 上午4:06, Palmer Dabbelt 写道: > On Thu, 11 Aug 2022 03:42:28 PDT (-0700), > xianting.tian@linux.alibaba.com wrote: >> >> 在 2022/8/11 下午6:33, Dan Carpenter 写道: >>> tree: >>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git >>> master >>> head:   f41445645ab5d172e6090d00c332c335d8dba337 >>> commit: 3f1901110a89b0e2e13adb2ac8d1a7102879ea98 RISC-V: Add fast >>> call path of crash_kexec() >>> config: riscv-randconfig-m031-20220810 >>> (https://download.01.org/0day-ci/archive/20220811/202208110538.uaLOQmBs-lkp@intel.com/config) >>> compiler: riscv64-linux-gcc (GCC) 12.1.0 >>> >>> If you fix the issue, kindly add following tag where applicable >>> Reported-by: kernel test robot >>> Reported-by: Dan Carpenter >>> >>> smatch warnings: >>> arch/riscv/kernel/traps.c:48 die() warn: variable dereferenced >>> before check 'regs' (see line 46) >>> >>> vim +/regs +48 arch/riscv/kernel/traps.c >>> >>> 76d2a0493a17d4 Palmer Dabbelt    2017-07-10  31  void die(struct >>> pt_regs *regs, const char *str) >>> 76d2a0493a17d4 Palmer Dabbelt    2017-07-10  32  { >>> 76d2a0493a17d4 Palmer Dabbelt    2017-07-10  33      static int >>> die_counter; >>> 76d2a0493a17d4 Palmer Dabbelt    2017-07-10  34      int ret; >>> 76d2a0493a17d4 Palmer Dabbelt    2017-07-10  35 >>> 76d2a0493a17d4 Palmer Dabbelt    2017-07-10  36 oops_enter(); >>> 76d2a0493a17d4 Palmer Dabbelt    2017-07-10  37 >>> 76d2a0493a17d4 Palmer Dabbelt    2017-07-10  38 >>> spin_lock_irq(&die_lock); >>> 76d2a0493a17d4 Palmer Dabbelt    2017-07-10  39 console_verbose(); >>> 76d2a0493a17d4 Palmer Dabbelt    2017-07-10  40 bust_spinlocks(1); >>> 76d2a0493a17d4 Palmer Dabbelt    2017-07-10  41 >>> 76d2a0493a17d4 Palmer Dabbelt    2017-07-10  42 pr_emerg("%s >>> [#%d]\n", str, ++die_counter); >>> 76d2a0493a17d4 Palmer Dabbelt    2017-07-10  43 print_modules(); >>> 76d2a0493a17d4 Palmer Dabbelt    2017-07-10  44 show_regs(regs); >>> 76d2a0493a17d4 Palmer Dabbelt    2017-07-10  45 >>> a4c3733d32a72f Christoph Hellwig 2019-10-28 @46      ret = >>> notify_die(DIE_OOPS, str, regs, 0, regs->cause, SIGSEGV); >>> ^^^^^^^^^^^ >>> 76d2a0493a17d4 Palmer Dabbelt    2017-07-10  47 >>> 3f1901110a89b0 Xianting Tian     2022-06-06 @48      if (regs && >>> kexec_should_crash(current)) >>> ^^^^ >>> >>> Delete this NULL check. >> thanks,  I will send another fixup patch to fix the issue, is it OK? > > You're always welcome to send fixes, but I didn't see anything so I > just sent along > https://lore.kernel.org/r/20220920200037.6727-1-palmer@rivosinc.com/ Thanks Palmer for the fix :) > >>> >>> 3f1901110a89b0 Xianting Tian     2022-06-06  49 crash_kexec(regs); >>> 3f1901110a89b0 Xianting Tian     2022-06-06  50 >>> 76d2a0493a17d4 Palmer Dabbelt    2017-07-10  51 bust_spinlocks(0); >>> 76d2a0493a17d4 Palmer Dabbelt    2017-07-10  52 add_taint(TAINT_DIE, >>> LOCKDEP_NOW_UNRELIABLE); >>> 76d2a0493a17d4 Palmer Dabbelt    2017-07-10  53 >>> spin_unlock_irq(&die_lock); >>> 76d2a0493a17d4 Palmer Dabbelt    2017-07-10  54 oops_exit(); >>> 76d2a0493a17d4 Palmer Dabbelt    2017-07-10  55 >>> 76d2a0493a17d4 Palmer Dabbelt    2017-07-10  56      if >>> (in_interrupt()) >>> 76d2a0493a17d4 Palmer Dabbelt    2017-07-10  57 panic("Fatal >>> exception in interrupt"); >>> 76d2a0493a17d4 Palmer Dabbelt    2017-07-10  58      if (panic_on_oops) >>> 76d2a0493a17d4 Palmer Dabbelt    2017-07-10  59 panic("Fatal >>> exception"); >>> 76d2a0493a17d4 Palmer Dabbelt    2017-07-10  60      if (ret != >>> NOTIFY_STOP) >>> 0e25498f8cd43c Eric W. Biederman 2021-06-28  61 >>> make_task_dead(SIGSEGV); >>> 76d2a0493a17d4 Palmer Dabbelt    2017-07-10  62  } >>>