mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 05:20:53 +07:00
statx: Kill fd-with-NULL-path support in favour of AT_EMPTY_PATH
With the new statx() syscall, the following both allow the attributes of
the file attached to a file descriptor to be retrieved:
statx(dfd, NULL, 0, ...);
and:
statx(dfd, "", AT_EMPTY_PATH, ...);
Change the code to reject the first option, though this means copying
the path and engaging pathwalk for the fstat() equivalent. dfd can be a
non-directory provided path is "".
[ The timing of this isn't wonderful, but applying this now before we
have statx() in any released kernel, before anybody starts using the
NULL special case. - Linus ]
Fixes: a528d35e8b
("statx: Add a system call to make enhanced file info available")
Reported-by: Michael Kerrisk <mtk.manpages@gmail.com>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Eric Sandeen <sandeen@sandeen.net>
cc: fstests@vger.kernel.org
cc: linux-api@vger.kernel.org
cc: linux-man@vger.kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
fc08b197bb
commit
1e2f82d1e9
13
fs/stat.c
13
fs/stat.c
@ -547,13 +547,13 @@ cp_statx(const struct kstat *stat, struct statx __user *buffer)
|
|||||||
/**
|
/**
|
||||||
* sys_statx - System call to get enhanced stats
|
* sys_statx - System call to get enhanced stats
|
||||||
* @dfd: Base directory to pathwalk from *or* fd to stat.
|
* @dfd: Base directory to pathwalk from *or* fd to stat.
|
||||||
* @filename: File to stat *or* NULL.
|
* @filename: File to stat or "" with AT_EMPTY_PATH
|
||||||
* @flags: AT_* flags to control pathwalk.
|
* @flags: AT_* flags to control pathwalk.
|
||||||
* @mask: Parts of statx struct actually required.
|
* @mask: Parts of statx struct actually required.
|
||||||
* @buffer: Result buffer.
|
* @buffer: Result buffer.
|
||||||
*
|
*
|
||||||
* Note that if filename is NULL, then it does the equivalent of fstat() using
|
* Note that fstat() can be emulated by setting dfd to the fd of interest,
|
||||||
* dfd to indicate the file of interest.
|
* supplying "" as the filename and setting AT_EMPTY_PATH in the flags.
|
||||||
*/
|
*/
|
||||||
SYSCALL_DEFINE5(statx,
|
SYSCALL_DEFINE5(statx,
|
||||||
int, dfd, const char __user *, filename, unsigned, flags,
|
int, dfd, const char __user *, filename, unsigned, flags,
|
||||||
@ -567,11 +567,10 @@ SYSCALL_DEFINE5(statx,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if ((flags & AT_STATX_SYNC_TYPE) == AT_STATX_SYNC_TYPE)
|
if ((flags & AT_STATX_SYNC_TYPE) == AT_STATX_SYNC_TYPE)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
if (!filename)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
if (filename)
|
error = vfs_statx(dfd, filename, flags, &stat, mask);
|
||||||
error = vfs_statx(dfd, filename, flags, &stat, mask);
|
|
||||||
else
|
|
||||||
error = vfs_statx_fd(dfd, &stat, mask, flags);
|
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user