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=1796388769; b=uL+qRGryPCAwaKzvBPyxJfa5x4OhCGM/wpoAwNbe/NCfc4vr6G83bZ/ynMCv6BID0opu 1ETkTg6QTXpLQnijsbiNBVA3+RbvUbuR3AIxXxNc2k0CSsc05udBXZ/6lbychYAWK8ILN bB5IWxg3DzTETwSaP7f/7tZGeW6ls4Nm48CjD2uTJUa9H/ntzb5of8/B63aJooXMebe1b UhJYNi6ASR6LwSHdm5wBfHyCmsNQN8W5XdyjGD8NGOZutEIRe2gX69z6GjszVr975L82s 6pOCfQckjA7So4zMhDquNdqNCKC0IYPJ2/WmR/LW1H9z+P3X0reaUs6NOOkG0wmGiGQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388769; 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=9nyKoOrWvhAS7Ngiqr1CH0jjFUJtkbUqtOzk8rqQ6P0=; b=5mM7Wm2nwF6iHCZRyenLfxM4qLR2ba/m/UkV3wdIBvcIy5qNse1A2vUOT553IAa1J8Jx 5TLCyODLq4VHzBpeSM5QSCP6ouZ5El9XlIGCBy3KuhmzxE68XOrRN7k/95F2i8lO2kVvP vo4nGP3Y+xiqrarAlnanQRjNHUpLakqQkABYyxUAN3mRpO2y86eYZwezb/Hx9wOjvqmR6 FJnI7yLlOAZ+HhU/OCHnV1Hx/59sfXQ0jBMjklgznDuN0yNp5YLhMwlz8nz/9QGcZjca9 YV70DVAIr/EUS1RhA3g677+mbTik8474I6ZkI5TZ5TfXzhTZe/EVEvVAhEb6gjb7asQ== 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=xh19Rajt; 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 3CC69606A32D; Fri, 4 Dec 2026 12:52:48 +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=xh19Rajt Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C9671F000CE; Fri, 4 Dec 2026 12:52:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388768; bh=9nyKoOrWvhAS7Ngiqr1CH0jjFUJtkbUqtOzk8rqQ6P0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=xh19RajtE9boLFsCq59Vk3dBpKCDlO/Ne6tvSPqQBtrcpfKj1LAppBKZACv1moLbf uD0WGJfxiUyQsMxWQLoDbYKU3uqaiq11zi7IuP9ZjlaDyuMpteRHjgDyTGJ+K2LWS3 92l0jqWlhAE6xg3zyLHVt5g1YDFQsO1zLXBA5o3c= 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 , Sasha Levin Subject: [PATCH 6.1 0745/1059] ovl: reject different lower idmaps on the same fs Date: Fri, 4 Dec 2026 19:04:36 +0900 Message-ID: <20261204100703.289644208@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev 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.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jérémy Jean [ Upstream commit 720f40c05b2785406121da0151543751204f2953 ] 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: Sasha Levin --- fs/overlayfs/ovl_entry.h | 2 ++ fs/overlayfs/super.c | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/fs/overlayfs/ovl_entry.h b/fs/overlayfs/ovl_entry.h index a479680a5ccd8..67a3b8f6c162e 100644 --- a/fs/overlayfs/ovl_entry.h +++ b/fs/overlayfs/ovl_entry.h @@ -25,6 +25,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 user_namespace *lower_idmap; /* Unusable (conflicting) uuid */ bool bad_uuid; /* Used as a lower layer (but maybe also as upper) */ diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index e8e7e1c59d95d..215ab87c4c2bf 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -1769,6 +1769,28 @@ static int ovl_get_layers(struct super_block *sb, struct ovl_fs *ofs, goto out; } + /* + * 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 (ofs->config.index || ofs->config.nfs_export) { + const struct user_namespace *idmap = mnt_user_ns(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", + stack[i].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. -- 2.53.0