From: Vivek Goyal <vgoyal@redhat.com>
To: linux-fsdevel@vger.kernel.org, Miklos Szeredi <miklos@szeredi.hu>
Subject: [PATCH] fuse: Clear setuid bit even in cache=never path
Date: Thu, 9 May 2019 15:42:44 -0400 [thread overview]
Message-ID: <20190509194244.GD24766@redhat.com> (raw)
If fuse daemon is started with cache=never, fuse falls back to direct IO.
In that write path we don't call file_remove_privs() and that means setuid
bit is not cleared if unpriviliged user writes to a file with setuid bit set.
pjdfstest chmod test 12.t tests this and fails.
Fix this by calling fuse_remove_privs() even for direct I/O path.
I tested this as follows.
- Run fuse example pasthrough fs.
$ passthrough_ll /mnt/pasthrough-mnt -o default_permissions,allow_other,cache=never
$ mkdir /mnt/pasthrough-mnt/testdir
$ cd /mnt/pasthrough-mnt/testdir
$ prove -rv pjdfstests/tests/chmod/12.t
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
---
fs/fuse/file.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
Index: rhvgoyal-linux/fs/fuse/file.c
===================================================================
--- rhvgoyal-linux.orig/fs/fuse/file.c 2019-05-09 15:08:36.782054201 -0400
+++ rhvgoyal-linux/fs/fuse/file.c 2019-05-09 15:28:09.397054201 -0400
@@ -1456,14 +1456,18 @@ static ssize_t fuse_direct_write_iter(st
/* Don't allow parallel writes to the same file */
inode_lock(inode);
res = generic_write_checks(iocb, from);
- if (res > 0) {
- if (!is_sync_kiocb(iocb) && iocb->ki_flags & IOCB_DIRECT) {
- res = fuse_direct_IO(iocb, from);
- } else {
- res = fuse_direct_io(&io, from, &iocb->ki_pos,
- FUSE_DIO_WRITE);
- }
+ if (res <= 0)
+ goto out;
+
+ res = file_remove_privs(iocb->ki_filp);
+ if (res)
+ goto out;
+ if (!is_sync_kiocb(iocb) && iocb->ki_flags & IOCB_DIRECT) {
+ res = fuse_direct_IO(iocb, from);
+ } else {
+ res = fuse_direct_io(&io, from, &iocb->ki_pos, FUSE_DIO_WRITE);
}
+out:
fuse_invalidate_attr(inode);
if (res > 0)
fuse_write_update_size(inode, iocb->ki_pos);
reply other threads:[~2019-05-09 19:42 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20190509194244.GD24766@redhat.com \
--to=vgoyal@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=miklos@szeredi.hu \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.