Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4661639pxj; Wed, 12 May 2021 10:18:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQxNbxDX0ro4euHhY+sb6fk2P15IcqsuGvNDCroL6UBteQYADXKGkK0ag0684Ag5ERnkSy X-Received: by 2002:a50:f41a:: with SMTP id r26mr44495714edm.339.1620839774827; Wed, 12 May 2021 10:16:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620839774; cv=none; d=google.com; s=arc-20160816; b=SZUMcWISxBktTHf18uOSYXREh7zY9HaONQrpUKdQEHwVuij30v0T+UKyHl6ZHgrqf7 9NAlhkhdfd0dwozvqGKY11bLY8pv2zEgev+Crl5XZsKIBfu4fHa3rWvjAY5Fl511DGrt eapgHKVQcIUzAnr/+V6qTnEKTFeSpi46isiizWj0pclROndWpI4EV1EjLDdLxLhCvMb0 wdoG2lzudC5ka1s/wsTm7BNbwY2hWtKRS5CBiiTz43p42OIoEZVOUfKGfrcFBgw9jyoB kX44VZROFSGhQNPzQoRMOpbSLwHRVh8kejoAokJvYdcpOqT6BRtIhDQtZHxHD/U0tsom hJTg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=M/L8+szmmBM1XBAEKry3uCf1xAVDGvOQqNzkL1mJVcY=; b=CiYk2ViZvSzv0onPVG8mi0V1gokgu2BTvtLQcLlKVfxO/5/SooR/RIVTAGNIKe58Rt 5cu3ePxYxoP1QhhRzlFZ3+vKFq89b/Z+uHIrgteC4yeBpu1oUN7Jw4nGXK4/uDFuslqA YWJNVpkLOiyhtI3oKDLvJqj/gkf4EOYGVTpO5nefdzaIW24R2cs6uCIYC8SjqvTY1lFD Ykqv5va7xGxclJy/DMEOBIyEcbgtwqZCB1C6NGn8ELzztRx7xUtYrsG1b5J2JnUSqoLw fgGyCFy9gkmXCguR8H/cBE5xsDR+1dSCi/Hjdy8RgGxovew2c6RNG9NdaUHAw36Y92D/ rQJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BHjjEb3p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w16si300948edd.85.2021.05.12.10.15.50; Wed, 12 May 2021 10:16:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BHjjEb3p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345877AbhELRMN (ORCPT + 99 others); Wed, 12 May 2021 13:12:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:48160 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235387AbhELP7m (ORCPT ); Wed, 12 May 2021 11:59:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EBC3C6197B; Wed, 12 May 2021 15:32:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620833540; bh=sBEwm+uHlyVNF45BaxNuJHaixHJpYJV7yDlSlaGqhwU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BHjjEb3pvHKxj7LvnKVAZ2Qlw7s05b0J6I6Pp4TzLvPZu7CUsEoIALhIqRa90kaiQ 1d2MtELUyyIbssJ5tKyr86yLONa484CGCifAzfI2/ztyxK+spwGosFC4nVud5kEAVJ iDrosrE8aMKg8q5FoBft9CZzHRGPKzObm81q+d84= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christoph Hellwig , Rasmus Villemoes , Sasha Levin Subject: [PATCH 5.11 191/601] devtmpfs: fix placement of complete() call Date: Wed, 12 May 2021 16:44:28 +0200 Message-Id: <20210512144834.122538521@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144827.811958675@linuxfoundation.org> References: <20210512144827.811958675@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rasmus Villemoes [ Upstream commit 38f087de8947700d3b06d3d1594490e0f611c5d1 ] Calling complete() from within the __init function is wrong - theoretically, the init process could proceed all the way to freeing the init mem before the devtmpfsd thread gets to execute the return instruction in devtmpfs_setup(). In practice, it seems to be harmless as gcc inlines devtmpfs_setup() into devtmpfsd(). So the calls of the __init functions init_chdir() etc. actually happen from devtmpfs_setup(), but the __ref on that one silences modpost (it's all right, because those calls happen before the complete()). But it does make the __init annotation of the setup function moot, which we'll fix in a subsequent patch. Fixes: bcbacc4909f1 ("devtmpfs: refactor devtmpfsd()") Reviewed-by: Christoph Hellwig Signed-off-by: Rasmus Villemoes Link: https://lore.kernel.org/r/20210312103027.2701413-1-linux@rasmusvillemoes.dk Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/base/devtmpfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c index eac184e6d657..a71d14117943 100644 --- a/drivers/base/devtmpfs.c +++ b/drivers/base/devtmpfs.c @@ -416,7 +416,6 @@ static int __init devtmpfs_setup(void *p) init_chroot("."); out: *(int *)p = err; - complete(&setup_done); return err; } @@ -429,6 +428,7 @@ static int __ref devtmpfsd(void *p) { int err = devtmpfs_setup(p); + complete(&setup_done); if (err) return err; devtmpfs_work_loop(); -- 2.30.2