From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796385641; b=VVk57C6vvpnj1wcPnNk3CAMnLBaZwg3qxkOp3CsMkogCPryVxH/aZ4x6SX89aaXgJRJV BCkRmReauQB+nBlHzUtXRNbO63Roc5zKfCZnvt6U2vK2JARUvnuDxyefANDTvpGn7WWVD h7sJiVooBCG05AJH+RrTsfw5JbLEksreSOdO8b5KDILsWUZrWqk6oLxmTXNXMVuDEa9Fp +HJySPYKKd2G1Dsf9uWBlHgqlDucVJrhjrr7SjHw6cLsYrUcy72V1ctDtmtZOo74yOVPU G4KRS8kAD5SAyA+LcRCwBjZ3XRd+/b2Y4xV+bzu/dEh1g/X6eeHfJVlRlU34bVZh0TQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385641; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=0q9gwxN3I2DkdO2SP6d6/ntqvQoSZjSz1QWrhda2o6w=; b=NIevKkV5Krs7JcyPFrVkXx1iqdwKOVtu2ilxI8s2dHorvWgOMfOZ8T8kHnQeabgYgoj/ G65wQKZabkwVv1c421sZbpLwB7a/9nXHbDhYNkRppTS/hTpF35kVdftKFxhPb84o8eYbx htT7YcGXo0Xq1gOgBali5gpTeH1Kfopk0rGhEVL+oh17pa7ssOCB1LKWHBZYW5XRWQu8G 34jqW6Zd4EA5nkt8adzxHzjQ3FZOQ2BfqiBt7N4NeVcIl5BkTGnvkJyeotOibv7VsSkXs /oePwAjARvMGY07Je4nUCI63vlpg4ln+GO7sAOtPY6g5jMwS2Lf3tOItjdco261Rb9Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=cv0M82a+; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F404606A32C; Fri, 4 Dec 2026 12:00:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=cv0M82a+ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C2BA1F0092C; Fri, 4 Dec 2026 12:00:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385641; bh=0q9gwxN3I2DkdO2SP6d6/ntqvQoSZjSz1QWrhda2o6w=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=cv0M82a+1GOEmsAYf1XCOp9y8yymHSy6X6pLezK1+pwLPLBs6++T+iC7qXAo4YG2N RaJe0+K4dv5uqPhJdgZ3w0IPkA0UodXu8bt7XHV3tUB7r7RTXnhacjtT+BIT98Q0fO rV1P7R9Gdq3qC11LjRVrjfLlw7zJGTbMcZpELmZg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Christian Brauner , =?UTF-8?q?J=C3=A9r=C3=A9my=20Jean?= , Amir Goldstein Subject: [PATCH 6.6 0590/1167] ovl: reject different lower idmaps on the same fs Date: Fri, 4 Dec 2026 19:00:17 +0900 Message-ID: <20261204100717.420658051@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jérémy Jean commit 720f40c05b2785406121da0151543751204f2953 upstream. Overayfs mounted with index=on or nfs_export=on require file handle support from backing filesystems. Overlay file handles identify a backing filesystem, but not the lower mount used to decode it. If lower layers share a superblock and use different idmaps, a handle can decode through the wrong layer. Record the first idmap on a private lower clone for each backing filesystem. Fail if another clone has a different idmap. Comparing the private clones prevents mount_setattr() from changing the checked state. Distinct idmap objects are treated as ambiguous. Fixes: bc70682a497c ("ovl: support idmapped layers") Suggested-by: Christian Brauner Link: Link: https://lore.kernel.org/all/20260925-server-hager-riskieren-06116eded213@brauner/ Cc: stable@vger.kernel.org Signed-off-by: Jérémy Jean Signed-off-by: Amir Goldstein Signed-off-by: Greg Kroah-Hartman --- fs/overlayfs/ovl_entry.h | 2 ++ fs/overlayfs/super.c | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) --- a/fs/overlayfs/ovl_entry.h +++ b/fs/overlayfs/ovl_entry.h @@ -24,6 +24,8 @@ struct ovl_config { struct ovl_sb { struct super_block *sb; dev_t pseudo_dev; + /* Idmap of the first lower layer on this fs */ + const struct mnt_idmap *lower_idmap; /* Unusable (conflicting) uuid */ bool bad_uuid; /* Used as a lower layer (but maybe also as upper) */ --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -1117,6 +1117,29 @@ static int ovl_get_layers(struct super_b } /* + * Lower file handles identify the lower fs, but not the layer, + * so with different idmaps on the same lower fs, index and + * nfs_export may decode a file handle through a layer with the + * wrong idmap. Following copy up origin without index is only + * used for st_ino, which does not depend on the idmap. + */ + if (i < nr_merged_lower && + (ofs->config.index || ofs->config.nfs_export)) { + const struct mnt_idmap *idmap = mnt_idmap(mnt); + struct ovl_sb *fs = &ofs->fs[fsid]; + + if (!fs->lower_idmap) { + fs->lower_idmap = idmap; + } else if (fs->lower_idmap != idmap) { + pr_err("lower layer '%pd2' conflicts with idmap of another lower layer on the same fs, mount with '-o index=off,nfs_export=off' to override.\n", + l->path.dentry); + iput(trap); + kern_unmount(mnt); + return -EINVAL; + } + } + + /* * Make lower layers R/O. That way fchmod/fchown on lower file * will fail instead of modifying lower fs. */