From patchwork Mon Mar 6 21:55:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9607789 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E1EA1601D2 for ; Mon, 6 Mar 2017 22:29:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E4CF2793B for ; Mon, 6 Mar 2017 22:29:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 230BC2846C; Mon, 6 Mar 2017 22:29:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8E202793B for ; Mon, 6 Mar 2017 22:29:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932490AbdCFW2h (ORCPT ); Mon, 6 Mar 2017 17:28:37 -0500 Received: from mail-pf0-f179.google.com ([209.85.192.179]:35609 "EHLO mail-pf0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754240AbdCFW2Q (ORCPT ); Mon, 6 Mar 2017 17:28:16 -0500 Received: by mail-pf0-f179.google.com with SMTP id j5so66006138pfb.2 for ; Mon, 06 Mar 2017 14:28:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FrODZ26Y5vxsPmtFEAykZCiUeFRh4//sSAtZqJ10W+w=; b=baST1iIPhXIfx2s1pTm6UnQjUJZek/wEQF6cnJNwJWTE3w51jTYzRgvEG6aZZaWliy pbVDvYZX4UQhCYdeq5kqubp+pt+EWSQSVI3+acFAUh0naStp0/W+32uK+JB/4Mcxp0I1 UXURTnknqRknCOE4IPAWwxgWPZxU9NxB/yKpU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FrODZ26Y5vxsPmtFEAykZCiUeFRh4//sSAtZqJ10W+w=; b=PbaTSDs0AnjnB1ShqWsqc1zPakvkCNeeHItQU3CEMG58QQSQ4Xb+ot5ofXsTXd0lmU HQ34NZXHNBKUXoUNzhxUqnQVCIT/c8nAE9PBhmj6W832DnHoi7h09uvgiP5Q31VY8pFI NJLj5ta0A3T6fxQzs/sZkdeWBASx0pxWFZFtXrYww2cAKpH5Wk3m1h2OxWAkpnbsBLvl e6EOlG6ZNeF05zskb0rFUD4+ZL/rlL+R13jsvmLiUnoIMuVDFdUjnG8rA2Kr6UWN21mB T50B5MWdxSKRgCi5U/ewDBvTp1sEtrXY6YBYEzuGFOC8Pn7PYM/eXeCyvkb3bLhjaVqr YwvA== X-Gm-Message-State: AMke39lKPo64kkhELDVg988IH4vRqjVT2Ch9KVA1xk8c6OUTOHTya3duOiAszUqYgTXHexN9 X-Received: by 10.84.216.81 with SMTP id f17mr29723164plj.170.1488837338107; Mon, 06 Mar 2017 13:55:38 -0800 (PST) Received: from www.outflux.net ([2002:ada4:7085:0:205a:2b55:4e6d:7d63]) by smtp.gmail.com with ESMTPSA id d199sm9937303pfd.107.2017.03.06.13.55.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Mar 2017 13:55:36 -0800 (PST) From: Kees Cook To: linux-kernel@vger.kernel.org Cc: Kees Cook , 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 Subject: [PATCH 03/18] pstore: Avoid race in module unloading Date: Mon, 6 Mar 2017 13:55:17 -0800 Message-Id: <1488837332-71582-4-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488837332-71582-1-git-send-email-keescook@chromium.org> References: <1488837332-71582-1-git-send-email-keescook@chromium.org> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Technically, it might be possible for struct pstore_info to go out of scope after the module_put(), so report the backend name first. 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);