All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fscrypt: remove unnecessary checks for NULL operations
@ 2017-04-04 21:39 Eric Biggers
  2017-04-06 19:24 ` Richard Weinberger
  2017-04-30  6:16 ` Theodore Ts'o
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Biggers @ 2017-04-04 21:39 UTC (permalink / raw)
  To: linux-fscrypt
  Cc: linux-fsdevel, Theodore Y . Ts'o, Jaegeuk Kim, Eric Biggers

From: Eric Biggers <ebiggers@google.com>

The functions in fs/crypto/*.c are only called by filesystems configured
with encryption support.  Since the ->get_context(), ->set_context(),
and ->empty_dir() operations are always provided in that case (and must
be, otherwise there would be no way to get/set encryption policies, or
in the case of ->get_context() even access encrypted files at all),
there is no need to check for these operations being NULL and we can
remove these unneeded checks.

Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 fs/crypto/keyinfo.c |  3 ---
 fs/crypto/policy.c  | 11 +----------
 2 files changed, 1 insertion(+), 13 deletions(-)

diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c
index 8cdfddce2b34..179e578b875b 100644
--- a/fs/crypto/keyinfo.c
+++ b/fs/crypto/keyinfo.c
@@ -183,9 +183,6 @@ int fscrypt_get_encryption_info(struct inode *inode)
 	if (res)
 		return res;
 
-	if (!inode->i_sb->s_cop->get_context)
-		return -EOPNOTSUPP;
-
 	res = inode->i_sb->s_cop->get_context(inode, &ctx, sizeof(ctx));
 	if (res < 0) {
 		if (!fscrypt_dummy_context_enabled(inode) ||
diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c
index 4908906d54d5..d71ec3780d0c 100644
--- a/fs/crypto/policy.c
+++ b/fs/crypto/policy.c
@@ -34,9 +34,6 @@ static int create_encryption_context_from_policy(struct inode *inode,
 {
 	struct fscrypt_context ctx;
 
-	if (!inode->i_sb->s_cop->set_context)
-		return -EOPNOTSUPP;
-
 	ctx.format = FS_ENCRYPTION_CONTEXT_FORMAT_V1;
 	memcpy(ctx.master_key_descriptor, policy->master_key_descriptor,
 					FS_KEY_DESCRIPTOR_SIZE);
@@ -87,8 +84,6 @@ int fscrypt_ioctl_set_policy(struct file *filp, const void __user *arg)
 	if (ret == -ENODATA) {
 		if (!S_ISDIR(inode->i_mode))
 			ret = -ENOTDIR;
-		else if (!inode->i_sb->s_cop->empty_dir)
-			ret = -EOPNOTSUPP;
 		else if (!inode->i_sb->s_cop->empty_dir(inode))
 			ret = -ENOTEMPTY;
 		else
@@ -118,8 +113,7 @@ int fscrypt_ioctl_get_policy(struct file *filp, void __user *arg)
 	struct fscrypt_policy policy;
 	int res;
 
-	if (!inode->i_sb->s_cop->get_context ||
-			!inode->i_sb->s_cop->is_encrypted(inode))
+	if (!inode->i_sb->s_cop->is_encrypted(inode))
 		return -ENODATA;
 
 	res = inode->i_sb->s_cop->get_context(inode, &ctx, sizeof(ctx));
@@ -202,9 +196,6 @@ int fscrypt_inherit_context(struct inode *parent, struct inode *child,
 	struct fscrypt_info *ci;
 	int res;
 
-	if (!parent->i_sb->s_cop->set_context)
-		return -EOPNOTSUPP;
-
 	res = fscrypt_get_encryption_info(parent);
 	if (res < 0)
 		return res;
-- 
2.12.2.715.g7642488e1d-goog

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

* Re: [PATCH] fscrypt: remove unnecessary checks for NULL operations
  2017-04-04 21:39 [PATCH] fscrypt: remove unnecessary checks for NULL operations Eric Biggers
@ 2017-04-06 19:24 ` Richard Weinberger
  2017-04-30  6:16 ` Theodore Ts'o
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Weinberger @ 2017-04-06 19:24 UTC (permalink / raw)
  To: Eric Biggers
  Cc: linux-fscrypt, linux-fsdevel, Theodore Y . Ts'o, Jaegeuk Kim,
	Eric Biggers

On Tue, Apr 4, 2017 at 11:39 PM, Eric Biggers <ebiggers3@gmail.com> wrote:
> From: Eric Biggers <ebiggers@google.com>
>
> The functions in fs/crypto/*.c are only called by filesystems configured
> with encryption support.  Since the ->get_context(), ->set_context(),
> and ->empty_dir() operations are always provided in that case (and must
> be, otherwise there would be no way to get/set encryption policies, or
> in the case of ->get_context() even access encrypted files at all),
> there is no need to check for these operations being NULL and we can
> remove these unneeded checks.
>
> Signed-off-by: Eric Biggers <ebiggers@google.com>
> ---
>  fs/crypto/keyinfo.c |  3 ---
>  fs/crypto/policy.c  | 11 +----------
>  2 files changed, 1 insertion(+), 13 deletions(-)
>
> diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c
> index 8cdfddce2b34..179e578b875b 100644
> --- a/fs/crypto/keyinfo.c
> +++ b/fs/crypto/keyinfo.c
> @@ -183,9 +183,6 @@ int fscrypt_get_encryption_info(struct inode *inode)
>         if (res)
>                 return res;
>
> -       if (!inode->i_sb->s_cop->get_context)
> -               return -EOPNOTSUPP;
> -
>         res = inode->i_sb->s_cop->get_context(inode, &ctx, sizeof(ctx));
>         if (res < 0) {
>                 if (!fscrypt_dummy_context_enabled(inode) ||
> diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c
> index 4908906d54d5..d71ec3780d0c 100644
> --- a/fs/crypto/policy.c
> +++ b/fs/crypto/policy.c
> @@ -34,9 +34,6 @@ static int create_encryption_context_from_policy(struct inode *inode,
>  {
>         struct fscrypt_context ctx;
>
> -       if (!inode->i_sb->s_cop->set_context)
> -               return -EOPNOTSUPP;
> -
>         ctx.format = FS_ENCRYPTION_CONTEXT_FORMAT_V1;
>         memcpy(ctx.master_key_descriptor, policy->master_key_descriptor,
>                                         FS_KEY_DESCRIPTOR_SIZE);
> @@ -87,8 +84,6 @@ int fscrypt_ioctl_set_policy(struct file *filp, const void __user *arg)
>         if (ret == -ENODATA) {
>                 if (!S_ISDIR(inode->i_mode))
>                         ret = -ENOTDIR;
> -               else if (!inode->i_sb->s_cop->empty_dir)
> -                       ret = -EOPNOTSUPP;
>                 else if (!inode->i_sb->s_cop->empty_dir(inode))
>                         ret = -ENOTEMPTY;
>                 else
> @@ -118,8 +113,7 @@ int fscrypt_ioctl_get_policy(struct file *filp, void __user *arg)
>         struct fscrypt_policy policy;
>         int res;
>
> -       if (!inode->i_sb->s_cop->get_context ||
> -                       !inode->i_sb->s_cop->is_encrypted(inode))
> +       if (!inode->i_sb->s_cop->is_encrypted(inode))
>                 return -ENODATA;
>
>         res = inode->i_sb->s_cop->get_context(inode, &ctx, sizeof(ctx));
> @@ -202,9 +196,6 @@ int fscrypt_inherit_context(struct inode *parent, struct inode *child,
>         struct fscrypt_info *ci;
>         int res;
>
> -       if (!parent->i_sb->s_cop->set_context)
> -               return -EOPNOTSUPP;
> -
>         res = fscrypt_get_encryption_info(parent);
>         if (res < 0)
>                 return res;

Reviewed-by: Richard Weinberger <richard@nod.at>

-- 
Thanks,
//richard

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

* Re: fscrypt: remove unnecessary checks for NULL operations
  2017-04-04 21:39 [PATCH] fscrypt: remove unnecessary checks for NULL operations Eric Biggers
  2017-04-06 19:24 ` Richard Weinberger
@ 2017-04-30  6:16 ` Theodore Ts'o
  1 sibling, 0 replies; 3+ messages in thread
From: Theodore Ts'o @ 2017-04-30  6:16 UTC (permalink / raw)
  To: Eric Biggers; +Cc: linux-fscrypt, linux-fsdevel, Jaegeuk Kim, Eric Biggers

On Tue, Apr 04, 2017 at 02:39:41PM -0700, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
> 
> The functions in fs/crypto/*.c are only called by filesystems configured
> with encryption support.  Since the ->get_context(), ->set_context(),
> and ->empty_dir() operations are always provided in that case (and must
> be, otherwise there would be no way to get/set encryption policies, or
> in the case of ->get_context() even access encrypted files at all),
> there is no need to check for these operations being NULL and we can
> remove these unneeded checks.
> 
> Signed-off-by: Eric Biggers <ebiggers@google.com>
> Reviewed-by: Richard Weinberger <richard@nod.at>

Thanks, applied.

						- Ted

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

end of thread, other threads:[~2017-04-30  6:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-04 21:39 [PATCH] fscrypt: remove unnecessary checks for NULL operations Eric Biggers
2017-04-06 19:24 ` Richard Weinberger
2017-04-30  6:16 ` Theodore Ts'o

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.