linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] statx: Kill fd-with-NULL-path support in favour of AT_EMPTY_PATH
@ 2017-04-26 21:15 David Howells
       [not found] ` <149324135581.24512.17200609423997054366.stgit-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: David Howells @ 2017-04-26 21:15 UTC (permalink / raw)
  To: viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn
  Cc: linux-man-u79uwXL29TY76Z2rM5mHXA,
	linux-api-u79uwXL29TY76Z2rM5mHXA, Eric Sandeen,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	fstests-u79uwXL29TY76Z2rM5mHXA, dhowells-H+wXaHxf7aLQT0dZR+AlfA,
	Michael Kerrisk, linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
	torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b

[!] NOTE: This breaks UAPI introduced in 4.11-rc1.

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 "".

Fixes: a528d35e8bfc ("statx: Add a system call to make enhanced file info available")
Reported-by: Michael Kerrisk <mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Signed-off-by: David Howells <dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
cc: Eric Sandeen <sandeen-+82itfer+wXR7s880joybQ@public.gmane.org>
cc: fstests-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
cc: linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
cc: linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
---

 fs/stat.c |   13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/fs/stat.c b/fs/stat.c
index c6c963b2546b..3d85747bd86e 100644
--- a/fs/stat.c
+++ b/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
  * @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.
  * @mask: Parts of statx struct actually required.
  * @buffer: Result buffer.
  *
- * Note that if filename is NULL, then it does the equivalent of fstat() using
- * dfd to indicate the file of interest.
+ * Note that fstat() can be emulated by setting dfd to the fd of interest,
+ * supplying "" as the filename and setting AT_EMPTY_PATH in the flags.
  */
 SYSCALL_DEFINE5(statx,
 		int, dfd, const char __user *, filename, unsigned, flags,
@@ -567,11 +567,10 @@ SYSCALL_DEFINE5(statx,
 		return -EINVAL;
 	if ((flags & AT_STATX_SYNC_TYPE) == AT_STATX_SYNC_TYPE)
 		return -EINVAL;
+	if (!filename)
+		return -EINVAL;
 
-	if (filename)
-		error = vfs_statx(dfd, filename, flags, &stat, mask);
-	else
-		error = vfs_statx_fd(dfd, &stat, mask, flags);
+	error = vfs_statx(dfd, filename, flags, &stat, mask);
 	if (error)
 		return error;
 

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] statx: Kill fd-with-NULL-path support in favour of AT_EMPTY_PATH
       [not found] ` <149324135581.24512.17200609423997054366.stgit-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
@ 2017-04-26 22:03   ` Linus Torvalds
       [not found]     ` <CA+55aFwUwQCJQFur67_FF3=5L1-q5P32JTm+TwPadKYnOo1B-A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Linus Torvalds @ 2017-04-26 22:03 UTC (permalink / raw)
  To: David Howells
  Cc: Al Viro, linux-man-u79uwXL29TY76Z2rM5mHXA, Linux API,
	Eric Sandeen, Linux Kernel Mailing List,
	fstests-u79uwXL29TY76Z2rM5mHXA, Michael Kerrisk, linux-fsdevel

On Wed, Apr 26, 2017 at 2:15 PM, David Howells <dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
> [!] NOTE: This breaks UAPI introduced in 4.11-rc1.

Ugh.

I'm, applying this now, so that we don't end up with a released kernel
that supports the NULL filename thing.

I'm not happy about the timing though. And I hope nobody started using
statx() outside of tests.

                 Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] statx: Kill fd-with-NULL-path support in favour of AT_EMPTY_PATH
       [not found]     ` <CA+55aFwUwQCJQFur67_FF3=5L1-q5P32JTm+TwPadKYnOo1B-A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2017-04-27 11:53       ` Michael Kerrisk (man-pages)
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Kerrisk (man-pages) @ 2017-04-27 11:53 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: David Howells, Al Viro, linux-man, Linux API, Eric Sandeen,
	Linux Kernel Mailing List, fstests, linux-fsdevel,
	Michael Kerrisk, Christoph Hellwig

On 27 April 2017 at 00:03, Linus Torvalds <torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org> wrote:
> On Wed, Apr 26, 2017 at 2:15 PM, David Howells <dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
>> [!] NOTE: This breaks UAPI introduced in 4.11-rc1.
>
> Ugh.
>
> I'm, applying this now, so that we don't end up with a released kernel
> that supports the NULL filename thing.
>
> I'm not happy about the timing though. And I hope nobody started using
> statx() outside of tests.

Agreed on the timing. Late review on my part didn't help.

But, also, David's fix is not quite right. I will send a patch.

Cheers,

Michael

-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-04-27 11:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-26 21:15 [PATCH] statx: Kill fd-with-NULL-path support in favour of AT_EMPTY_PATH David Howells
     [not found] ` <149324135581.24512.17200609423997054366.stgit-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
2017-04-26 22:03   ` Linus Torvalds
     [not found]     ` <CA+55aFwUwQCJQFur67_FF3=5L1-q5P32JTm+TwPadKYnOo1B-A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-04-27 11:53       ` Michael Kerrisk (man-pages)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).