diff options
author | Eric Biggers <ebiggers@google.com> | 2017-03-31 13:31:32 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2017-04-03 01:05:56 -0400 |
commit | 8c7493aa3e9ae90f90196f4d4c1398ad143cba7b (patch) | |
tree | 1639352862be76cb08c7b04f64a71008aeab18b9 /fs/stat.c | |
parent | 75dd7e4bb663c7047c7d1bd4dad26f8c048851be (diff) |
statx: reject unknown flags when using NULL path
The statx() system call currently accepts unknown flags when called with
a NULL path to operate on a file descriptor. Left unchanged, this could
make it hard to introduce new query flags in the future, since
applications may not be able to tell whether a given flag is supported.
Fix this by failing the system call with EINVAL if any flags other than
KSTAT_QUERY_FLAGS are specified in combination with a NULL path.
Arguably, we could still permit known lookup-related flags such as
AT_SYMLINK_NOFOLLOW. However, that would be inconsistent with how
sys_utimensat() behaves when passed a NULL path, which seems to be the
closest precedent. And given that the NULL path case is (I believe)
mainly intended to be used to implement a wrapper function like fstatx()
that doesn't have a path argument, I think rejecting lookup-related
flags too is probably the best choice.
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/stat.c')
-rw-r--r-- | fs/stat.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -130,9 +130,13 @@ EXPORT_SYMBOL(vfs_getattr); | |||
130 | int vfs_statx_fd(unsigned int fd, struct kstat *stat, | 130 | int vfs_statx_fd(unsigned int fd, struct kstat *stat, |
131 | u32 request_mask, unsigned int query_flags) | 131 | u32 request_mask, unsigned int query_flags) |
132 | { | 132 | { |
133 | struct fd f = fdget_raw(fd); | 133 | struct fd f; |
134 | int error = -EBADF; | 134 | int error = -EBADF; |
135 | 135 | ||
136 | if (query_flags & ~KSTAT_QUERY_FLAGS) | ||
137 | return -EINVAL; | ||
138 | |||
139 | f = fdget_raw(fd); | ||
136 | if (f.file) { | 140 | if (f.file) { |
137 | error = vfs_getattr(&f.file->f_path, stat, | 141 | error = vfs_getattr(&f.file->f_path, stat, |
138 | request_mask, query_flags); | 142 | request_mask, query_flags); |