vfs: add fileattr ops
authorMiklos Szeredi <mszeredi@redhat.com>
Wed, 7 Apr 2021 12:36:42 +0000 (14:36 +0200)
committerMiklos Szeredi <mszeredi@redhat.com>
Mon, 12 Apr 2021 13:04:23 +0000 (15:04 +0200)
commit4c5b479975212065ef39786e115fde42847e95a9
treefb285b479c8025061763e768c23a326edf6ec4ff
parente49d033bddf5b565044e2abe4241353959bc9120
vfs: add fileattr ops

There's a substantial amount of boilerplate in filesystems handling
FS_IOC_[GS]ETFLAGS/ FS_IOC_FS[GS]ETXATTR ioctls.

Also due to userspace buffers being involved in the ioctl API this is
difficult to stack, as shown by overlayfs issues related to these ioctls.

Introduce a new internal API named "fileattr" (fsxattr can be confused with
xattr, xflags is inappropriate, since this is more than just flags).

There's significant overlap between flags and xflags and this API handles
the conversions automatically, so filesystems may choose which one to use.

In ->fileattr_get() a hint is provided to the filesystem whether flags or
xattr are being requested by userspace, but in this series this hint is
ignored by all filesystems, since generating all the attributes is cheap.

If a filesystem doesn't implemement the fileattr API, just fall back to
f_op->ioctl().  When all filesystems are converted, the fallback can be
removed.

32bit compat ioctls are now handled by the generic code as well.

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Documentation/filesystems/locking.rst
Documentation/filesystems/vfs.rst
fs/ioctl.c
include/linux/fileattr.h [new file with mode: 0644]
include/linux/fs.h