All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fanotify_user: use upper_32_bits() to verify mask
@ 2021-03-25  8:37 Christian Brauner
  2021-03-25 14:34 ` Jan Kara
  0 siblings, 1 reply; 2+ messages in thread
From: Christian Brauner @ 2021-03-25  8:37 UTC (permalink / raw)
  To: Jan Kara, Amir Goldstein; +Cc: linux-fsdevel, linux-kernel, Christian Brauner

From: Christian Brauner <christian.brauner@ubuntu.com>

I don't see an obvious reason why the upper 32 bit check needs to be
open-coded this way. Switch to upper_32_bits() which is more idiomatic and
should conceptually be the same check.

Cc: Amir Goldstein <amir73il@gmail.com>
Cc: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
---
 fs/notify/fanotify/fanotify_user.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index 9e0c1afac8bd..d5683fa9d495 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -1126,7 +1126,7 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask,
 		 __func__, fanotify_fd, flags, dfd, pathname, mask);
 
 	/* we only use the lower 32 bits as of right now. */
-	if (mask & ((__u64)0xffffffff << 32))
+	if (upper_32_bits(mask))
 		return -EINVAL;
 
 	if (flags & ~FANOTIFY_MARK_FLAGS)

base-commit: 0d02ec6b3136c73c09e7859f0d0e4e2c4c07b49b
-- 
2.27.0


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

* Re: [PATCH] fanotify_user: use upper_32_bits() to verify mask
  2021-03-25  8:37 [PATCH] fanotify_user: use upper_32_bits() to verify mask Christian Brauner
@ 2021-03-25 14:34 ` Jan Kara
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Kara @ 2021-03-25 14:34 UTC (permalink / raw)
  To: Christian Brauner
  Cc: Jan Kara, Amir Goldstein, linux-fsdevel, linux-kernel, Christian Brauner

On Thu 25-03-21 09:37:43, Christian Brauner wrote:
> From: Christian Brauner <christian.brauner@ubuntu.com>
> 
> I don't see an obvious reason why the upper 32 bit check needs to be
> open-coded this way. Switch to upper_32_bits() which is more idiomatic and
> should conceptually be the same check.
> 
> Cc: Amir Goldstein <amir73il@gmail.com>
> Cc: Jan Kara <jack@suse.cz>
> Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>

Thanks for the cleanup. I've added it to my tree.

								Honza

> ---
>  fs/notify/fanotify/fanotify_user.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
> index 9e0c1afac8bd..d5683fa9d495 100644
> --- a/fs/notify/fanotify/fanotify_user.c
> +++ b/fs/notify/fanotify/fanotify_user.c
> @@ -1126,7 +1126,7 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask,
>  		 __func__, fanotify_fd, flags, dfd, pathname, mask);
>  
>  	/* we only use the lower 32 bits as of right now. */
> -	if (mask & ((__u64)0xffffffff << 32))
> +	if (upper_32_bits(mask))
>  		return -EINVAL;
>  
>  	if (flags & ~FANOTIFY_MARK_FLAGS)
> 
> base-commit: 0d02ec6b3136c73c09e7859f0d0e4e2c4c07b49b
> -- 
> 2.27.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

end of thread, other threads:[~2021-03-25 14:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-25  8:37 [PATCH] fanotify_user: use upper_32_bits() to verify mask Christian Brauner
2021-03-25 14:34 ` Jan Kara

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.