From nobody Thu Apr 2 06:27:58 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 52DC6349AF5; Tue, 24 Feb 2026 22:27:47 +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=1771972069; cv=none; b=Ou+11k0fWpLuyduWTa2w0Vwqt+BjMuLsNyWm03tT9H9zYkvYEUWRv5BhplFHTiiv8r41RvqqrIzBee4O/X8qmlGDHUk5G/uipsho5uUAaxXlTWMWg1oFiPkLEWkAz3amp7NPOPPyn5YkDkH+i/mVFZEx8ieeb/3ftQGFEXYsg20= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771972069; c=relaxed/simple; bh=8npN8lDUKLB/B/vi6olsXCscd/grdMnQXyTSElVQCIQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nyY/PNOhlOQnqg5ehihYfnisCylprj3kJ6LFxdw1//4T4EX2oOZ2Pt7zya95AuG7tc4VGb3KRo8NySL3u9aO+ruwGubikxi4M3K68ewo+DpDqTtJabGT04i86XHsHJkvdB7uheI54zLN/PGWHZzZTUex2HwG9lWzBM/FwVkqpos= 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=eunBjtdv; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=DFvVp2g0; 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="eunBjtdv"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="DFvVp2g0" Received: from phl-compute-11.internal (phl-compute-11.internal [10.202.2.51]) by mailflow.phl.internal (Postfix) with ESMTP id A16B0138052C; Tue, 24 Feb 2026 17:27:46 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-11.internal (MEProxy); Tue, 24 Feb 2026 17:27:46 -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=1771972066; x=1771979266; bh=zoLaKvUIcq0LBSrvSvYdTrZyLAsLuraYZU3vedQYf7U=; b= eunBjtdvb7py65uKkhmWny3U0yrgkknbEzMVQWKR+94mqZBtzVxNG5UcQZeTXet1 f+sFFa1H7+k0RQ3dGy17Q8a4likxcrMxwnAG/xA499ylO5Abt49a3ZDk85O9WQr9 Cz0DTv8sPh8sqCI+a9KXs/NaCZ1kJGNLh1MCaj4Ag5LoDF8GCMewVz6BNuXdz1tL +WSGeeV8W7HNwadLfkZJdMj/b2WxWBMSME2ppKQ28WbR+H/+ugCmHg7deoZiiZWv PSfz9SjKvntrtb6Z8/ba/hoFi1Y2tsfv6rq+4AW6LMiMsxHzAAoG6skhYXbrIjXN +c2A0Ea/Sv+A43yHxjYu/g== 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=1771972066; x=1771979266; bh=z oLaKvUIcq0LBSrvSvYdTrZyLAsLuraYZU3vedQYf7U=; b=DFvVp2g0aej3dNXGt WHFp/uzE8GtGq2WoHKtqHDsKXVgQ6Q7svrfudc4BRLDYwF3ZxQ0DcNnh7bJ0Y7Ly 3PBvs8vIjLmWL76cuGp601c+1oOwQnel/RaE9da0J5l0iuMTeDVpRRV8O11455SG kNCkqICmXWzTkaZN1demnwZvrZgKHrTVekon1VvKRJQDackfFkM51A2Wa+Iqkxu0 CBd6pi8lMlBSrn3VIs141ef66gGoy81xRjSb4mnmuxyWUNvIERuuYIIVgzuUEkon oSxZJSRGrdBIrQSE7yMPTqlbVdZotyhWZzEONFfP4J6acQyOTW0v/5FTIm6ZBB/o vViKw== 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:27:40 -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 13/15] ovl: use is_subdir() for testing if one thing is a subdir of another Date: Wed, 25 Feb 2026 09:16:58 +1100 Message-ID: <20260224222542.3458677-14-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 Rather than using lock_rename(), use the more obvious is_subdir() for ensuring that neither upper nor workdir contain the other. Also be explicit in the comment that the two directories cannot be the same. As this is a point-it-time sanity check and does not provide any on-going guarantees, the removal of locking does not introduce any interesting races. Reviewed-by: Amir Goldstein Reviewed-by: Jeff Layton Signed-off-by: NeilBrown --- fs/overlayfs/super.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index 109643930b9f..58adefb1c5b8 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -451,18 +451,13 @@ static int ovl_lower_dir(const char *name, const stru= ct path *path, return 0; } =20 -/* Workdir should not be subdir of upperdir and vice versa */ +/* + * Workdir should not be subdir of upperdir and vice versa, and + * they should not be the same. + */ static bool ovl_workdir_ok(struct dentry *workdir, struct dentry *upperdir) { - bool ok =3D false; - - if (workdir !=3D upperdir) { - struct dentry *trap =3D lock_rename(workdir, upperdir); - if (!IS_ERR(trap)) - unlock_rename(workdir, upperdir); - ok =3D (trap =3D=3D NULL); - } - return ok; + return !is_subdir(workdir, upperdir) && !is_subdir(upperdir, workdir); } =20 static int ovl_setup_trap(struct super_block *sb, struct dentry *dir, --=20 2.50.0.107.gf914562f5916.dirty