Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933016AbdCGQZM (ORCPT ); Tue, 7 Mar 2017 11:25:12 -0500 Received: from mail-ua0-f194.google.com ([209.85.217.194]:35469 "EHLO mail-ua0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755435AbdCGQY4 (ORCPT ); Tue, 7 Mar 2017 11:24:56 -0500 MIME-Version: 1.0 In-Reply-To: <1488837332-71582-4-git-send-email-keescook@chromium.org> References: <1488837332-71582-1-git-send-email-keescook@chromium.org> <1488837332-71582-4-git-send-email-keescook@chromium.org> From: Namhyung Kim Date: Wed, 8 Mar 2017 01:16:43 +0900 X-Google-Sender-Auth: X0s5hMKMOpT1c3kbPR8v3Kv8V5Y Message-ID: Subject: Re: [PATCH 03/18] pstore: Avoid race in module unloading To: Kees Cook Cc: LKML , Nobuhiro Iwamatsu , Qiuxu Zhuo , Ard Biesheuvel , Anton Vorontsov , Colin Cross , Tony Luck , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , "Rafael J. Wysocki" , Len Brown , Matt Fleming , Nathan Fontenot , Pan Xinhui , Daniel Axtens , Paul Gortmaker , Geliang Tang , linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org, linux-efi@vger.kernel.org, linux-doc@vger.kernel.org Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1036 Lines: 40 Hi Kees, On Tue, Mar 7, 2017 at 6:55 AM, Kees Cook wrote: > Technically, it might be possible for struct pstore_info to go out of > scope after the module_put(), so report the backend name first. But in that case, using pstore will crash the kernel anyway, right? If so, why pstore doesn't keep a reference until unregister? Do I miss something? Thanks, Namhyung > > Signed-off-by: Kees Cook > --- > fs/pstore/platform.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c > index 074fe85a2078..d69ef8a840b9 100644 > --- a/fs/pstore/platform.c > +++ b/fs/pstore/platform.c > @@ -722,10 +722,10 @@ int pstore_register(struct pstore_info *psi) > */ > backend = psi->name; > > - module_put(owner); > - > pr_info("Registered %s as persistent store backend\n", psi->name); > > + module_put(owner); > + > return 0; > } > EXPORT_SYMBOL_GPL(pstore_register); > -- > 2.7.4 >