]> git.ipfire.org Git - thirdparty/linux.git/commit
simple_xattr: change interface to pass struct simple_xattrs **
authorMiklos Szeredi <mszeredi@redhat.com>
Fri, 5 Jun 2026 13:53:18 +0000 (15:53 +0200)
committerChristian Brauner <brauner@kernel.org>
Sat, 6 Jun 2026 13:21:41 +0000 (15:21 +0200)
commit076e5cef28e27febfc09b5f72544d2b857c75201
tree29bcb8b6db7696bd2377f153a6e8f9034f1e68a8
parent832f4de4c8ba4f19e5df1d016a09917204b17834
simple_xattr: change interface to pass struct simple_xattrs **

Change the simple_xattr API to accept pointer-to-pointer (struct
simple_xattrs **) instead of pointer.  This allows the functions to handle
lazy allocation internally without requiring callers to use
simple_xattrs_lazy_alloc().

The simple_xattr_set(), simple_xattr_set_limited() and simple_xattr_add()
functions now handle allocation when xattrs is NULL.  simple_xattrs_free()
now also frees the xattrs structure itself and sets the pointer to NULL.

This simplifies callers and removes the need for most callers to explicitly
manage xattrs allocation and lifetime.

In shmem_initxattrs(), the total required space for all initial xattrs
(ispace) is pre-calculated and deducted from sbinfo->free_ispace.

Since this patch modifies the function to add new xattrs directly to the
inode's &info->xattrs list rather than using a local temporary variable, a
failure means that the partially populated info->xattrs list remains
attached to the inode.

When the VFS caller handles the -ENOMEM error, it drops the newly created
inode via iput(), shmem_free_inode() adds freed to sbinfo->free_ispace a
second time, permanently inflating the tmpfs free space quota.

Fix by substracting already added xattrs from ispace.

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Link: https://patch.msgid.link/20260605135322.2632068-4-mszeredi@redhat.com
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
fs/kernfs/dir.c
fs/kernfs/inode.c
fs/pidfs.c
fs/xattr.c
include/linux/xattr.h
mm/shmem.c
net/socket.c