From: Eric Biggers <ebiggers3@gmail.com>
To: linux-fsdevel@vger.kernel.org
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
David Howells <dhowells@redhat.com>,
mtk.manpages@gmail.com, Christoph Hellwig <hch@infradead.org>,
"Darrick J . Wong" <darrick.wong@oracle.com>,
Linux API <linux-api@vger.kernel.org>,
linux-xfs@vger.kernel.org, Eric Biggers <ebiggers@google.com>
Subject: [PATCH] statx: reject unknown flags when using NULL path
Date: Fri, 10 Mar 2017 22:58:23 -0800 [thread overview]
Message-ID: <20170311065823.4415-1-ebiggers3@gmail.com> (raw)
From: Eric Biggers <ebiggers@google.com>
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>
---
fs/stat.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/fs/stat.c b/fs/stat.c
index fa0be59340cc..df484a60846d 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -130,9 +130,13 @@ EXPORT_SYMBOL(vfs_getattr);
int vfs_statx_fd(unsigned int fd, struct kstat *stat,
u32 request_mask, unsigned int query_flags)
{
- struct fd f = fdget_raw(fd);
+ struct fd f;
int error = -EBADF;
+ if (query_flags & ~KSTAT_QUERY_FLAGS)
+ return -EINVAL;
+
+ f = fdget_raw(fd);
if (f.file) {
error = vfs_getattr(&f.file->f_path, stat,
request_mask, query_flags);
--
2.12.0
next reply other threads:[~2017-03-11 7:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-11 6:58 Eric Biggers [this message]
2017-03-20 17:11 ` [PATCH] statx: reject unknown flags when using NULL path Eric Biggers
2017-03-20 17:44 ` Christoph Hellwig
2017-03-31 15:39 ` Christoph Hellwig
2017-03-31 15:43 ` Al Viro
2017-03-31 15:51 ` David Howells
2017-03-31 16:02 ` Christoph Hellwig
2017-03-31 16:58 ` David Howells
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170311065823.4415-1-ebiggers3@gmail.com \
--to=ebiggers3@gmail.com \
--cc=darrick.wong@oracle.com \
--cc=dhowells@redhat.com \
--cc=ebiggers@google.com \
--cc=hch@infradead.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=mtk.manpages@gmail.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).