linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: disable pwsalt ioctl when encryption disabled by config
@ 2016-11-22  0:23 Eric Biggers
  2016-12-01 16:56 ` Theodore Ts'o
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Biggers @ 2016-11-22  0:23 UTC (permalink / raw)
  To: linux-ext4
  Cc: Theodore Ts'o, Andreas Dilger, Jaegeuk Kim,
	Richard Weinberger, Eric Biggers

On a CONFIG_EXT4_FS_ENCRYPTION=n kernel, the ioctls to get and set
encryption policies were disabled but EXT4_IOC_GET_ENCRYPTION_PWSALT was
not.  But there's no good reason to expose the pwsalt ioctl if the
kernel doesn't support encryption.  The pwsalt ioctl was also disabled
pre-4.8 (via ext4_sb_has_crypto() previously returning 0 when encryption
was disabled by config) and seems to have been enabled by mistake when
ext4 encryption was refactored to use fs/crypto/.  So let's disable it
again.

Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 fs/ext4/ioctl.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index a0db5d9..a8957d9 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -191,6 +191,7 @@ static long swap_inode_boot_loader(struct super_block *sb,
 	return err;
 }
 
+#ifdef CONFIG_EXT4_FS_ENCRYPTION
 static int uuid_is_zero(__u8 u[16])
 {
 	int	i;
@@ -200,6 +201,7 @@ static int uuid_is_zero(__u8 u[16])
 			return 0;
 	return 1;
 }
+#endif
 
 static int ext4_ioctl_setflags(struct inode *inode,
 			       unsigned int flags)
@@ -782,6 +784,7 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 #endif
 	}
 	case EXT4_IOC_GET_ENCRYPTION_PWSALT: {
+#ifdef CONFIG_EXT4_FS_ENCRYPTION
 		int err, err2;
 		struct ext4_sb_info *sbi = EXT4_SB(sb);
 		handle_t *handle;
@@ -816,6 +819,9 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 				 sbi->s_es->s_encrypt_pw_salt, 16))
 			return -EFAULT;
 		return 0;
+#else
+		return -EOPNOTSUPP;
+#endif
 	}
 	case EXT4_IOC_GET_ENCRYPTION_POLICY: {
 #ifdef CONFIG_EXT4_FS_ENCRYPTION
-- 
2.8.0.rc3.226.g39d4020


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

* Re: [PATCH] ext4: disable pwsalt ioctl when encryption disabled by config
  2016-11-22  0:23 [PATCH] ext4: disable pwsalt ioctl when encryption disabled by config Eric Biggers
@ 2016-12-01 16:56 ` Theodore Ts'o
  0 siblings, 0 replies; 2+ messages in thread
From: Theodore Ts'o @ 2016-12-01 16:56 UTC (permalink / raw)
  To: Eric Biggers; +Cc: linux-ext4, Andreas Dilger, Jaegeuk Kim, Richard Weinberger

On Mon, Nov 21, 2016 at 04:23:12PM -0800, Eric Biggers wrote:
> On a CONFIG_EXT4_FS_ENCRYPTION=n kernel, the ioctls to get and set
> encryption policies were disabled but EXT4_IOC_GET_ENCRYPTION_PWSALT was
> not.  But there's no good reason to expose the pwsalt ioctl if the
> kernel doesn't support encryption.  The pwsalt ioctl was also disabled
> pre-4.8 (via ext4_sb_has_crypto() previously returning 0 when encryption
> was disabled by config) and seems to have been enabled by mistake when
> ext4 encryption was refactored to use fs/crypto/.  So let's disable it
> again.
> 
> Signed-off-by: Eric Biggers <ebiggers@google.com>

Thanks, applied.

					- Ted

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

end of thread, other threads:[~2016-12-01 16:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-22  0:23 [PATCH] ext4: disable pwsalt ioctl when encryption disabled by config Eric Biggers
2016-12-01 16:56 ` Theodore Ts'o

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