linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fuse: Support FS_IOC_GET_ENCRYPTION_POLICY_EX
@ 2020-12-07  4:03 Chirantan Ekbote
  2020-12-07 18:01 ` Eric Biggers
  2020-12-08  9:38 ` [PATCH v2 0/2] fuse: fscrypt ioctl support Chirantan Ekbote
  0 siblings, 2 replies; 8+ messages in thread
From: Chirantan Ekbote @ 2020-12-07  4:03 UTC (permalink / raw)
  To: Miklos Szeredi
  Cc: linux-fsdevel, Dylan Reid, Suleiman Souhlal, fuse-devel,
	Eric Biggers, Chirantan Ekbote

This is a dynamically sized ioctl so we need to check the user-provided
parameter for the actual length.

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

diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index c03034e8c1529..1627c14e9dacc 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -19,6 +19,7 @@
 #include <linux/falloc.h>
 #include <linux/uio.h>
 #include <linux/fs.h>
+#include <linux/fscrypt.h>
 
 static struct page **fuse_pages_alloc(unsigned int npages, gfp_t flags,
 				      struct fuse_page_desc **desc)
@@ -2808,6 +2809,21 @@ long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg,
 		case FS_IOC_SETFLAGS:
 			iov->iov_len = sizeof(int);
 			break;
+		case FS_IOC_GET_ENCRYPTION_POLICY_EX: {
+			struct fscrypt_get_policy_ex_arg policy;
+			unsigned long size_ptr =
+				arg + offsetof(struct fscrypt_get_policy_ex_arg,
+					       policy_size);
+
+			if (copy_from_user(&policy.policy_size,
+					   (void __user *)size_ptr,
+					   sizeof(policy.policy_size)))
+				return -EFAULT;
+
+			iov->iov_len =
+				sizeof(policy.policy_size) + policy.policy_size;
+			break;
+		}
 		default:
 			iov->iov_len = _IOC_SIZE(cmd);
 			break;
-- 
2.29.2.576.ga3fc446d84-goog


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

end of thread, other threads:[~2021-02-15 14:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-07  4:03 [PATCH] fuse: Support FS_IOC_GET_ENCRYPTION_POLICY_EX Chirantan Ekbote
2020-12-07 18:01 ` Eric Biggers
2020-12-08  9:38 ` [PATCH v2 0/2] fuse: fscrypt ioctl support Chirantan Ekbote
2020-12-08  9:38   ` [PATCH v2 1/2] fuse: Move ioctl length calculation to a separate function Chirantan Ekbote
2020-12-11 18:11     ` Eric Biggers
2020-12-08  9:38   ` [PATCH v2 2/2] fuse: Support FS_IOC_GET_ENCRYPTION_POLICY_EX Chirantan Ekbote
2020-12-11 18:12     ` Eric Biggers
2021-02-15 14:49     ` Miklos Szeredi

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