vfs patch queue
Subsystems (20)
cover vfs patch queue
Hi Al,
Can you please apply the following patches?
All of these have been through the review process, some have been through several revisions, some haven't gotten any comments yet.
Git tree is here:
git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs.git for-viro
Thanks,
Miklos
Miklos Szeredi (12):
vfs: allow unprivileged whiteout creation
aio: fix async fsync creds
proc/mounts: add cursor
utimensat: AT_EMPTY_PATH support
f*xattr: allow O_PATH descriptors
uapi: deprecate STATX_ALL
statx: don't clear STATX_ATIME on SB_RDONLY
statx: add mount ID
statx: add mount_root
vfs: don't parse forbidden flags
vfs: don't parse "posixacl" option
vfs: don't parse "silent" option
fs/aio.c | 8 +++ fs/char_dev.c | 3 ++ fs/fs_context.c | 30 ----------- fs/mount.h | 12 +++-- fs/namei.c | 17 ++---- fs/namespace.c | 91 +++++++++++++++++++++++++++------ fs/proc_namespace.c | 4 +- fs/stat.c | 11 +++- fs/utimes.c | 6 ++- fs/xattr.c | 8 +-- include/linux/device_cgroup.h | 3 ++ include/linux/mount.h | 4 +- include/linux/stat.h | 1 + include/uapi/linux/stat.h | 18 ++++++- samples/vfs/test-statx.c | 2 +- tools/include/uapi/linux/stat.h | 11 +++- 16 files changed, 153 insertions(+), 76 deletions(-)
Signature · 1 line
2.21.1
PATCH 1/12 vfs: allow unprivileged whiteout creation
Whiteouts, unlike real device node should not require privileges to create.
The general concern with device nodes is that opening them can have side effects. The kernel already avoids zero major (see Documentation/admin-guide/devices.txt). To be on the safe side the patch explicitly forbids registering a char device with 0/0 number (see cdev_add()).
This guarantees that a non-O_PATH open on a whiteout will fail with ENODEV; i.e. it won't have any side effect.
--- fs/char_dev.c | 3 +++ fs/namei.c | 17 ++++------------- include/linux/device_cgroup.h | 3 +++ 3 files changed, 10 insertions(+), 13 deletions(-)
fs/char_dev.c +3 -0
@@ -483,6 +483,9 @@ int cdev_add(struct cdev *p, dev_t dev, unsigned count) p->dev = dev; p->count = count; +if (WARN_ON (dev ==WHITEOUT_DEV )) +return -EBUSY ; + error =kobj_map (cdev_map, dev, count,NULL , exact_match, exact_lock, p);if (error)
fs/namei.c +4 -13
@@ -3505,12 +3505,14 @@ EXPORT_SYMBOL(user_path_create);int vfs_mknod (struct inode *dir,struct dentry *dentry,umode_t mode,dev_t dev) { +bool is_whiteout =S_ISCHR (mode) && dev ==WHITEOUT_DEV ;int error =may_create (dir, dentry);if (error)return error; -if ((S_ISCHR (mode) ||S_ISBLK (mode)) && !capable (CAP_MKNOD )) +if ((S_ISCHR (mode) ||S_ISBLK (mode)) && !is_whiteout && + !capable (CAP_MKNOD ))return -EPERM ;if (!dir->i_op->mknod)
@@ -4345,9 +4347,6 @@ static int do_renameat2(int olddfd, const char __user *oldname, int newdfd, (flags & RENAME_EXCHANGE))return -EINVAL ; -if ((flags &RENAME_WHITEOUT ) && !capable (CAP_MKNOD )) -return -EPERM ; -if (flags &RENAME_EXCHANGE ) target_flags =0 ;
@@ -4485,15 +4484,7 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newnaint vfs_whiteout (struct inode *dir,struct dentry *dentry) { -int error =may_create (dir, dentry); -if (error) -return error; - -if (!dir->i_op->mknod) -return -EPERM ; - -return dir->i_op->mknod (dir, dentry, -S_IFCHR |WHITEOUT_MODE ,WHITEOUT_DEV ); +return vfs_mknod (dir, dentry,S_IFCHR |WHITEOUT_MODE ,WHITEOUT_DEV ); }EXPORT_SYMBOL (vfs_whiteout);
include/linux/device_cgroup.h +3 -0
@@ -51,6 +51,9 @@ static inline int devcgroup_inode_mknod(int mode, dev_t dev)if (!S_ISBLK (mode) && !S_ISCHR (mode))return 0 ; +if (S_ISCHR (mode) && dev ==WHITEOUT_DEV ) +return 0 ; +if (S_ISBLK (mode)) type =DEVCG_DEV_BLOCK ;else
Signature · 1 line
2.21.1
Al Viro
maintainerRe: [PATCH 01/12] vfs: allow unprivileged whiteout creation
Quoted 10 lines · Miklos Szeredi
Whiteouts, unlike real device node should not require privileges to create.
The general concern with device nodes is that opening them can have side effects. The kernel already avoids zero major (see
Documentation/admin-guide/devices.txt). To be on the safe side the patch explicitly forbids registering a char device with 0/0 number (seecdev_add()).This guarantees that a non-O_PATH open on a whiteout will fail with ENODEV; i.e. it won't have any side effect.
Humm... one question:
fs/namei.c SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna · line 4488
Quoted 13 lines
int
vfs_whiteout(struct inode *dir, struct dentry *dentry){fs/namei.c +1
-9-int error =may_create (dir, dentry); -if (error) -return error; - -if (!dir->i_op->mknod) -return -EPERM ; - -return dir->i_op->mknod (dir, dentry, -S_IFCHR |WHITEOUT_MODE ,WHITEOUT_DEV ); +return vfs_mknod (dir, dentry,S_IFCHR |WHITEOUT_MODE ,WHITEOUT_DEV ); }
why do we still need to export it? I mean, it looks like a static inline fodder.
PATCH 2/12 aio: fix async fsync creds
In reply to Miklos SzerediAvi Kivity reports that on fuse filesystems running in a user namespace asyncronous fsync fails with EOVERFLOW.
The reason is that f_ops->fsync() is called with the creds of the kthread performing aio work instead of the creds of the process originally submitting IOCB_CMD_FSYNC.
Fuse sends the creds of the caller in the request header and it needs to translate the uid and gid into the server's user namespace. Since the kthread is running in init_user_ns, the translation will fail and the operation returns an error.
It can be argued that fsync doesn't actually need any creds, but just zeroing out those fields in the header (as with requests that currently don't take creds) is a backward compatibility risk.
Instead of working around this issue in fuse, solve the core of the problem by calling the filesystem with the proper creds.
--- fs/aio.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/aio.c +8 -0
@@ -176,6 +176,7 @@ struct fsync_iocb {struct file *file;struct work_struct work;bool datasync; +struct cred *creds; };struct poll_iocb {
@@ -1589,8 +1590,11 @@ static int aio_write(struct kiocb *req, const struct iocb *iocb,static void aio_fsync_work (struct work_struct *work) { struct aio_kiocb *iocb = container_of(work, struct aio_kiocb, fsync.work); +const struct cred *old_cred =override_creds (iocb->fsync.creds); iocb->ki_res.res =vfs_fsync (iocb->fsync.file, iocb->fsync.datasync); +revert_creds (old_cred); +put_cred (iocb->fsync.creds);iocb_put (iocb); }
@@ -1604,6 +1608,10 @@ static int aio_fsync(struct fsync_iocb *req, const struct iocb *iocb,if (unlikely (!req->file->f_op->fsync))return -EINVAL ; + req->creds =prepare_creds (); +if (!req->creds) +return -ENOMEM ; + req->datasync = datasync;INIT_WORK (&req->work, aio_fsync_work);schedule_work (&req->work);
Signature · 1 line
2.21.1
Re: [PATCH 02/12] aio: fix async fsync creds
Looks good,
PATCH 3/12 proc/mounts: add cursor
In reply to Miklos SzerediIf mounts are deleted after a read(2) call on /proc/self/mounts (or its kin), the subsequent read(2) could miss a mount that comes after the deleted one in the list. This is because the file position is interpreted as the number mount entries from the start of the list.
E.g. first read gets entries #0 to #9; the seq file index will be 10. Then entry #5 is deleted, resulting in #10 becoming #9 and #11 becoming #10, etc... The next read will continue from entry #10, and #9 is missed.
Solve this by adding a cursor entry for each open instance. Taking the global namespace_sem for write seems excessive, since we are only dealing with a per-namespace list. Instead add a per-namespace spinlock and use that together with namespace_sem taken for read to protect against concurrent modification of the mount list. This may reduce parallelism of is_local_mountpoint(), but it's hardly a big contention point. We could also use RCU freeing of cursors to make traversal not need additional locks, if that turns out to be neceesary.
Only move the cursor once for each read (cursor is not added on open) to minimize cacheline invalidation. When EOF is reached, the cursor is taken off the list, in order to prevent an excessive number of cursors due to inactive open file descriptors.
--- fs/mount.h | 12 ++++-- fs/namespace.c | 91 +++++++++++++++++++++++++++++++++++-------- fs/proc_namespace.c | 4 +- include/linux/mount.h | 4 +- 4 files changed, 90 insertions(+), 21 deletions(-)
fs/mount.h +9 -3
@@ -9,7 +9,13 @@ struct mnt_namespace {atomic_t count;struct ns_common ns;struct mount * root; +/* +* Traversal and modification of .list is protected by either +* - taking namespace_sem for write, OR +* - taking namespace_sem for read AND taking .ns_lock. +*/ struct list_head list; +spinlock_t ns_lock;struct user_namespace *user_ns;struct ucounts *ucounts;u64 seq;/* Sequence number to prevent loops */
@@ -133,9 +139,7 @@ struct proc_mounts {struct mnt_namespace *ns;struct path root;int (*show)(struct seq_file *,struct vfsmount *); -void *cached_mount; -u64 cached_event; -loff_t cached_index; +struct mount cursor; };extern const struct seq_operations mounts_op;
@@ -153,3 +157,5 @@ static inline bool is_anon_ns(struct mnt_namespace *ns) {return ns->seq ==0 ; } + +extern void mnt_cursor_del (struct mnt_namespace *ns,struct mount *cursor);
fs/namespace.c +75 -16
166 lines not on this page · raw message
fs/proc_namespace.c +3 -1
@@ -279,7 +279,8 @@ static int mounts_open_common(struct inode *inode, struct file *file, p->ns = ns; p->root = root; p->show = show; - p->cached_event = ~0ULL ; +INIT_LIST_HEAD (&p->cursor.mnt_list); + p->cursor.mnt.mnt_flags =MNT_CURSOR ;return 0 ;
@@ -296,6 +297,7 @@ static int mounts_release(struct inode *inode, struct file *file)struct seq_file *m = file->private_data;struct proc_mounts *p = m->private;path_put (&p->root); +mnt_cursor_del (p->ns, &p->cursor);put_mnt_ns (p->ns);return seq_release_private (inode, file); }
include/linux/mount.h +3 -1
@@ -50,7 +50,8 @@ struct fs_context;#define MNT_ATIME_MASK (MNT_NOATIME | MNT_NODIRATIME | MNT_RELATIME )#define MNT_INTERNAL_FLAGS (MNT_SHARED | MNT_WRITE_HOLD | MNT_INTERNAL | \ - MNT_DOOMED | MNT_SYNC_UMOUNT | MNT_MARKED) + MNT_DOOMED | MNT_SYNC_UMOUNT | MNT_MARKED | \ + MNT_CURSOR)#define MNT_INTERNAL 0x4000
@@ -64,6 +65,7 @@ struct fs_context;#define MNT_SYNC_UMOUNT 0x2000000#define MNT_MARKED 0x4000000#define MNT_UMOUNT 0x8000000 +#define MNT_CURSOR 0x10000000struct vfsmount {struct dentry *mnt_root;/* root of the mounted tree */
Signature · 1 line
2.21.1
Al Viro
maintainerRe: [PATCH 03/12] proc/mounts: add cursor
fs/namespace.c struct vfsmount *mnt_clone_internal(const struct path *path) · line 1273
Quoted 1 line · Miklos Szeredi
fs/namespace.c +1
-0+for (p = p->next; p != &ns->list; p = p->next) {
Nit:
/**
* list_for_each_continue - continue iteration over a list
* @pos: the &struct list_head to use as a loop cursor.
* @head: the head for your list.
*
* Continue to iterate over a list, continuing after the current position. */
#define list_for_each_continue(pos, head) \
for (pos = pos->next; pos != (head); pos = pos->next)PATCH 4/12 utimensat: AT_EMPTY_PATH support
In reply to Miklos SzerediThis makes it possible to use utimensat on an O_PATH file (including symlinks).
It supersedes the nonstandard utimensat(fd, NULL, ...) form.
--- fs/utimes.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/utimes.c +4 -2
@@ -95,13 +95,13 @@ long do_utimes(int dfd, const char __user *filename, struct timespec64 *times, goto out; } -if (flags & ~AT_SYMLINK_NOFOLLOW ) +if (flags & ~(AT_SYMLINK_NOFOLLOW |AT_EMPTY_PATH )) goto out;if (filename ==NULL && dfd !=AT_FDCWD ) {struct fd f; -if (flags &AT_SYMLINK_NOFOLLOW ) +if (flags) goto out; f =fdget (dfd);
@@ -117,6 +117,8 @@ long do_utimes(int dfd, const char __user *filename, struct timespec64 *times,if (!(flags &AT_SYMLINK_NOFOLLOW )) lookup_flags |=LOOKUP_FOLLOW ; +if (flags &AT_EMPTY_PATH ) + lookup_flags |=LOOKUP_EMPTY ; retry: error =user_path_at (dfd, filename, lookup_flags, &path);if (error)
Signature · 1 line
2.21.1
Re: [PATCH 04/12] utimensat: AT_EMPTY_PATH support
Quoted 6 lines · Miklos Szeredi
This makes it possible to use utimensat on an
O_PATHfile (including symlinks).It supersedes the nonstandard
utimensat(fd, NULL, ...)form.Signed-off-by Miklos Szeredi <[email protected]>
I think this needs a Cc to linux-api and linux-man.
Otherwise this looks good to me:
PATCH 5/12 f*xattr: allow O_PATH descriptors
In reply to Miklos SzerediThis allows xattr ops on symlink/special files referenced by an O_PATH descriptor without having to play games with /proc/self/fd/NN (which doesn't work for symlinks anyway).
This capability is the same as would be given by introducing ...at() variants with an AT_EMPTY_PATH argument. Looking at getattr/setattr type syscalls, this is allowed for fstatat() and fchownat(), but not for fchmodat() and utimensat(). What's the logic?
While this carries a minute risk of someone relying on the property of xattr syscalls rejecting O_PATH descriptors, it saves the trouble of introducing another set of syscalls.
Only file->f_path and file->f_inode are accessed in these functions.
Current versions return EBADF, hence easy to detect the presense of this feature and fall back in case it's missing.
--- fs/xattr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/xattr.c +4 -4
@@ -495,7 +495,7 @@ SYSCALL_DEFINE5(lsetxattr, const char __user *, pathname, SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name, const void __user *,value, size_t, size, int, flags) { -struct fd f =fdget (fd); +struct fd f =fdget_raw (fd);int error = -EBADF ;if (!f.file)
@@ -587,7 +587,7 @@ SYSCALL_DEFINE4(lgetxattr, const char __user *, pathname, SYSCALL_DEFINE4(fgetxattr, int, fd, const char __user *, name, void __user *, value, size_t, size) { -struct fd f =fdget (fd); +struct fd f =fdget_raw (fd);ssize_t error = -EBADF ;if (!f.file)
@@ -662,7 +662,7 @@ SYSCALL_DEFINE3(llistxattr, const char __user *, pathname, char __user *, list, SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size) { -struct fd f =fdget (fd); +struct fd f =fdget_raw (fd);ssize_t error = -EBADF ;if (!f.file)
@@ -727,7 +727,7 @@ SYSCALL_DEFINE2(lremovexattr, const char __user *, pathname, SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name) { -struct fd f =fdget (fd); +struct fd f =fdget_raw (fd);int error = -EBADF ;if (!f.file)
Signature · 1 line
2.21.1
Re: [PATCH 05/12] f*xattr: allow O_PATH descriptors
Needs a Cc to linux-api and linux-man.
Quoted 3 lines · Miklos Szeredi
This allows xattr ops on symlink/special files referenced by an
O_PATHdescriptor without having to play games with/proc/self/fd/NN(which doesn't work for symlinks anyway).
Do we even intent to support xattrs on say links? They never wire up ->listxattr and would only get them through s_xattr. I'm defintively worried that this could break things without a very careful audit.
Re: [PATCH 05/12] f*xattr: allow O_PATH descriptors
Quoted 11 lines · Christoph Hellwig
Needs a Cc to linux-api and linux-man.
Quoted 3 lines · Miklos Szeredi
This allows xattr ops on symlink/special files referenced by an
O_PATHdescriptor without having to play games with/proc/self/fd/NN(which doesn't work for symlinks anyway).Do we even intent to support xattrs on say links? They never wire up ->listxattr and would only get them through
s_xattr. I'm defintively worried that this could break things without a very careful audit.
Why do you think listxattr is not wired up for symlinks?
Xfs and ext4 definitely do have it, and it seems most others too:
$ git grep -A10 "struct inode_operations.*symlink" | grep listxattr | wc -l 29
Thanks,
Miklos
Re: [PATCH 05/12] f*xattr: allow O_PATH descriptors
Quoted 14 lines · Miklos Szeredi
Quoted 11 lines · Christoph Hellwig
Needs a Cc to linux-api and linux-man.
Quoted 3 lines · Miklos Szeredi
This allows xattr ops on symlink/special files referenced by an
O_PATHdescriptor without having to play games with/proc/self/fd/NN(which doesn't work for symlinks anyway).Do we even intent to support xattrs on say links? They never wire up ->listxattr and would only get them through
s_xattr. I'm defintively worried that this could break things without a very careful audit.
Quoted 6 lines
Why do you think listxattr is not wired up for symlinks?
Xfs and ext4 definitely do have it, and it seems most others too:
$ git grep -A10 "struct inode_operations.*symlink" | grep listxattr | wc -l 29
In any case, I'm dropping this patch for now. The comment about/proc/self/fd/NN not working is actually wrong; it does work despite the target being a symlink: LOOKUP_FOLLOW only follows the magic symlink in this case, not the symlink that is the target. So it's possible to get (set, remove, list) the xattr on an O_PATH descriptor using
sprintf("/proc/self/fd/%i", procpath, sizeof(procpath)); getxattr(procpath, ...);
Thanks,
Miklos
PATCH 6/12 uapi: deprecate STATX_ALL
In reply to Miklos SzerediConstants of the *_ALL type can be actively harmful due to the fact that developers will usually fail to consider the possible effects of future changes to the definition.
Deprecate STATX_ALL in the uapi, while no damage has been done yet.
We could keep something like this around in the kernel, but there's actually no point, since all filesystems should be explicitly checking flags that they support and not rely on the VFS masking unknown ones out: a flag could be known to the VFS, yet not known to the filesystem.
--- fs/stat.c | 1 - include/uapi/linux/stat.h | 11 ++++++++++- samples/vfs/test-statx.c | 2 +- tools/include/uapi/linux/stat.h | 11 ++++++++++- 4 files changed, 21 insertions(+), 4 deletions(-)
fs/stat.c +0 -1
@@ -70,7 +70,6 @@ int vfs_getattr_nosec(const struct path *path, struct kstat *stat,memset (stat,0 ,sizeof (*stat)); stat->result_mask |=STATX_BASIC_STATS ; - request_mask &=STATX_ALL ; query_flags &=KSTAT_QUERY_FLAGS ;/* allow the fs to override these if it really wants to */
include/uapi/linux/stat.h +10 -1
@@ -148,9 +148,18 @@ struct statx {#define STATX_BLOCKS 0x00000400U/* Want/got stx_blocks */ #define STATX_BASIC_STATS 0x000007ffU/* The stuff in the normal stat struct */ #define STATX_BTIME 0x00000800U/* Want/got stx_btime */ -#define STATX_ALL 0x00000fffU/* All currently supported flags */ +#define STATX__RESERVED 0x80000000U/* Reserved for future struct statx expansion */ +#ifndef __KERNEL__ +/* +* This is deprecated, and shall remain the same value in the future. To avoid +* confusion please use the equivalent (STATX_BASIC_STATS | STATX_BTIME) +* instead. +*/ +#define STATX_ALL 0x00000fffU +#endif +/* * Attributes to be found in stx_attributes and masked in stx_attributes_mask. *
samples/vfs/test-statx.c +1 -1
@@ -216,7 +216,7 @@ int main(int argc, char **argv)struct statx stx;int ret, raw =0 , atflag =AT_SYMLINK_NOFOLLOW ; -unsigned int mask =STATX_ALL ; +unsigned int mask =STATX_BASIC_STATS |STATX_BTIME ;for (argv++; *argv; argv++) {if (strcmp (*argv,"-F" ) ==0 ) {
tools/include/uapi/linux/stat.h +10 -1
@@ -148,9 +148,18 @@ struct statx {#define STATX_BLOCKS 0x00000400U/* Want/got stx_blocks */ #define STATX_BASIC_STATS 0x000007ffU/* The stuff in the normal stat struct */ #define STATX_BTIME 0x00000800U/* Want/got stx_btime */ -#define STATX_ALL 0x00000fffU/* All currently supported flags */ +#define STATX__RESERVED 0x80000000U/* Reserved for future struct statx expansion */ +#ifndef __KERNEL__ +/* +* This is deprecated, and shall remain the same value in the future. To avoid +* confusion please use the equivalent (STATX_BASIC_STATS | STATX_BTIME) +* instead. +*/ +#define STATX_ALL 0x00000fffU +#endif +/* * Attributes to be found in stx_attributes and masked in stx_attributes_mask. *
Signature · 1 line
2.21.1
Re: [PATCH 06/12] uapi: deprecate STATX_ALL
Looks good,
PATCH 7/12 statx: don't clear STATX_ATIME on SB_RDONLY
In reply to Miklos SzerediIS_NOATIME(inode) is defined as __IS_FLG(inode, SB_RDONLY|SB_NOATIME), so generic_fillattr() will clear STATX_ATIME from the result_mask if the super block is marked read only.
This was probably not the intention, so fix to only clear STATX_ATIME if the fs doesn't support atime at all.
--- fs/stat.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/stat.c +2 -1
@@ -73,7 +73,8 @@ int vfs_getattr_nosec(const struct path *path, struct kstat *stat, query_flags &=KSTAT_QUERY_FLAGS ;/* allow the fs to override these if it really wants to */ -if (IS_NOATIME (inode)) +/* SB_NOATIME means filesystem supplies dummy atime value */ +if (inode->i_sb->s_flags &SB_NOATIME ) stat->result_mask &= ~STATX_ATIME ;if (IS_AUTOMOUNT (inode)) stat->attributes |=STATX_ATTR_AUTOMOUNT ;
Signature · 1 line
2.21.1
Re: [PATCH 07/12] statx: don't clear STATX_ATIME on SB_RDONLY
Quoted 9 lines · Miklos Szeredi
IS_NOATIME(inode)is defined as__IS_FLG(inode, SB_RDONLY|SB_NOATIME), sogeneric_fillattr()will clearSTATX_ATIMEfrom theresult_maskif the super block is marked read only.This was probably not the intention, so fix to only clear
STATX_ATIMEif the fs doesn't support atime at all.Signed-off-by Miklos Szeredi <[email protected]>Acked-by David Howells <[email protected]>
Looks good,
PATCH 8/12 statx: add mount ID
In reply to Miklos SzerediSystemd is hacking around to get it and it's trivial to add to statx, so...
--- fs/stat.c | 4 ++++ include/linux/stat.h | 1 + include/uapi/linux/stat.h | 6 +++++- 3 files changed, 10 insertions(+), 1 deletion(-)
fs/stat.c +4 -0
@@ -22,6 +22,7 @@#include <asm/unistd.h> #include "internal.h" +#include "mount.h" /** * generic_fillattr - Fill in the basic attributes from the inode struct
@@ -199,6 +200,8 @@ int vfs_statx(int dfd, const char __user *filename, int flags, goto out; error =vfs_getattr (&path, stat, request_mask, flags); + stat->mnt_id =real_mount (path.mnt)->mnt_id; + stat->result_mask |=STATX_MNT_ID ;path_put (&path);if (retry_estale (error, lookup_flags)) { lookup_flags |=LOOKUP_REVAL ;
@@ -563,6 +566,7 @@ cp_statx(const struct kstat *stat, struct statx __user *buffer) tmp.stx_rdev_minor =MINOR (stat->rdev); tmp.stx_dev_major =MAJOR (stat->dev); tmp.stx_dev_minor =MINOR (stat->dev); + tmp.stx_mnt_id = stat->mnt_id;return copy_to_user (buffer, &tmp,sizeof (tmp)) ? -EFAULT :0 ; }
include/linux/stat.h +1 -0
@@ -47,6 +47,7 @@ struct kstat {struct timespec64 ctime;struct timespec64 btime;/* File creation time */ u64 blocks; + u64 mnt_id; };#endif
include/uapi/linux/stat.h +5 -1
@@ -123,7 +123,10 @@ struct statx {__u32 stx_dev_major;/* ID of device containing file [uncond] */ __u32 stx_dev_minor;/* 0x90 */ -__u64 __spare2[14 ];/* Spare space for future expansion */ +__u64 stx_mnt_id; +__u64 __spare2; +/* 0xa0 */ +__u64 __spare3[12 ];/* Spare space for future expansion */ /* 0x100 */ };
@@ -148,6 +151,7 @@ struct statx {#define STATX_BLOCKS 0x00000400U/* Want/got stx_blocks */ #define STATX_BASIC_STATS 0x000007ffU/* The stuff in the normal stat struct */ #define STATX_BTIME 0x00000800U/* Want/got stx_btime */ +#define STATX_MNT_ID 0x00001000U/* Got stx_mnt_id */ #define STATX__RESERVED 0x80000000U/* Reserved for future struct statx expansion */
Signature · 1 line
2.21.1
Re: [PATCH 08/12] statx: add mount ID
Looks good,
PATCH 9/12 statx: add mount_root
In reply to Miklos SzerediDetermining whether a path or file descriptor refers to a mountpoint (or more precisely a mount root) is not trivial using current tools.
Add a flag to statx that indicates whether the path or fd refers to the root of a mount or not.
--- fs/stat.c | 3 +++ include/uapi/linux/stat.h | 1 + 2 files changed, 4 insertions(+)
fs/stat.c +3 -0
@@ -202,6 +202,9 @@ int vfs_statx(int dfd, const char __user *filename, int flags, error =vfs_getattr (&path, stat, request_mask, flags); stat->mnt_id =real_mount (path.mnt)->mnt_id; stat->result_mask |=STATX_MNT_ID ; +if (path.mnt->mnt_root == path.dentry) + stat->attributes |=STATX_ATTR_MOUNT_ROOT ; + stat->attributes_mask |=STATX_ATTR_MOUNT_ROOT ;path_put (&path);if (retry_estale (error, lookup_flags)) { lookup_flags |=LOOKUP_REVAL ;
include/uapi/linux/stat.h +1 -0
@@ -181,6 +181,7 @@ struct statx {#define STATX_ATTR_NODUMP 0x00000040/* [I] File is not to be dumped */ #define STATX_ATTR_ENCRYPTED 0x00000800/* [I] File requires key to decrypt in fs */ #define STATX_ATTR_AUTOMOUNT 0x00001000/* Dir: Automount trigger */ +#define STATX_ATTR_MOUNT_ROOT 0x00002000/* Root of a mount */ #define STATX_ATTR_VERITY 0x00100000/* [I] Verity protected file */
Signature · 1 line
2.21.1
Re: [PATCH 09/12] statx: add mount_root
Quoted 5 lines · Miklos Szeredi
Determining whether a path or file descriptor refers to a mountpoint (or more precisely a mount root) is not trivial using current tools.
Add a flag to statx that indicates whether the path or fd refers to the root of a mount or not.
A brief summary of the previous discussion might be useful here. (Comparing st_dev is unreliable for bind mounts; openat2() with RESOLVE_NO_XDEV works for some use cases but triggers other code (like security checks and autofs) that are undesirable in other cases:
https://lore.kernel.org/lkml/[email protected]/T/#ma4516eed1c7507b83343321e3ebd13bba972301c
)
Looks good to me, though.--b.
Quoted 37 lines
Reported-by Lennart Poettering <[email protected]>Reported-by J. Bruce Fields <[email protected]>Signed-off-by Miklos Szeredi <[email protected]>--- fs/stat.c | 3 +++ include/uapi/linux/stat.h | 1 + 2 files changed, 4 insertions(+)fs/stat.c +3
-0@@ -202,6 +202,9 @@ int vfs_statx(int dfd, const char __user *filename, int flags, error =vfs_getattr (&path, stat, request_mask, flags); stat->mnt_id =real_mount (path.mnt)->mnt_id; stat->result_mask |=STATX_MNT_ID ; +if (path.mnt->mnt_root == path.dentry) + stat->attributes |=STATX_ATTR_MOUNT_ROOT ; + stat->attributes_mask |=STATX_ATTR_MOUNT_ROOT ;path_put (&path);if (retry_estale (error, lookup_flags)) { lookup_flags |=LOOKUP_REVAL ;include/uapi/linux/stat.h +1
-0@@ -181,6 +181,7 @@ struct statx {#define STATX_ATTR_NODUMP 0x00000040/* [I] File is not to be dumped */ #define STATX_ATTR_ENCRYPTED 0x00000800/* [I] File requires key to decrypt in fs */ #define STATX_ATTR_AUTOMOUNT 0x00001000/* Dir: Automount trigger */ +#define STATX_ATTR_MOUNT_ROOT 0x00002000/* Root of a mount */ #define STATX_ATTR_VERITY 0x00100000/* [I] Verity protected file */ Signature · 1 line
2.21.1
Re: [PATCH 09/12] statx: add mount_root
In reply to Miklos SzerediLooks good,
PATCH 10/12 vfs: don't parse forbidden flags
In reply to Miklos SzerediMakes little sense to keep this blacklist synced with what mount(8) parses and what it doesn't. E.g. it has various forms of "*atime" options, but not "atime"...
--- fs/fs_context.c | 28 ---------------------------- 1 file changed, 28 deletions(-)
fs/fs_context.c +0 -28
@@ -57,40 +57,12 @@ static const struct constant_table common_clear_sb_flag[] = { { }, }; -static const char *const forbidden_sb_flag[] = { -"bind" , -"dev" , -"exec" , -"move" , -"noatime" , -"nodev" , -"nodiratime" , -"noexec" , -"norelatime" , -"nostrictatime" , -"nosuid" , -"private" , -"rec" , -"relatime" , -"remount" , -"shared" , -"slave" , -"strictatime" , -"suid" , -"unbindable" , -}; -/* * Check for a common mount option that manipulates s_flags. */ static int vfs_parse_sb_flag (struct fs_context *fc,const char *key) {unsigned int token; -unsigned int i; - -for (i =0 ; i <ARRAY_SIZE (forbidden_sb_flag); i++) -if (strcmp (key, forbidden_sb_flag[i]) ==0 ) -return -EINVAL ; token =lookup_constant (common_set_sb_flag, key,0 );if (token) {
Signature · 1 line
2.21.1
Re: [PATCH 10/12] vfs: don't parse forbidden flags
Quoted 3 lines · Miklos Szeredi
Makes little sense to keep this blacklist synced with what mount(8) parses and what it doesn't. E.g. it has various forms of "*atime" options, but not "atime"...
Yes, this list looks pretty strange.
PATCH 11/12 vfs: don't parse "posixacl" option
In reply to Miklos SzerediUnlike the others, this is _not_ a standard option accepted by mount(8).
In fact SB_POSIXACL is an internal flag, and accepting MS_POSIXACL on the mount(2) interface is possibly a bug.
The only filesystem that apparently wants to handle the "posixacl" option is 9p, but it has special handling of that option besides setting SB_POSIXACL.
--- fs/fs_context.c | 1 - 1 file changed, 1 deletion(-)
fs/fs_context.c +0 -1
@@ -42,7 +42,6 @@ static const struct constant_table common_set_sb_flag[] = { { "dirsync", SB_DIRSYNC }, { "lazytime", SB_LAZYTIME }, { "mand", SB_MANDLOCK }, - { "posixacl", SB_POSIXACL }, { "ro", SB_RDONLY }, { "sync", SB_SYNCHRONOUS }, { },
Signature · 1 line
2.21.1
Re: [PATCH 11/12] vfs: don't parse "posixacl" option
Quoted 8 lines · Miklos Szeredi
Unlike the others, this is _not_ a standard option accepted by mount(8).
In fact
SB_POSIXACLis an internal flag, and acceptingMS_POSIXACLon the mount(2) interface is possibly a bug.The only filesystem that apparently wants to handle the "posixacl" option is 9p, but it has special handling of that option besides setting
SB_POSIXACL.
Looks good:
PATCH 12/12 vfs: don't parse "silent" option
In reply to Miklos SzerediParsing "silent" and clearing SB_SILENT makes zero sense.
Parsing "silent" and setting SB_SILENT would make a bit more sense, but apparently nobody cares.
--- fs/fs_context.c | 1 - 1 file changed, 1 deletion(-)
fs/fs_context.c +0 -1
@@ -52,7 +52,6 @@ static const struct constant_table common_clear_sb_flag[] = { { "nolazytime", SB_LAZYTIME }, { "nomand", SB_MANDLOCK }, { "rw", SB_RDONLY }, - { "silent", SB_SILENT }, { }, };
Signature · 1 line
2.21.1
Re: [PATCH 12/12] vfs: don't parse "silent" option
Quoted 6 lines · Miklos Szeredi
Parsing "silent" and clearing
SB_SILENTmakes zero sense.Parsing "silent" and setting
SB_SILENTwould make a bit more sense, but apparently nobody cares.Signed-off-by Miklos Szeredi <[email protected]>
Looksgood,
[13/12 PATCH] vfs: add faccessat2 syscall
In reply to Miklos SzerediPOSIX defines faccessat() as having a fourth "flags" argument, while the linux syscall doesn't have it. Glibc tries to emulate AT_EACCESS and AT_SYMLINK_NOFOLLOW, but AT_EACCESS emulation is broken.
Add a new faccessat(2) syscall with the added flags argument and implement both flags.
The value of AT_EACCESS is defined in glibc headers to be the same as AT_REMOVEDIR. Use this value for the kernel interface as well, together with the explanatory comment.
Also add AT_EMPTY_PATH support, which is not documented by POSIX, but can be useful and is trivial to implement.
--- arch/alpha/kernel/syscalls/syscall.tbl | 1 + arch/arm/tools/syscall.tbl | 1 + arch/arm64/include/asm/unistd.h | 2 +- arch/arm64/include/asm/unistd32.h | 2 + arch/ia64/kernel/syscalls/syscall.tbl | 1 + arch/m68k/kernel/syscalls/syscall.tbl | 1 + arch/microblaze/kernel/syscalls/syscall.tbl | 1 + arch/mips/kernel/syscalls/syscall_n32.tbl | 1 + arch/mips/kernel/syscalls/syscall_n64.tbl | 1 + arch/mips/kernel/syscalls/syscall_o32.tbl | 1 + arch/parisc/kernel/syscalls/syscall.tbl | 1 + arch/powerpc/kernel/syscalls/syscall.tbl | 1 + arch/s390/kernel/syscalls/syscall.tbl | 1 + arch/sh/kernel/syscalls/syscall.tbl | 1 + arch/sparc/kernel/syscalls/syscall.tbl | 1 + arch/x86/entry/syscalls/syscall_32.tbl | 1 + arch/x86/entry/syscalls/syscall_64.tbl | 1 + arch/xtensa/kernel/syscalls/syscall.tbl | 1 + fs/internal.h | 1 - fs/open.c | 58 ++++++++++++++++----- include/linux/syscalls.h | 7 ++- include/uapi/asm-generic/unistd.h | 4 +- include/uapi/linux/fcntl.h | 10 ++++ 23 files changed, 82 insertions(+), 18 deletions(-)
arch/alpha/kernel/syscalls/syscall.tbl +1 -0
@@ -477,3 +477,4 @@ # 545 reserved for clone3 547 common openat2 sys_openat2 548 common pidfd_getfd sys_pidfd_getfd +549 common faccessat2 sys_faccessat2
arch/arm/tools/syscall.tbl +1 -0
@@ -451,3 +451,4 @@ 435 common clone3 sys_clone3 437 common openat2 sys_openat2 438 common pidfd_getfd sys_pidfd_getfd +439 common faccessat2 sys_faccessat2
arch/arm64/include/asm/unistd.h +1 -1
@@ -38,7 +38,7 @@#define __ARM_NR_compat_set_tls (__ARM_NR_COMPAT_BASE + 5)#define __ARM_NR_COMPAT_END (__ARM_NR_COMPAT_BASE + 0x800) -#define __NR_compat_syscalls 439 +#define __NR_compat_syscalls 440#endif #define __ARCH_WANT_SYS_CLONE
arch/arm64/include/asm/unistd32.h +2 -0
@@ -883,6 +883,8 @@ __SYSCALL(__NR_clone3, sys_clone3) __SYSCALL(__NR_openat2, sys_openat2)#define __NR_pidfd_getfd 438 __SYSCALL(__NR_pidfd_getfd, sys_pidfd_getfd) +#define __NR_faccessat2 439 +__SYSCALL (__NR_faccessat2, sys_faccessat2)/* * Please add new compat syscalls above this comment and update
arch/ia64/kernel/syscalls/syscall.tbl +1 -0
@@ -358,3 +358,4 @@ # 435 reserved for clone3 437 common openat2 sys_openat2 438 common pidfd_getfd sys_pidfd_getfd +439 common faccessat2 sys_faccessat2
arch/m68k/kernel/syscalls/syscall.tbl +1 -0
@@ -437,3 +437,4 @@ 435 common clone3 __sys_clone3 437 common openat2 sys_openat2 438 common pidfd_getfd sys_pidfd_getfd +439 common faccessat2 sys_faccessat2
arch/microblaze/kernel/syscalls/syscall.tbl +1 -0
@@ -443,3 +443,4 @@ 435 common clone3 sys_clone3 437 common openat2 sys_openat2 438 common pidfd_getfd sys_pidfd_getfd +439 common faccessat2 sys_faccessat2
arch/mips/kernel/syscalls/syscall_n32.tbl +1 -0
@@ -376,3 +376,4 @@ 435 n32 clone3 __sys_clone3 437 n32 openat2 sys_openat2 438 n32 pidfd_getfd sys_pidfd_getfd +439 n32 faccessat2 sys_faccessat2
arch/mips/kernel/syscalls/syscall_n64.tbl +1 -0
@@ -352,3 +352,4 @@ 435 n64 clone3 __sys_clone3 437 n64 openat2 sys_openat2 438 n64 pidfd_getfd sys_pidfd_getfd +439 n64 faccessat2 sys_faccessat2
arch/mips/kernel/syscalls/syscall_o32.tbl +1 -0
@@ -425,3 +425,4 @@ 435 o32 clone3 __sys_clone3 437 o32 openat2 sys_openat2 438 o32 pidfd_getfd sys_pidfd_getfd +439 o32 faccessat2 sys_faccessat2
arch/parisc/kernel/syscalls/syscall.tbl +1 -0
@@ -435,3 +435,4 @@ 435 common clone3 sys_clone3_wrapper 437 common openat2 sys_openat2 438 common pidfd_getfd sys_pidfd_getfd +439 common faccessat2 sys_faccessat2
arch/powerpc/kernel/syscalls/syscall.tbl +1 -0
@@ -527,3 +527,4 @@ 435 spu clone3 sys_ni_syscall 437 common openat2 sys_openat2 438 common pidfd_getfd sys_pidfd_getfd +439 common faccessat2 sys_faccessat2
arch/s390/kernel/syscalls/syscall.tbl +1 -0
@@ -440,3 +440,4 @@ 435 common clone3 sys_clone3 sys_clone3 437 common openat2 sys_openat2 sys_openat2 438 common pidfd_getfd sys_pidfd_getfd sys_pidfd_getfd +439 common faccessat2 sys_faccessat2 sys_faccessat2
arch/sh/kernel/syscalls/syscall.tbl +1 -0
@@ -440,3 +440,4 @@ # 435 reserved for clone3 437 common openat2 sys_openat2 438 common pidfd_getfd sys_pidfd_getfd +439 common faccessat2 sys_faccessat2
arch/sparc/kernel/syscalls/syscall.tbl +1 -0
@@ -483,3 +483,4 @@ # 435 reserved for clone3 437 common openat2 sys_openat2 438 common pidfd_getfd sys_pidfd_getfd +439 common faccessat2 sys_faccessat2
arch/x86/entry/syscalls/syscall_32.tbl +1 -0
@@ -442,3 +442,4 @@ 435 i386 clone3 sys_clone3 437 i386 openat2 sys_openat2 438 i386 pidfd_getfd sys_pidfd_getfd +439 i386 faccessat2 sys_faccessat2
arch/x86/entry/syscalls/syscall_64.tbl +1 -0
@@ -359,6 +359,7 @@ 435 common clone3 sys_clone3 437 common openat2 sys_openat2 438 common pidfd_getfd sys_pidfd_getfd +439 common faccessat2 sys_faccessat2 # # x32-specific system call numbers start at 512 to avoid cache impact
arch/xtensa/kernel/syscalls/syscall.tbl +1 -0
@@ -408,3 +408,4 @@ 435 common clone3 sys_clone3 437 common openat2 sys_openat2 438 common pidfd_getfd sys_pidfd_getfd +439 common faccessat2 sys_faccessat2
fs/internal.h +0 -1
@@ -126,7 +126,6 @@ extern struct open_how build_open_how(int flags, umode_t mode);extern int build_open_flags (const struct open_how *how,struct open_flags *op);long do_sys_ftruncate (unsigned int fd,loff_t length,int small); -long do_faccessat (int dfd,const char __user *filename,int mode);int do_fchmodat (int dfd,const char __user *filename,umode_t mode);int do_fchownat (int dfd,const char __user *filename,uid_t user,gid_t group,int flag);
fs/open.c +45 -13
91 lines not on this page · raw message
include/linux/syscalls.h +5 -2
@@ -428,6 +428,8 @@ asmlinkage long sys_ftruncate64(unsigned int fd, loff_t length);#endif asmlinkage long sys_fallocate (int fd,int mode,loff_t offset,loff_t len);asmlinkage long sys_faccessat (int dfd,const char __user *filename,int mode); +asmlinkage long sys_faccessat2 (int dfd,const char __user *filename,int mode, +int flags);asmlinkage long sys_chdir (const char __user *filename);asmlinkage long sys_fchdir (unsigned int fd);asmlinkage long sys_chroot (const char __user *filename);
@@ -1333,11 +1335,12 @@ static inline int ksys_chmod(const char __user *filename, umode_t mode)return do_fchmodat (AT_FDCWD , filename, mode); } -extern long do_faccessat (int dfd,const char __user *filename,int mode); +extern long do_faccessat (int dfd,const char __user *filename,int mode, +int flags);static inline long ksys_access (const char __user *filename,int mode) { -return do_faccessat (AT_FDCWD , filename, mode); +return do_faccessat (AT_FDCWD , filename, mode,0 ); } extern int do_fchownat(int dfd, const char __user *filename, uid_t user,
include/uapi/asm-generic/unistd.h +3 -1
@@ -855,9 +855,11 @@ __SYSCALL(__NR_clone3, sys_clone3) __SYSCALL(__NR_openat2, sys_openat2)#define __NR_pidfd_getfd 438 __SYSCALL(__NR_pidfd_getfd, sys_pidfd_getfd) +#define __NR_faccessat2 439 +__SYSCALL(__NR_faccessat2, sys_faccessat2)#undef __NR_syscalls -#define __NR_syscalls 439 +#define __NR_syscalls 440/* * 32 bit systems traditionally used different
include/uapi/linux/fcntl.h +10 -0
@@ -84,10 +84,20 @@#define DN_ATTRIB 0x00000020/* File changed attibutes */ #define DN_MULTISHOT 0x80000000/* Don't remove notifier */ +/* +* The constants AT_REMOVEDIR and AT_EACCESS have the same value. AT_EACCESS is +* meaningful only to faccessat, while AT_REMOVEDIR is meaningful only to +* unlinkat. The two functions do completely different things and therefore, +* the flags can be allowed to overlap. For example, passing AT_REMOVEDIR to +* faccessat would be undefined behavior and thus treating it equivalent to +* AT_EACCESS is valid undefined behavior. +*/ #define AT_FDCWD -100/* Special value used to indicate openat should use the current working directory. */ #define AT_SYMLINK_NOFOLLOW 0x100/* Do not follow symbolic links. */ +#define AT_EACCESS 0x200/* Test access permitted for +effective IDs, not real IDs. */ #define AT_REMOVEDIR 0x200/* Remove directory instead of unlinking file. */ #define AT_SYMLINK_FOLLOW 0x400/* Follow symbolic links. */
Signature · 1 line
2.21.1
Re: [13/12 PATCH] vfs: add faccessat2 syscall
Needs a Cc to linux-api and linux-man.
Can you split the access_override_creds refactor into a separate prep patch? Also please drop the pointless externs for functions prototypes in headers while you're at it.
Otherwise this looks sane to me.
Quoted 4 lines · Miklos Szeredi
Hi Al,
Can you please apply the following patches?
Ping? Could you please have a look at these patches?
- /proc/mounts cursor is almost half the total lines changed, and that one was already pretty damn well reviewed by you
- unprivileged whiteout one was approved by the security guys
- aio fsync one is a real bug, please comment on whether the patch is acceptable or should I work around it in fuse
- STATX_MNT_ID extension is a no brainer, the other one may or may not be useful, that's arguable...
- the others are not important, but I think useful
- and I missed one (faccess2); amending to patch series
Thanks,
Miklos
Quoted 46 lines
All of these have been through the review process, some have been through several revisions, some haven't gotten any comments yet.
Git tree is here:
git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs.gitfor-viroThanks,
MiklosMiklos Szeredi (12):
vfs: allow unprivileged whiteout creation
aio: fix async fsync creds
proc/mounts: add cursor
utimensat:AT_EMPTY_PATHsupport
f*xattr: allowO_PATHdescriptors
uapi: deprecateSTATX_ALL
statx: don't clearSTATX_ATIMEonSB_RDONLY
statx: add mount ID
statx: addmount_root
vfs: don't parse forbidden flags
vfs: don't parse "posixacl" option
vfs: don't parse "silent" optionfs/aio.c | 8 +++ fs/char_dev.c | 3 ++ fs/fs_context.c | 30 ----------- fs/mount.h | 12 +++-- fs/namei.c | 17 ++---- fs/namespace.c | 91 +++++++++++++++++++++++++++------ fs/proc_namespace.c | 4 +- fs/stat.c | 11 +++- fs/utimes.c | 6 ++- fs/xattr.c | 8 +-- include/linux/device_cgroup.h | 3 ++ include/linux/mount.h | 4 +- include/linux/stat.h | 1 + include/uapi/linux/stat.h | 18 ++++++- samples/vfs/test-statx.c | 2 +- tools/include/uapi/linux/stat.h | 11 +++- 16 files changed, 153 insertions(+), 76 deletions(-)--
2.21.1
Al Viro
maintainerQuoted 16 lines · Miklos Szeredi
Quoted 4 lines · Miklos Szeredi
Hi Al,
Can you please apply the following patches?
Ping? Could you please have a look at these patches?
-
/proc/mountscursor is almost half the total lines changed, and that one was already pretty damn well reviewed by you- unprivileged whiteout one was approved by the security guys
- aio fsync one is a real bug, please comment on whether the patch is acceptable or should I work around it in fuse
Quoted 6 lines
-
STATX_MNT_IDextension is a no brainer, the other one may or may not be useful, that's arguable...- the others are not important, but I think useful
- and I missed one (faccess2); amending to patch series
I can live with that, modulo couple of trivial nits. Have you tested the /proc/mounts part for what happens if it's opened shitloads of times, with each instance lseek'ed a bit forward (all to the same position, that is)? That, in principle, allows an unpriveleged user to pile a lot of list entries and cause serious looping under a spinlock...
Quoted 23 lines · Al Viro
Quoted 21 lines · Miklos Szeredi
Quoted 4 lines · Miklos Szeredi
Hi Al,
Can you please apply the following patches?
Ping? Could you please have a look at these patches?
-
/proc/mountscursor is almost half the total lines changed, and that one was already pretty damn well reviewed by you- unprivileged whiteout one was approved by the security guys
- aio fsync one is a real bug, please comment on whether the patch is acceptable or should I work around it in fuse
-
STATX_MNT_IDextension is a no brainer, the other one may or may not be useful, that's arguable...- the others are not important, but I think useful
Quoted 7 lines
Quoted 1 line
- and I missed one (faccess2); amending to patch series
I can live with that, modulo couple of trivial nits. Have you tested the
/proc/mountspart for what happens if it's opened shitloads of times, with each instance lseek'ed a bit forward (all to the same position, that is)? That, in principle, allows an unpriveleged user to pile a lot of list entries and cause serious looping under a spinlock...
Hmm, indeed.
Did some testing: a single loop takes on the order of 40ns. To trigger the soft lockup detector it would take 20s/40ns=500M cursors. Each new cursor is added after the existing ones, so inserting 500M cursors would take 40ns*500M^2/2 = ~158 years. That's obviously not a great way to DoS the system.
I understand that 100ms could be a serious problem in some cases, but even that would take 34 hours to set up.
Is less than that still a worry? I don't really know how much effort
is needed (if at all) in order to make this a non-issue.
Thanks,
Miklos
Quoted 18 lines · Al Viro
Quoted 16 lines · Miklos Szeredi
Quoted 4 lines · Miklos Szeredi
Hi Al,
Can you please apply the following patches?
Ping? Could you please have a look at these patches?
-
/proc/mountscursor is almost half the total lines changed, and that one was already pretty damn well reviewed by you- unprivileged whiteout one was approved by the security guys
- aio fsync one is a real bug, please comment on whether the patch is acceptable or should I work around it in fuse
Quoted 8 lines
Quoted 6 lines
-
STATX_MNT_IDextension is a no brainer, the other one may or may not be useful, that's arguable...- the others are not important, but I think useful
- and I missed one (faccess2); amending to patch series
I can live with that, modulo couple of trivial nits.
Nits from you and Christoph fixed, Reviewed-by: tags added, and force pushed to:
git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs.git#for-viro
As I've said, I'm not sure what are the constraints for spinlock holding. We could easily switch to a mutex and that would solve the inability to schedule, but would it make a real difference to the damage a malicious user can do?
Thanks,
Miklos
Al Viro
maintainerQuoted 3 lines · Miklos Szeredi
Nits from you and Christoph fixed, Reviewed-by: tags added, and force pushed to:
git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs.git#for-viro
Pulled, in for-next now.