From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from flow-b7-smtp.messagingengine.com (flow-b7-smtp.messagingengine.com [202.12.124.142]) (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 3DA5F30F95A; Thu, 30 Oct 2025 23:38:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.142 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761867483; cv=none; b=gGNdEzgZSaSKv4ZIHfAUDFhERv77A1lokAqTaJfHkX2yCQC//yl59ttEMAl+BSGbtC7km1+z3WymlNw4Aiaql7o62x99XJnRcohk1xtkzQrJ2FJDKqhoLz9vdvBMfByZ8fcSz221v9G2q8bdDEBI5LdQvgxaQJ0eh23hRH7OBjk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761867483; c=relaxed/simple; bh=1JFznHwJ9SmoMKBcNVs4nFsIbrQIPYx/MgpAl4L7FeE=; h=Content-Type:MIME-Version:From:To:Cc:Subject:In-reply-to: References:Date:Message-id; b=liWDuDSzQAW2jyLizSbx2d98u7gpcw0hjF/DTDenn6F2u/GfUAH7+WfAEjWRFlWD96IuYkdl4oeCMlFzW21QSpCl4F2BKoGWJBs74/nMCd+/W5BtnECBaCw3zQPOQ1HjqQFeH/TFnQTYsRPaRqzff51FUdfTYhprDq9pTFe9fls= 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=Ox4MPwGj; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=hEN6xMm3; arc=none smtp.client-ip=202.12.124.142 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="Ox4MPwGj"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="hEN6xMm3" Received: from phl-compute-11.internal (phl-compute-11.internal [10.202.2.51]) by mailflow.stl.internal (Postfix) with ESMTP id 661A61300302; Thu, 30 Oct 2025 19:37:59 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-11.internal (MEProxy); Thu, 30 Oct 2025 19:38:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:cc:content-transfer-encoding:content-type: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= 1761867479; x=1761874679; bh=ARXwRWPRXeSKN/a2GX42QMZWqyYh6A4I7nh hSoUQkaA=; b=Ox4MPwGjPlU7Jlj9LlcQHN5imiEuc2ynryxgmpyWdO9AP2GCH+R Ph1E/ZCQWxDX+zS3gkmj968ICezZUL5iUXVYOa92K5R8JK9SxFuJajrw9BEus8vu aYC320qfxLOrmDrt69pRh6it4iX/g0+3kPqCNTfNu7eH/OVortH3sHVcfTOtiM2p dIYJwgZyMhDpA4zqryLJshkZz3stXt/gFhsbYTXtPUhCD4/dJeZqOfZ38X60aStf RjSQAfCKs3YwhBx4JrBfRPuIIDBk7hqgQxSxcj9zSZ+6fSh+evUr6KKlst0VwHXU yWVypFKp6izNluJDDVz5+9JgWBB+DpKPZxA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type: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=1761867479; x= 1761874679; bh=ARXwRWPRXeSKN/a2GX42QMZWqyYh6A4I7nhhSoUQkaA=; b=h EN6xMm3YCBXxlazAcYuvL9ksO67U4EaE05UPUSkIDkxcR103gn6B4NW6RIbdke7d KRmJv65M7ixo5BCvipseLsEQveJUlN/h2yS6BtBKniOya/PdkvMEwXLyLrlkP552 +3Jg7g8K/FKHwG00gXwelqzzir6QF79i2nFmly56TRaMq/J32k64kG5+oeNxvsz9 mK10xF1caEsIRvleuQpTSRyPJ5p/QEzGcl9I/sZII+doXn4a1H0djy3LWtuDmvAr TDmYW3tqaw1hGK7hkngNP+rNbdUvLusHQH7mxOsye/cAhLNGCqLhzuPNbVILbLVT 6L30TBF6xwUv5c5Uy2OaQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdduieejleehucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurheptgfgggfhvfevufgjfhffkfhrsehtqhertddttdejnecuhfhrohhmpefpvghilheu rhhofihnuceonhgvihhlsgesohifnhhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnh epleejtdefgeeukeeiteduveehudevfeffvedutefgteduhfegvdfgtdeigeeuudejnecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhgvihhlsg esohifnhhmrghilhdrnhgvthdpnhgspghrtghpthhtohepgedupdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehvihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpd hrtghpthhtohepshgvlhhinhhugiesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphht thhopehlihhnuhigqdigfhhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoh eplhhinhhugidquhhnihhonhhfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphht thhopehlihhnuhigqdhsvggtuhhrihhthidqmhhoughulhgvsehvghgvrhdrkhgvrhhnvg hlrdhorhhgpdhrtghpthhtoheplhhinhhugidqnhhfshesvhhgvghrrdhkvghrnhgvlhdr ohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlh drohhrghdprhgtphhtthhopehlihhnuhigqdhfshguvghvvghlsehvghgvrhdrkhgvrhhn vghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqtghifhhssehvghgvrhdrkhgvrhhnvg hlrdhorhhg X-ME-Proxy: Feedback-ID: iab3e480c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 30 Oct 2025 19:37:46 -0400 (EDT) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: NeilBrown To: "Al Viro" Cc: "Christian Brauner" , "Amir Goldstein" , "Jan Kara" , linux-fsdevel@vger.kernel.org, "Jeff Layton" , "Chris Mason" , "David Sterba" , "David Howells" , "Greg Kroah-Hartman" , "Rafael J. Wysocki" , "Danilo Krummrich" , "Tyler Hicks" , "Miklos Szeredi" , "Chuck Lever" , "Olga Kornievskaia" , "Dai Ngo" , "Namjae Jeon" , "Steve French" , "Sergey Senozhatsky" , "Carlos Maiolino" , "John Johansen" , "Paul Moore" , "James Morris" , "Serge E. Hallyn" , "Stephen Smalley" , "Ondrej Mosnacek" , "Mateusz Guzik" , "Lorenzo Stoakes" , "Stefan Berger" , "Darrick J. Wong" , linux-kernel@vger.kernel.org, netfs@lists.linux.dev, ecryptfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-cifs@vger.kernel.org, linux-xfs@vger.kernel.org, apparmor@lists.ubuntu.com, linux-security-module@vger.kernel.org, selinux@vger.kernel.org Subject: Re: [PATCH v4 11/14] Add start_renaming_two_dentries() In-reply-to: <20251030062214.GW2441659@ZenIV> References: <20251029234353.1321957-1-neilb@ownmail.net>, <20251029234353.1321957-12-neilb@ownmail.net>, <20251030062214.GW2441659@ZenIV> Date: Fri, 31 Oct 2025 10:37:44 +1100 Message-id: <176186746483.1793333.1130347070516464496@noble.neil.brown.name> Reply-To: NeilBrown On Thu, 30 Oct 2025, Al Viro wrote: > On Thu, Oct 30, 2025 at 10:31:11AM +1100, NeilBrown wrote: >=20 > > +++ b/fs/debugfs/inode.c >=20 > Why does debugfs_change_name() need any of that horror? Seriously, WTF? > This is strictly a name change on a filesystem that never, ever moves > anything from one directory to another. "horror" is clearly in the eye of the beholder, and not a helpful description... Is there anything in this use of start_renaming_two_dentries() which is harmful? I agree that not all of the functionality is needed in this case, but some of it is. Would you prefer we also add start_renaming_two_dentries_with_same_parent() or similar? >=20 > IMO struct renamedata is a fucking eyesore, but that aside, this: >=20 > > @@ -539,22 +540,30 @@ static int sel_make_policy_nodes(struct selinux_fs_= info *fsi, > > if (ret) > > goto out; > > =20 > > - lock_rename(tmp_parent, fsi->sb->s_root); > > + rd.old_parent =3D tmp_parent; > > + rd.new_parent =3D fsi->sb->s_root; > > =20 > > /* booleans */ > > - d_exchange(tmp_bool_dir, fsi->bool_dir); > > + ret =3D start_renaming_two_dentries(&rd, tmp_bool_dir, fsi->bool_dir); > > + if (!ret) { > > + d_exchange(tmp_bool_dir, fsi->bool_dir); > > =20 > > - swap(fsi->bool_num, bool_num); > > - swap(fsi->bool_pending_names, bool_names); > > - swap(fsi->bool_pending_values, bool_values); > > + swap(fsi->bool_num, bool_num); > > + swap(fsi->bool_pending_names, bool_names); > > + swap(fsi->bool_pending_values, bool_values); > > =20 > > - fsi->bool_dir =3D tmp_bool_dir; > > + fsi->bool_dir =3D tmp_bool_dir; > > + end_renaming(&rd); > > + } > > =20 > > /* classes */ > > - d_exchange(tmp_class_dir, fsi->class_dir); > > - fsi->class_dir =3D tmp_class_dir; > > + ret =3D start_renaming_two_dentries(&rd, tmp_class_dir, fsi->class_dir); > > + if (ret =3D=3D 0) { > > + d_exchange(tmp_class_dir, fsi->class_dir); > > + fsi->class_dir =3D tmp_class_dir; > > =20 > > - unlock_rename(tmp_parent, fsi->sb->s_root); > > + end_renaming(&rd); > > + } > > =20 > > out: > > sel_remove_old_bool_data(bool_num, bool_names, bool_values); >=20 > is very interesting - suddenly you get two non-overlapping scopes instead o= f one. > Why is that OK? >=20 >From the perspective of code performing lookup of these names, two consecutive lookups would not be locked so they could see inconsistencies anyway. >From the perspective of code changing these names, that is protected by selinux_state.policy_mutex which is held across the combined operation. A readdir could possibly see the old inum for one name and the new inum for the other name. I don't imagine this would be a problem. I have added a comment to the commit message to highlight this. Thanks, NeilBrown