linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chirantan Ekbote <chirantan@chromium.org>
To: =Miklos Szeredi <miklos@szeredi.hu>
Cc: linux-fsdevel@vger.kernel.org, Dylan Reid <dgreid@chromium.org>,
	Suleiman Souhlal <suleiman@chromium.org>,
	Chirantan Ekbote <chirantan@chromium.org>
Subject: [PATCH] fuse: Mark fscrypt ioctls as unrestricted
Date: Thu, 23 Apr 2020 16:47:06 +0900	[thread overview]
Message-ID: <20200423074706.107016-1-chirantan@chromium.org> (raw)

The definitions for these 2 ioctls have been reversed: "get" is marked
as a write ioctl and "set" is marked as a read ioctl.  Moreover, since
these are now part of the public kernel interface they can never be
fixed because fixing them might break userspace applications compiled
with the older headers.

Since the fuse module strictly enforces the ioctl encodings, it will
reject any attempt by the fuse server to correctly implement these
ioctls.  Instead, check if the process is trying to make one of these
ioctls and mark it unrestricted.  This will allow the server to fix the
encoding by reading/writing the correct data.

Signed-off-by: Chirantan Ekbote <chirantan@chromium.org>
---
 fs/fuse/file.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 9d67b830fb7a2..9b6d993323d53 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -18,6 +18,7 @@
 #include <linux/swap.h>
 #include <linux/falloc.h>
 #include <linux/uio.h>
+#include <linux/fscrypt.h>
 
 static struct page **fuse_pages_alloc(unsigned int npages, gfp_t flags,
 				      struct fuse_page_desc **desc)
@@ -2751,6 +2752,16 @@ long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg,
 
 	fuse_page_descs_length_init(ap.descs, 0, fc->max_pages);
 
+	/*
+	 * These commands are encoded backwards so it is literally impossible
+	 * for a fuse server to implement them. Instead, mark them unrestricted
+	 * so that the server can deal with the broken encoding itself.
+	 */
+	if (cmd == FS_IOC_GET_ENCRYPTION_POLICY ||
+	    cmd == FS_IOC_SET_ENCRYPTION_POLICY) {
+		flags |= FUSE_IOCTL_UNRESTRICTED;
+	}
+
 	/*
 	 * If restricted, initialize IO parameters as encoded in @cmd.
 	 * RETRY from server is not allowed.
-- 
2.26.1.301.g55bc3eb7cb9-goog


             reply	other threads:[~2020-04-23  7:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-23  7:47 Chirantan Ekbote [this message]
2020-04-23 15:38 ` [PATCH] fuse: Mark fscrypt ioctls as unrestricted Eric Biggers
2020-04-24  6:12   ` Chirantan Ekbote

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=20200423074706.107016-1-chirantan@chromium.org \
    --to=chirantan@chromium.org \
    --cc=dgreid@chromium.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=suleiman@chromium.org \
    /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).