Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2044654rwb; Fri, 2 Dec 2022 04:55:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf6gY07LpHzRdnfRRS4kZZDXRrrzuoC+ppY0Tjf9FWSjr0hgBbL3rZK84VNFnCPOLzy3aDG3 X-Received: by 2002:a65:6c0d:0:b0:470:7886:e200 with SMTP id y13-20020a656c0d000000b004707886e200mr52061375pgu.111.1669985733291; Fri, 02 Dec 2022 04:55:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669985733; cv=none; d=google.com; s=arc-20160816; b=erZZSqKc3kGCvZVTt9dyUZJsZvr1q+rLE+rKGK0wWhiACWIc5ii3R5e73jNaTUDM3g vBcrOWDuP2Hp2D7xNqzByRNXKk2dxG8/2GUaqDbNbM5VRHe/MosO1j459f1FGuhbPQSr XJcCARmuFEiahzneHtiKGHoA/InmlZJkS/nSqn6JTyQhY9v8vu181PVTmGYjL5d2BrO4 XggQjhp4/A9FOhN6stG+K9RNnwGLmAoVaJewqWTdEaMcDVHVQQirvNGZGtJU0e6VEXmj FNEnffZSB3Gvva0MqkxhIqzOWeme+BMvI6eZ7ncW3xGm2QSJaQGPrHiVCbRzlgKDBq+R XO3Q== 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; bh=b2IRnrm+I2gOA6t6Is3guuC27DUZk9YV3rbhZ/DI6B0=; b=mw+Ru/yqu23uAD5wB3E6vJ7NAIM2sjC1x0pEhKT1HKK3FZBy2YqICTcU18T1jD58J1 gCxzvJscOTsJxDs0u6FwMeNsEYzsIYsSQyml84uG+ogt6iGN8wVut9nsbkuCVPIQ2tEz 50ViRx0WMeE8PB5z7P0uS5bS0GHiuDPH5LY4u7Nb/ZTiKKYMij6Amvs03cFtcCro+HAR Q8wTLvilg1TEAT4MaXfG49L4sM+GUfN0PVla2YrNg+D5+f+SmSHfq4ZVQ8xFCJwdMedB PgQ2r6+kghEOyiK6QS2VuQu4eiuABXKfCoWkJl9j501W04TyEnMZXsrHrgQn7SxT1xAc yjqQ== 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cm9-20020a056a00338900b00572ef957b35si7032695pfb.210.2022.12.02.04.55.23; Fri, 02 Dec 2022 04:55:33 -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; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233557AbiLBMpl (ORCPT + 83 others); Fri, 2 Dec 2022 07:45:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232801AbiLBMpj (ORCPT ); Fri, 2 Dec 2022 07:45:39 -0500 Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 216F5DCBD9 for ; Fri, 2 Dec 2022 04:45:34 -0800 (PST) Received: from dev011.ch-qa.sw.ru ([172.29.1.16]) by relay.virtuozzo.com with esmtp (Exim 4.95) (envelope-from ) id 1p15Pp-005MRe-O6; Fri, 02 Dec 2022 13:45:17 +0100 From: Alexander Atanasov To: Greg Kroah-Hartman , "Rafael J. Wysocki" Cc: kernel@openvz.org, Alexander Atanasov , linux-kernel@vger.kernel.org Subject: [PATCH] devtmpfs: move NULLing the thread pointer before unregistering fs Date: Fri, 2 Dec 2022 14:45:01 +0200 Message-Id: <20221202124502.217462-1-alexander.atanasov@virtuozzo.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE 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 In commit 31c779f293b3 ("devtmpfs: fix the dangling pointer of global devtmpfsd thread") a dangling pointer on an error condition was fixed. But the fix left the dangling pointer during unregister_filesystem and printk calls. Improve the fix to clear the pointer before unregistration to close the window where the dangling pointer can be potentially used. Make it clear the pointer at only one place in the function. Signed-off-by: Alexander Atanasov --- drivers/base/devtmpfs.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c index e4bffeabf344..773e66ef5642 100644 --- a/drivers/base/devtmpfs.c +++ b/drivers/base/devtmpfs.c @@ -472,17 +472,15 @@ int __init devtmpfs_init(void) } thread = kthread_run(devtmpfsd, &err, "kdevtmpfs"); - if (!IS_ERR(thread)) { + if (!IS_ERR(thread)) wait_for_completion(&setup_done); - } else { + else err = PTR_ERR(thread); - thread = NULL; - } if (err) { + thread = NULL; printk(KERN_ERR "devtmpfs: unable to create devtmpfs %i\n", err); unregister_filesystem(&dev_fs_type); - thread = NULL; return err; } base-commit: b7b275e60bcd5f89771e865a8239325f86d9927d -- 2.31.1