linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] fanotify: fix incorrect fmode_t casts
@ 2022-05-22 12:08 Vasily Averin
  2022-05-22 12:08 ` Christoph Hellwig
  2022-05-23  9:43 ` Jan Kara
  0 siblings, 2 replies; 3+ messages in thread
From: Vasily Averin @ 2022-05-22 12:08 UTC (permalink / raw)
  To: Jan Kara
  Cc: kernel, linux-kernel, Christoph Hellwig, Christian Brauner,
	Amir Goldstein, Matthew Bobrowski, linux-fsdevel

Fixes sparce warnings:
fs/notify/fanotify/fanotify_user.c:267:63: sparse:
 warning: restricted fmode_t degrades to integer
fs/notify/fanotify/fanotify_user.c:1351:28: sparse:
 warning: restricted fmode_t degrades to integer

FMODE_NONTIFY have bitwise fmode_t type and requires __force attribute
for any casts.

Signed-off-by: Vasily Averin <vvs@openvz.org>
Reviewed-by: Christian Brauner (Microsoft) <brauner@kernel.org>
---
v3: split, according to Christoph Hellwig recommendation
---
 fs/notify/fanotify/fanotify_user.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index a792e21c5309..16d8fc84713a 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -264,7 +264,7 @@ static int create_fd(struct fsnotify_group *group, struct path *path,
 	 * originally opened O_WRONLY.
 	 */
 	new_file = dentry_open(path,
-			       group->fanotify_data.f_flags | FMODE_NONOTIFY,
+			       group->fanotify_data.f_flags | __FMODE_NONOTIFY,
 			       current_cred());
 	if (IS_ERR(new_file)) {
 		/*
@@ -1348,7 +1348,7 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags)
 	    (!(fid_mode & FAN_REPORT_NAME) || !(fid_mode & FAN_REPORT_FID)))
 		return -EINVAL;
 
-	f_flags = O_RDWR | FMODE_NONOTIFY;
+	f_flags = O_RDWR | __FMODE_NONOTIFY;
 	if (flags & FAN_CLOEXEC)
 		f_flags |= O_CLOEXEC;
 	if (flags & FAN_NONBLOCK)
-- 
2.36.1


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

* Re: [PATCH v3] fanotify: fix incorrect fmode_t casts
  2022-05-22 12:08 [PATCH v3] fanotify: fix incorrect fmode_t casts Vasily Averin
@ 2022-05-22 12:08 ` Christoph Hellwig
  2022-05-23  9:43 ` Jan Kara
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2022-05-22 12:08 UTC (permalink / raw)
  To: Vasily Averin
  Cc: Jan Kara, kernel, linux-kernel, Christoph Hellwig,
	Christian Brauner, Amir Goldstein, Matthew Bobrowski,
	linux-fsdevel

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH v3] fanotify: fix incorrect fmode_t casts
  2022-05-22 12:08 [PATCH v3] fanotify: fix incorrect fmode_t casts Vasily Averin
  2022-05-22 12:08 ` Christoph Hellwig
@ 2022-05-23  9:43 ` Jan Kara
  1 sibling, 0 replies; 3+ messages in thread
From: Jan Kara @ 2022-05-23  9:43 UTC (permalink / raw)
  To: Vasily Averin
  Cc: Jan Kara, kernel, linux-kernel, Christoph Hellwig,
	Christian Brauner, Amir Goldstein, Matthew Bobrowski,
	linux-fsdevel

On Sun 22-05-22 15:08:02, Vasily Averin wrote:
> Fixes sparce warnings:
> fs/notify/fanotify/fanotify_user.c:267:63: sparse:
>  warning: restricted fmode_t degrades to integer
> fs/notify/fanotify/fanotify_user.c:1351:28: sparse:
>  warning: restricted fmode_t degrades to integer
> 
> FMODE_NONTIFY have bitwise fmode_t type and requires __force attribute
> for any casts.
> 
> Signed-off-by: Vasily Averin <vvs@openvz.org>
> Reviewed-by: Christian Brauner (Microsoft) <brauner@kernel.org>

Thanks. I've merged the patch to my tree.

								Honza

> ---
> v3: split, according to Christoph Hellwig recommendation
> ---
>  fs/notify/fanotify/fanotify_user.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
> index a792e21c5309..16d8fc84713a 100644
> --- a/fs/notify/fanotify/fanotify_user.c
> +++ b/fs/notify/fanotify/fanotify_user.c
> @@ -264,7 +264,7 @@ static int create_fd(struct fsnotify_group *group, struct path *path,
>  	 * originally opened O_WRONLY.
>  	 */
>  	new_file = dentry_open(path,
> -			       group->fanotify_data.f_flags | FMODE_NONOTIFY,
> +			       group->fanotify_data.f_flags | __FMODE_NONOTIFY,
>  			       current_cred());
>  	if (IS_ERR(new_file)) {
>  		/*
> @@ -1348,7 +1348,7 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags)
>  	    (!(fid_mode & FAN_REPORT_NAME) || !(fid_mode & FAN_REPORT_FID)))
>  		return -EINVAL;
>  
> -	f_flags = O_RDWR | FMODE_NONOTIFY;
> +	f_flags = O_RDWR | __FMODE_NONOTIFY;
>  	if (flags & FAN_CLOEXEC)
>  		f_flags |= O_CLOEXEC;
>  	if (flags & FAN_NONBLOCK)
> -- 
> 2.36.1
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

end of thread, other threads:[~2022-05-23  9:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-22 12:08 [PATCH v3] fanotify: fix incorrect fmode_t casts Vasily Averin
2022-05-22 12:08 ` Christoph Hellwig
2022-05-23  9:43 ` Jan Kara

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