* FAILED: patch "[PATCH] ovl: do not copy up an xattr value that was never read" failed to apply to 5.10-stable tree
@ 2026-11-04 14:36 gregkh
2026-11-05 13:45 ` [PATCH 5.10.y] ovl: do not copy up an xattr value that was never read Sasha Levin
0 siblings, 1 reply; 2+ messages in thread
From: gregkh @ 2026-11-04 14:36 UTC (permalink / raw)
To: mason, amir73il, fahad, josef; +Cc: stable
The patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x 755b5c5c9277be251a51623d6065abab948c61bc
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026110420-outage-visor-9527@gregkh' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 755b5c5c9277be251a51623d6065abab948c61bc Mon Sep 17 00:00:00 2001
From: Chris Mason <mason@kernel.org>
Date: Wed, 7 Oct 2026 09:45:28 +0000
Subject: [PATCH] ovl: do not copy up an xattr value that was never read
Copy-up stores uninitialized kernel memory in an xattr of the upper
file, where the user can read it.
ovl_copy_xattr() may only pass bytes to ovl_do_setxattr() that
ovl_do_getxattr() has read. When the read fails with -ERANGE the
function asks for the size again, and if the new size fits the buffer
it stores the buffer although nothing was read into it. The buffer
comes from kvmalloc(), or it still holds the value of the previous
xattr.
A FUSE lower layer that answers every sized GETXATTR with -ERANGE made
copy-up store 4096 bytes that the server never sent, with a kernel
pointer in them, as an xattr of the upper file.
Fix this by failing the copy-up with -EIO when the size that follows
-ERANGE fits the buffer.
Reported-by: Fahad Alharbi <fahad@codepure.com>
Closes: https://lore.kernel.org/linux-fsdevel/CAOQ4uxjhfpNVvoVrTayj46H2CViTOc3oxzM6xdb8+E7ikE2CSA@mail.gmail.com/
Fixes: e4ad29fa0d22 ("ovl: use a minimal buffer in ovl_copy_xattr")
Cc: stable@vger.kernel.org
Signed-off-by: Chris Mason <mason@kernel.org>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
index e963701b4c87..c220cb5d0b70 100644
--- a/fs/overlayfs/copy_up.c
+++ b/fs/overlayfs/copy_up.c
@@ -131,8 +131,12 @@ int ovl_copy_xattr(struct super_block *sb, const struct path *oldpath, struct de
retry:
size = ovl_do_getxattr(oldpath, name, value, value_size);
- if (size == -ERANGE)
+ if (size == -ERANGE) {
size = ovl_do_getxattr(oldpath, name, NULL, 0);
+ /* Nothing was read into value, so it must not be used */
+ if (size >= 0 && size <= value_size)
+ size = -EIO;
+ }
if (size < 0) {
error = size;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 5.10.y] ovl: do not copy up an xattr value that was never read
2026-11-04 14:36 FAILED: patch "[PATCH] ovl: do not copy up an xattr value that was never read" failed to apply to 5.10-stable tree gregkh
@ 2026-11-05 13:45 ` Sasha Levin
0 siblings, 0 replies; 2+ messages in thread
From: Sasha Levin @ 2026-11-05 13:45 UTC (permalink / raw)
To: stable; +Cc: Chris Mason, Fahad Alharbi, Josef Bacik, Amir Goldstein,
Sasha Levin
From: Chris Mason <mason@kernel.org>
[ Upstream commit 755b5c5c9277be251a51623d6065abab948c61bc ]
Copy-up stores uninitialized kernel memory in an xattr of the upper
file, where the user can read it.
ovl_copy_xattr() may only pass bytes to ovl_do_setxattr() that
ovl_do_getxattr() has read. When the read fails with -ERANGE the
function asks for the size again, and if the new size fits the buffer
it stores the buffer although nothing was read into it. The buffer
comes from kvmalloc(), or it still holds the value of the previous
xattr.
A FUSE lower layer that answers every sized GETXATTR with -ERANGE made
copy-up store 4096 bytes that the server never sent, with a kernel
pointer in them, as an xattr of the upper file.
Fix this by failing the copy-up with -EIO when the size that follows
-ERANGE fits the buffer.
Reported-by: Fahad Alharbi <fahad@codepure.com>
Closes: https://lore.kernel.org/linux-fsdevel/CAOQ4uxjhfpNVvoVrTayj46H2CViTOc3oxzM6xdb8+E7ikE2CSA@mail.gmail.com/
Fixes: e4ad29fa0d22 ("ovl: use a minimal buffer in ovl_copy_xattr")
Cc: stable@vger.kernel.org
Signed-off-by: Chris Mason <mason@kernel.org>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
[ sashal: Adjusted context to retain vfs_getxattr(old, ...) calls instead of upstream ovl_do_getxattr(oldpath, ...). ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/overlayfs/copy_up.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
index 018867303a93a..cb89a96561da4 100644
--- a/fs/overlayfs/copy_up.c
+++ b/fs/overlayfs/copy_up.c
@@ -94,8 +94,12 @@ int ovl_copy_xattr(struct super_block *sb, struct dentry *old,
}
retry:
size = vfs_getxattr(old, name, value, value_size);
- if (size == -ERANGE)
+ if (size == -ERANGE) {
size = vfs_getxattr(old, name, NULL, 0);
+ /* Nothing was read into value, so it must not be used */
+ if (size >= 0 && size <= value_size)
+ size = -EIO;
+ }
if (size < 0) {
error = size;
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-05 13:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-04 14:36 FAILED: patch "[PATCH] ovl: do not copy up an xattr value that was never read" failed to apply to 5.10-stable tree gregkh
2026-11-05 13:45 ` [PATCH 5.10.y] ovl: do not copy up an xattr value that was never read Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox