* [PATCH] shmem: consume the reserved xattr space despite remount
@ 2026-11-18 18:23 Andrew Morton
2026-11-19 14:30 ` Christian Brauner
2026-11-19 18:23 ` sashiko-bot
0 siblings, 2 replies; 3+ messages in thread
From: Andrew Morton @ 2026-11-18 18:23 UTC (permalink / raw)
To: Christian Brauner
Cc: linux-mm, linux-fsdevel, Andrew Morton,
syzbot+4324f771847cecb27c54, Hugh Dickins, Baolin Wang,
Miklos Szeredi
From: Andrew Morton <akpm@linux-foundation.org>
Subject: shmem: consume the reserved xattr space despite remount
Date: Thu, 05 Nov 2026 08:08:06 -0800
Creating a tmpfs inode can trigger WARN_ON(ispace) in shmem_initxattrs()
when a concurrent remount sets nr_inodes=0. With panic_on_warn enabled,
this warning can panic the machine.
shmem_initxattrs() reserves space for the security xattrs while inode
limits are enabled. It later tests max_inodes again before consuming that
reservation for each installed xattr. If remount disables the limit
between those steps, successfully installed xattrs leave a nonzero
reservation behind.
Use the remaining reservation, rather than the current mount policy, to
decide whether to subtract the installed xattr's space. This also leaves
the failure path with only the unconsumed reservation to refund.
An initially unlimited filesystem cannot acquire an inode limit through
remount: shmem_reconfigure() rejects that transition.
Link: https://lore.kernel.org/20261105082717.c459bb33778fcf27e5675082@linux-foundation.org
Fixes: 076e5cef28e2 ("simple_xattr: change interface to pass struct simple_xattrs")
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reported-by: <syzbot+4324f771847cecb27c54@syzkaller.appspotmail.com>
Closes: https://syzkaller.appspot.com/bug?extid=4324f771847cecb27c54
Tested-by: syzbot+4324f771847cecb27c54@syzkaller.appspotmail.com
Cc: Hugh Dickins <hughd@google.com>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Miklos Szeredi <mszeredi@redhat.com>
Cc: Christian Brauner <brauner@kernel.org>
---
Reproduced the warning before the fix and verified its absence
afterward in a Debian 13 guest with SELinux enabled (permissive).
A temporary hook paused file creation after reserving security-xattr
space. Another process completed a real nr_inodes=0 remount before
creation resumed. The unpatched kernel left 94 bytes unconsumed and
triggered WARN_ON(ispace); the patched kernel consumed the reservation
completely. File contents and the security xattr were verified.
Ordinary creation on limited and unlimited tmpfs mounts also passed
on both kernels. No additional KASAN or lockdep reports occurred.
Tested Linux 7.4.0-rc1 with GCC 13.3, KASAN and lockdep, using KVM:
8 GiB RAM, four vCPUs and one virtual NUMA node, backed by a
Threadripper PRO 3995WX. Both kernels had the same diagnostic hook;
the ordering was forced rather than left to random stress.
mm/shmem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/mm/shmem.c~shmem-consume-the-reserved-xattr-space-despite-remount
+++ a/mm/shmem.c
@@ -4491,7 +4491,7 @@ static int shmem_initxattrs(struct inode
if (simple_xattr_add(&sbinfo->xa_cache, &info->xattrs, new_xattr))
break;
- if (sbinfo->max_inodes)
+ if (ispace)
ispace -= simple_xattr_space(new_xattr->name, new_xattr->size);
retain_and_null_ptr(new_xattr);
}
_
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] shmem: consume the reserved xattr space despite remount
2026-11-18 18:23 [PATCH] shmem: consume the reserved xattr space despite remount Andrew Morton
@ 2026-11-19 14:30 ` Christian Brauner
2026-11-19 18:23 ` sashiko-bot
1 sibling, 0 replies; 3+ messages in thread
From: Christian Brauner @ 2026-11-19 14:30 UTC (permalink / raw)
To: Andrew Morton
Cc: Christian Brauner, linux-mm, linux-fsdevel,
syzbot+4324f771847cecb27c54, Hugh Dickins, Baolin Wang,
Miklos Szeredi
On Wed, 18 Nov 2026 10:23:05 -0800, Andrew Morton wrote:
> Creating a tmpfs inode can trigger WARN_ON(ispace) in shmem_initxattrs()
> when a concurrent remount sets nr_inodes=0. With panic_on_warn enabled,
> this warning can panic the machine.
>
> shmem_initxattrs() reserves space for the security xattrs while inode
> limits are enabled. It later tests max_inodes again before consuming that
> reservation for each installed xattr. If remount disables the limit
> between those steps, successfully installed xattrs leave a nonzero
> reservation behind.
>
> [...]
Applied to the vfs.fixes branch of the vfs/vfs.git tree.
Patches in the vfs.fixes branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.fixes
[1/1] shmem: consume the reserved xattr space despite remount
https://git.kernel.org/vfs/vfs/c/274ae8ab278e
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] shmem: consume the reserved xattr space despite remount
2026-11-18 18:23 [PATCH] shmem: consume the reserved xattr space despite remount Andrew Morton
2026-11-19 14:30 ` Christian Brauner
@ 2026-11-19 18:23 ` sashiko-bot
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-11-19 18:23 UTC (permalink / raw)
To: Andrew Morton, Christian Brauner
Cc: linux-mm, syzbot+4324f771847cecb27c54, Hugh Dickins, Baolin Wang,
Miklos Szeredi
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] shmem: Fixes trailer subject omits trailing pointer asterisks
--
commit 2c1ee388f6f3d6454e93c257214769e6a996663f
Author: Andrew Morton <akpm@linux-foundation.org>
> shmem: consume the reserved xattr space despite remount
>
> Creating a tmpfs inode can trigger WARN_ON(ispace) in shmem_initxattrs()
> when a concurrent remount sets nr_inodes=0. With panic_on_warn enabled,
> this warning can panic the machine.
>
> shmem_initxattrs() reserves space for the security xattrs while inode
> limits are enabled. It later tests max_inodes again before consuming that
> reservation for each installed xattr. If remount disables the limit
> between those steps, successfully installed xattrs leave a nonzero
> reservation behind.
>
> Use the remaining reservation, rather than the current mount policy, to
> decide whether to subtract the installed xattr's space. This also leaves
> the failure path with only the unconsumed reservation to refund.
>
> An initially unlimited filesystem cannot acquire an inode limit through
> remount: shmem_reconfigure() rejects that transition.
>
> Link: https://lore.kernel.org/20261105082717.c459bb33778fcf27e5675082@linux-foundation.org
> Fixes: 076e5cef28e2 ("simple_xattr: change interface to pass struct simple_xattrs")
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> Reported-by: <syzbot+4324f771847cecb27c54@syzkaller.appspotmail.com>
> Closes: https://syzkaller.appspotcom/bug?extid=4324f771847cecb27c54
> Tested-by: syzbot+4324f771847cecb27c54@syzkaller.appspotmail.com
> Cc: Hugh Dickins <hughd@google.com>
> Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
> Cc: Miklos Szeredi <mszeredi@redhat.com>
> Cc: Christian Brauner <brauner@kernel.org>
[Severity: Low]
The subject in the Fixes: tag is missing the trailing " **" from commit
076e5cef28e2 ("simple_xattr: change interface to pass struct simple_xattrs **").
Should this be:
Fixes: 076e5cef28e2 ("simple_xattr: change interface to pass struct simple_xattrs **")
--
Sashiko AI review · https://sashiko.dev/#/patchset/00461f0c866d4a4eb9f50792f0e1f3d0.1@linux-foundation.org?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-19 18:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 18:23 [PATCH] shmem: consume the reserved xattr space despite remount Andrew Morton
2026-11-19 14:30 ` Christian Brauner
2026-11-19 18:23 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox