Message ID | 20230126112129.4602-1-johan+linaro@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp222993wrn; Thu, 26 Jan 2023 03:35:32 -0800 (PST) X-Google-Smtp-Source: AK7set+EeIyNlIxkDuT8IxsgVeQRjoPPFAZQlcxy3vb6bORxiFFxPsxFjMVCnL3zPi/7ExsIuM8N X-Received: by 2002:a17:90b:384c:b0:22b:f895:54bc with SMTP id nl12-20020a17090b384c00b0022bf89554bcmr1793609pjb.47.1674732931928; Thu, 26 Jan 2023 03:35:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674732931; cv=none; d=google.com; s=arc-20160816; b=ltsSoEXbDUdt73v9c5l/saV9mE0ARJmAvMIjN5aSL4mdD583wCEocC3b2at7mlM7TY 2MpguwPQik5rzBT0NhPJj4UwumcOfMnWtJplcfW82jcoucGKKPs26H/zp11tja/AlRX3 VBSMq5wloYwwzmSGCGR8OavwxkuVhNcWq0rPlskHlqH2oMySfzQFldFxrEIM19MYKx7v sPmlaF9lEqiNYoVkt0YVlR3rB3vTYw/K4djPCvvRKMNICPh25NTXI+32eqiReo91P1Ku VOurJ4VS+crv9LpaX80I2mtmQRmYxbbSzfjm89jBkEPg8Q5HuzRcy8T/ArsHSlrr0IYA yNsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=KuYVbkFOAHDknv+bOxwxPr0hwpwZfK1Uwd5hYa4mmXc=; b=Ut4VwekuxWM6XcVMNfd6OLtHZbJuNEVUcSoDbInsk0WrIse/JQIF008wQpkIo3Ylrh oKDUs2Sn8DGihnJsSzwYf82El82vIjFYRnJEAhvAHfIjdgZJYR6em4oMDgygJt6NZkJb 2I9naJliLus6JlYIWvIEXQoj6PTGAlTtqtkNYh2gaLKf7JMpU/0HibviyfjlV6jI9/x5 0OY8sSueZ0HjjzrcZ0VSzau05mIPClAOInsbffLI0y3D42RsfkC9FlyzGg4d9jKmvmf2 fHLGm4zU1WPmZOpuz9UDeh0RbLz6/nKD2T0afAkZOkenc/Lup1eXny6Z7LkxijRs0flz 17Sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uIXzC1Vz; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t23-20020a17090aba9700b002290c209ccdsi1313371pjr.150.2023.01.26.03.35.18; Thu, 26 Jan 2023 03:35:31 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uIXzC1Vz; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237071AbjAZLXg (ORCPT <rfc822;lekhanya01809@gmail.com> + 99 others); Thu, 26 Jan 2023 06:23:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235097AbjAZLXf (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 26 Jan 2023 06:23:35 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8676B62250; Thu, 26 Jan 2023 03:23:34 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 40681B81D67; Thu, 26 Jan 2023 11:23:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFAF4C433EF; Thu, 26 Jan 2023 11:23:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674732211; bh=66CKXAS/9EP3h8TINvZYNEfbZEZC0fHykS1xCI4vhh0=; h=From:To:Cc:Subject:Date:From; b=uIXzC1Vzni8t9BXgZoq8o0afdj8AMuiS7eTtEUEHkjTslxW6Ve/37BP0lHiIcbDIB q/MtyscQCcpASrh6Ey5zWSm/Ys7josHMN6CuiJeHBmnhtNoWcdMjJcjkJXpcrnboLk tP4nQpjYLWm657VvkR4kh6yjFtPyxkpoRRnxN9x6cqtA1EdsyZ4ipOsgG7hSjhhHyv LDeOqR0v8wIDZf7alQC/5bXPlDLROFwE2dBFqZp2864+LmvQmX2e9WJ9V/72kiEZVe 8NHbB7UBwO7rwkrYAt5nc6bdDNgs6utmzhlB7bW+hbB5/3cHkihmmMMqxlSlGh8fb+ pD93stJBo7ZRA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from <johan+linaro@kernel.org>) id 1pL0Lx-0001Cy-8A; Thu, 26 Jan 2023 12:23:38 +0100 From: Johan Hovold <johan+linaro@kernel.org> To: Ard Biesheuvel <ardb@kernel.org> Cc: Jeremy Kerr <jk@ozlabs.org>, Maximilian Luz <luzmaximilian@gmail.com>, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold <johan+linaro@kernel.org>, Steev Klimaszewski <steev@kali.org> Subject: [PATCH] efivarfs: fix NULL-deref on mount when no efivars Date: Thu, 26 Jan 2023 12:21:29 +0100 Message-Id: <20230126112129.4602-1-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756084758788119920?= X-GMAIL-MSGID: =?utf-8?q?1756084758788119920?= |
Series |
efivarfs: fix NULL-deref on mount when no efivars
|
|
Commit Message
Johan Hovold
Jan. 26, 2023, 11:21 a.m. UTC
The VFS calls kill_sb() also in case mount fails in get_tree().
Add the missing check to make sure that efivars has been registered also
to kill_sb() to avoid dereferencing a NULL pointer when trying to remove
efivar entries.
Fixes: c3fd71b428b8 ("efivarfs: always register filesystem")
Reported-by: Steev Klimaszewski <steev@kali.org>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
fs/efivarfs/super.c | 3 +++
1 file changed, 3 insertions(+)
Comments
On Thu, 26 Jan 2023 at 12:23, Johan Hovold <johan+linaro@kernel.org> wrote: > > The VFS calls kill_sb() also in case mount fails in get_tree(). > > Add the missing check to make sure that efivars has been registered also > to kill_sb() to avoid dereferencing a NULL pointer when trying to remove > efivar entries. > > Fixes: c3fd71b428b8 ("efivarfs: always register filesystem") > Reported-by: Steev Klimaszewski <steev@kali.org> > Signed-off-by: Johan Hovold <johan+linaro@kernel.org> Thanks - I have squashed this with the original patch. > --- > fs/efivarfs/super.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/fs/efivarfs/super.c b/fs/efivarfs/super.c > index b67d431c861a..482d612b716b 100644 > --- a/fs/efivarfs/super.c > +++ b/fs/efivarfs/super.c > @@ -246,6 +246,9 @@ static void efivarfs_kill_sb(struct super_block *sb) > { > kill_litter_super(sb); > > + if (!efivar_is_available()) > + return; > + > /* Remove all entries and destroy */ > efivar_entry_iter(efivarfs_destroy, &efivarfs_list, NULL); > } > -- > 2.39.1 >
On Thu, Jan 26, 2023 at 09:32:27PM +0100, Ard Biesheuvel wrote: > On Thu, 26 Jan 2023 at 12:23, Johan Hovold <johan+linaro@kernel.org> wrote: > > > > The VFS calls kill_sb() also in case mount fails in get_tree(). > > > > Add the missing check to make sure that efivars has been registered also > > to kill_sb() to avoid dereferencing a NULL pointer when trying to remove > > efivar entries. > > > > Fixes: c3fd71b428b8 ("efivarfs: always register filesystem") > > Reported-by: Steev Klimaszewski <steev@kali.org> > > Signed-off-by: Johan Hovold <johan+linaro@kernel.org> > > Thanks - I have squashed this with the original patch. Thanks, Ard. And sorry about not catching this before posting. Johan
On Fri, 27 Jan 2023 at 09:28, Johan Hovold <johan@kernel.org> wrote: > > On Thu, Jan 26, 2023 at 09:32:27PM +0100, Ard Biesheuvel wrote: > > On Thu, 26 Jan 2023 at 12:23, Johan Hovold <johan+linaro@kernel.org> wrote: > > > > > > The VFS calls kill_sb() also in case mount fails in get_tree(). > > > > > > Add the missing check to make sure that efivars has been registered also > > > to kill_sb() to avoid dereferencing a NULL pointer when trying to remove > > > efivar entries. > > > > > > Fixes: c3fd71b428b8 ("efivarfs: always register filesystem") > > > Reported-by: Steev Klimaszewski <steev@kali.org> > > > Signed-off-by: Johan Hovold <johan+linaro@kernel.org> > > > > Thanks - I have squashed this with the original patch. > > Thanks, Ard. And sorry about not catching this before posting. > No worries.
Hi Johan, I love your patch! Yet something to improve: [auto build test ERROR on v6.2-rc5] [also build test ERROR on linus/master] [cannot apply to efi/next next-20230223] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Johan-Hovold/efivarfs-fix-NULL-deref-on-mount-when-no-efivars/20230128-094525 patch link: https://lore.kernel.org/r/20230126112129.4602-1-johan%2Blinaro%40kernel.org patch subject: [PATCH] efivarfs: fix NULL-deref on mount when no efivars config: x86_64-randconfig-a011 (https://download.01.org/0day-ci/archive/20230223/202302231642.tyrVwZMY-lkp@intel.com/config) compiler: gcc-11 (Debian 11.3.0-8) 11.3.0 reproduce (this is a W=1 build): # https://github.com/intel-lab-lkp/linux/commit/da57163cc9d947884520240ec71c2806f48b8a64 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Johan-Hovold/efivarfs-fix-NULL-deref-on-mount-when-no-efivars/20230128-094525 git checkout da57163cc9d947884520240ec71c2806f48b8a64 # save the config file mkdir build_dir && cp config build_dir/.config make W=1 O=build_dir ARCH=x86_64 olddefconfig make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash fs/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> | Link: https://lore.kernel.org/oe-kbuild-all/202302231642.tyrVwZMY-lkp@intel.com/ All errors (new ones prefixed by >>): fs/efivarfs/super.c: In function 'efivarfs_kill_sb': >> fs/efivarfs/super.c:246:14: error: implicit declaration of function 'efivar_is_available'; did you mean 'slab_is_available'? [-Werror=implicit-function-declaration] 246 | if (!efivar_is_available()) | ^~~~~~~~~~~~~~~~~~~ | slab_is_available cc1: some warnings being treated as errors vim +246 fs/efivarfs/super.c 241 242 static void efivarfs_kill_sb(struct super_block *sb) 243 { 244 kill_litter_super(sb); 245 > 246 if (!efivar_is_available()) 247 return; 248 249 /* Remove all entries and destroy */ 250 efivar_entry_iter(efivarfs_destroy, &efivarfs_list, NULL); 251 } 252
Hi Johan, I love your patch! Yet something to improve: [auto build test ERROR on v6.2-rc5] [also build test ERROR on linus/master] [cannot apply to efi/next next-20230223] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Johan-Hovold/efivarfs-fix-NULL-deref-on-mount-when-no-efivars/20230128-094525 patch link: https://lore.kernel.org/r/20230126112129.4602-1-johan%2Blinaro%40kernel.org patch subject: [PATCH] efivarfs: fix NULL-deref on mount when no efivars config: i386-randconfig-a015 (https://download.01.org/0day-ci/archive/20230223/202302231733.iymwHTPf-lkp@intel.com/config) compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/da57163cc9d947884520240ec71c2806f48b8a64 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Johan-Hovold/efivarfs-fix-NULL-deref-on-mount-when-no-efivars/20230128-094525 git checkout da57163cc9d947884520240ec71c2806f48b8a64 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash fs/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> | Link: https://lore.kernel.org/oe-kbuild-all/202302231733.iymwHTPf-lkp@intel.com/ All errors (new ones prefixed by >>): >> fs/efivarfs/super.c:246:7: error: implicit declaration of function 'efivar_is_available' is invalid in C99 [-Werror,-Wimplicit-function-declaration] if (!efivar_is_available()) ^ fs/efivarfs/super.c:246:7: note: did you mean 'slab_is_available'? include/linux/slab.h:171:6: note: 'slab_is_available' declared here bool slab_is_available(void); ^ 1 error generated. vim +/efivar_is_available +246 fs/efivarfs/super.c 241 242 static void efivarfs_kill_sb(struct super_block *sb) 243 { 244 kill_litter_super(sb); 245 > 246 if (!efivar_is_available()) 247 return; 248 249 /* Remove all entries and destroy */ 250 efivar_entry_iter(efivarfs_destroy, &efivarfs_list, NULL); 251 } 252
On Thu, Feb 23, 2023 at 05:03:54PM +0800, kernel test robot wrote: > Hi Johan, > > I love your patch! Yet something to improve: > > [auto build test ERROR on v6.2-rc5] > [also build test ERROR on linus/master] > [cannot apply to efi/next next-20230223] I have no idea what your robot is trying to do here, but this patch has been folded into 301de9a20553 ("efivarfs: always register filesystem") and is already in linux-next building just fine. > [If your patch is applied to the wrong git tree, kindly drop us a note. > And when submitting patch, we suggest to use '--base' as documented in > https://git-scm.com/docs/git-format-patch#_base_tree_information] > > url: https://github.com/intel-lab-lkp/linux/commits/Johan-Hovold/efivarfs-fix-NULL-deref-on-mount-when-no-efivars/20230128-094525 > patch link: https://lore.kernel.org/r/20230126112129.4602-1-johan%2Blinaro%40kernel.org > patch subject: [PATCH] efivarfs: fix NULL-deref on mount when no efivars > config: x86_64-randconfig-a011 (https://download.01.org/0day-ci/archive/20230223/202302231642.tyrVwZMY-lkp@intel.com/config) > compiler: gcc-11 (Debian 11.3.0-8) 11.3.0 > reproduce (this is a W=1 build): > # https://github.com/intel-lab-lkp/linux/commit/da57163cc9d947884520240ec71c2806f48b8a64 > git remote add linux-review https://github.com/intel-lab-lkp/linux > git fetch --no-tags linux-review Johan-Hovold/efivarfs-fix-NULL-deref-on-mount-when-no-efivars/20230128-094525 > git checkout da57163cc9d947884520240ec71c2806f48b8a64 > # save the config file > mkdir build_dir && cp config build_dir/.config > make W=1 O=build_dir ARCH=x86_64 olddefconfig > make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash fs/ > > If you fix the issue, kindly add following tag where applicable > | Reported-by: kernel test robot <lkp@intel.com> > | Link: https://lore.kernel.org/oe-kbuild-all/202302231642.tyrVwZMY-lkp@intel.com/ > > All errors (new ones prefixed by >>): > > fs/efivarfs/super.c: In function 'efivarfs_kill_sb': > >> fs/efivarfs/super.c:246:14: error: implicit declaration of function 'efivar_is_available'; did you mean 'slab_is_available'? [-Werror=implicit-function-declaration] > 246 | if (!efivar_is_available()) > | ^~~~~~~~~~~~~~~~~~~ > | slab_is_available > cc1: some warnings being treated as errors > > > vim +246 fs/efivarfs/super.c > > 241 > 242 static void efivarfs_kill_sb(struct super_block *sb) > 243 { > 244 kill_litter_super(sb); > 245 > > 246 if (!efivar_is_available()) > 247 return; > 248 > 249 /* Remove all entries and destroy */ > 250 efivar_entry_iter(efivarfs_destroy, &efivarfs_list, NULL); > 251 } > 252 Johan
diff --git a/fs/efivarfs/super.c b/fs/efivarfs/super.c index b67d431c861a..482d612b716b 100644 --- a/fs/efivarfs/super.c +++ b/fs/efivarfs/super.c @@ -246,6 +246,9 @@ static void efivarfs_kill_sb(struct super_block *sb) { kill_litter_super(sb); + if (!efivar_is_available()) + return; + /* Remove all entries and destroy */ efivar_entry_iter(efivarfs_destroy, &efivarfs_list, NULL); }