vfs: allow O_PATH file descriptors for fstatfs()
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 30 Sep 2013 15:35:10 +0000 (08:35 -0700)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 28 Nov 2013 14:02:03 +0000 (14:02 +0000)
commit 9d05746e7b16d8565dddbe3200faa1e669d23bbf upstream.

Olga reported that file descriptors opened with O_PATH do not work with
fstatfs(), found during further development of ksh93's thread support.

There is no reason to not allow O_PATH file descriptors here (fstatfs is
very much a path operation), so use "fdget_raw()".  See commit
55815f70147d ("vfs: make O_PATH file descriptors usable for 'fstat()'")
for a very similar issue reported for fstat() by the same team.

Reported-and-tested-by: ольга крыжановская <olga.kryzhanovska@gmail.com>
Acked-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[bwh: Backported to 3.2: use fget_raw() not fdget_raw()]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
fs/statfs.c

index 9cf04a1..a133c3e 100644 (file)
@@ -86,7 +86,7 @@ int user_statfs(const char __user *pathname, struct kstatfs *st)
 
 int fd_statfs(int fd, struct kstatfs *st)
 {
-       struct file *file = fget(fd);
+       struct file *file = fget_raw(fd);
        int error = -EBADF;
        if (file) {
                error = vfs_statfs(&file->f_path, st);