From nobody Thu Apr 2 04:58:04 2026 Received: from flow-a2-smtp.messagingengine.com (flow-a2-smtp.messagingengine.com [103.168.172.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 46E20344D98; Tue, 24 Feb 2026 22:26:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.137 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771972011; cv=none; b=aOMVrgqLWNa3a3tUvUemUo/8qClE0iWea/A/t3kGvTBEJwKAOAI/1klxusjz4/EZ5bUm9o11kY1ZYRrCMTXyYthgcf8R/aRv8fB8RKOSmDpl1pZiAAj8Vt5ELqc4YMQij3cUxXxRzIufo47qNGNa4GhgQJlF4NxQxiuezENjRaU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771972011; c=relaxed/simple; bh=XdH95tiFrQ/sKORHCrxucIV+VvmedwyPT7NUDj0XhsU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oqPUMAB+4JkJZCfM00MZSr1yOa41JG5pDnk/V78xqHZo04clQ63LX3n/4ZDbDb4mw6pX6hGRjIbXc3gdUVvAXgJk+bbeiFVYgFoIvgwQ4OkcDSjcEc/Y1eepTWmlI1veGvB0iAZRUwFJikwGPTqNRLaylbe+KNYMfJri39RxAZw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b=Dxxendxg; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=fW+7qVBm; arc=none smtp.client-ip=103.168.172.137 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ownmail.net header.i=@ownmail.net header.b="Dxxendxg"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="fW+7qVBm" Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailflow.phl.internal (Postfix) with ESMTP id A3CA213805A6; Tue, 24 Feb 2026 17:26:48 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Tue, 24 Feb 2026 17:26:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm3; t=1771972008; x=1771979208; bh=uXMU6tWLxH62oiHRDx59UoQh2FcFUEj9XaKWMgxDywE=; b= DxxendxgyK6rTiqG/fxumh1kOC6ytof4U4niPIav51NX7ee/mCUy0bU+TUm+/0Mm rFj2T38yPbTdz9PP3+zc+ovcdQXWWs/Dd5/r2DA0CLQy6p4a6DvvBx6FDbv+CVXL uDjQuYQvf5ea1y9rg2MrEzKlaEEZCht9eSHlLCMx3AkrdMwxU+aN7fBkpoek9xTR 4PVF+NCj1EPeG7h/0P9DsB77rKWQnnchfa7OErS6boEFK0f1NfQAD+lrFjz9Asgc HrAkn3QmXAQteBcAckwenqh5ufmzzshcWB1aKTyHJ+xzE4IHeYTh/CIvXHa9CGg3 3gAB0KwqmPs7v3X3LpnZBA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1771972008; x=1771979208; bh=u XMU6tWLxH62oiHRDx59UoQh2FcFUEj9XaKWMgxDywE=; b=fW+7qVBmtWMZCbjyx hnRlX0IaoiA7RThWcfCR03kI9XQ2zX8Khs3d/poMc4rqnMGdv1tfcfF6tWtGGgJ1 duI9rVPkdEpp/HjFy/BXyhblmTBTS5ML+2s9HqJ/S1RathJXRQP4FKvtpM/KTLsT 8c4FAq5J2neZoaWMwkcEetoH1+FfPadcHWq+L0E0IBNjkulXWQSJJi0+NbKBQXF4 Yyzhasq874CLbWLTM6lr47KRLYE51Ru9oVY4i4rIDpZFr28ntAjnC+zFAiqonBAh m7WOlInrlEOnf99F0tljLcn3JbSLPx73PnRrj6toPcnwq8rhagPp7ttw+bvyvLyl Luvdw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvgedufeekucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhhrggfgsedtkeertdertddtnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epveevkeffudeuvefhieeghffgudektdelkeejiedtjedugfeukedvkeffvdefvddunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohepvddvpdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtohepshgvlhhinhhugiesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphht thhopehlihhnuhigqdhunhhiohhnfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtg hpthhtoheplhhinhhugidqshgvtghurhhithihqdhmohguuhhlvgesvhhgvghrrdhkvghr nhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhnfhhssehvghgvrhdrkhgvrhhnvg hlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqfhhsuggvvhgvlhesvhhgvghrrdhkvg hrnhgvlhdrohhrghdprhgtphhtthhopehmihhklhhoshesshiivghrvgguihdrhhhupdhr tghpthhtohepjhgrtghksehsuhhsvgdrtgii X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 24 Feb 2026 17:26:42 -0500 (EST) From: NeilBrown To: Christian Brauner , Alexander Viro , David Howells , Jan Kara , Chuck Lever , Jeff Layton , Miklos Szeredi , Amir Goldstein , John Johansen , Paul Moore , James Morris , "Serge E. Hallyn" , Stephen Smalley , "Darrick J. Wong" Cc: linux-kernel@vger.kernel.org, netfs@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org, apparmor@lists.ubuntu.com, linux-security-module@vger.kernel.org, selinux@vger.kernel.org Subject: [PATCH v3 06/15] selinux: Use simple_start_creating() / simple_done_creating() Date: Wed, 25 Feb 2026 09:16:51 +1100 Message-ID: <20260224222542.3458677-7-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20260224222542.3458677-1-neilb@ownmail.net> References: <20260224222542.3458677-1-neilb@ownmail.net> Reply-To: NeilBrown Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: NeilBrown Instead of explicitly locking the parent and performing a lookup in selinux, use simple_start_creating(), and then use simple_done_creating() to unlock. This extends the region that the directory is locked for, and also performs a lookup. The lock extension is of no real consequence. The lookup uses simple_lookup() and so always succeeds. Thus when d_make_persistent() is called the dentry will already be hashed. d_make_persistent() handles this case. Reviewed-by: Jeff Layton Acked-by: Paul Moore Signed-off-by: NeilBrown --- security/selinux/selinuxfs.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c index 3245cc531555..83aa765a09f9 100644 --- a/security/selinux/selinuxfs.c +++ b/security/selinux/selinuxfs.c @@ -1931,27 +1931,26 @@ static const struct inode_operations swapover_dir_i= node_operations =3D { static struct dentry *sel_make_swapover_dir(struct super_block *sb, unsigned long *ino) { - struct dentry *dentry =3D d_alloc_name(sb->s_root, ".swapover"); + struct dentry *dentry; struct inode *inode; =20 - if (!dentry) - return ERR_PTR(-ENOMEM); - inode =3D sel_make_inode(sb, S_IFDIR); - if (!inode) { - dput(dentry); + if (!inode) return ERR_PTR(-ENOMEM); + + dentry =3D simple_start_creating(sb->s_root, ".swapover"); + if (IS_ERR(dentry)) { + iput(inode); + return dentry; } =20 inode->i_op =3D &swapover_dir_inode_operations; inode->i_ino =3D ++(*ino); /* directory inodes start off with i_nlink =3D=3D 2 (for "." entry) */ inc_nlink(inode); - inode_lock(sb->s_root->d_inode); d_make_persistent(dentry, inode); inc_nlink(sb->s_root->d_inode); - inode_unlock(sb->s_root->d_inode); - dput(dentry); + simple_done_creating(dentry); return dentry; // borrowed } =20 --=20 2.50.0.107.gf914562f5916.dirty