linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Vasily Averin <vvs@openvz.org>
Cc: Christoph Hellwig <hch@infradead.org>, Jan Kara <jack@suse.cz>,
	Christian Brauner <brauner@kernel.org>,
	kernel@openvz.org, linux-kernel@vger.kernel.org,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Amir Goldstein <amir73il@gmail.com>,
	Matthew Bobrowski <repnop@google.com>,
	linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v2] sparse: fix incorrect fmode_t casts
Date: Wed, 18 May 2022 06:22:33 -0700	[thread overview]
Message-ID: <YoTzGfqtbt1Bvemj@infradead.org> (raw)
In-Reply-To: <86e82d40-0952-e76f-aac5-53abe48ec770@openvz.org>

The fanotify and open.c changes looks fine, but should be split
into one each with a proper subject and description.

For procfs something simpler like the patch below might be a better
option:

diff --git a/fs/proc/base.c b/fs/proc/base.c
index c1031843cc6aa..c07c6b51f0cb9 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -2237,13 +2237,13 @@ static struct dentry *
 proc_map_files_instantiate(struct dentry *dentry,
 			   struct task_struct *task, const void *ptr)
 {
-	fmode_t mode = (fmode_t)(unsigned long)ptr;
+	const fmode_t *mode = ptr;
 	struct proc_inode *ei;
 	struct inode *inode;
 
 	inode = proc_pid_make_inode(dentry->d_sb, task, S_IFLNK |
-				    ((mode & FMODE_READ ) ? S_IRUSR : 0) |
-				    ((mode & FMODE_WRITE) ? S_IWUSR : 0));
+				    ((*mode & FMODE_READ ) ? S_IRUSR : 0) |
+				    ((*mode & FMODE_WRITE) ? S_IWUSR : 0));
 	if (!inode)
 		return ERR_PTR(-ENOENT);
 
@@ -2294,7 +2294,7 @@ static struct dentry *proc_map_files_lookup(struct inode *dir,
 
 	if (vma->vm_file)
 		result = proc_map_files_instantiate(dentry, task,
-				(void *)(unsigned long)vma->vm_file->f_mode);
+				&vma->vm_file->f_mode);
 
 out_no_vma:
 	mmap_read_unlock(mm);
@@ -2391,7 +2391,7 @@ proc_map_files_readdir(struct file *file, struct dir_context *ctx)
 				      buf, len,
 				      proc_map_files_instantiate,
 				      task,
-				      (void *)(unsigned long)p->mode))
+				      &p->mode))
 			break;
 		ctx->pos++;
 	}

  parent reply	other threads:[~2022-05-18 13:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-14 10:22 [PATCH] sparse: use force attribute for fmode_t casts Vasily Averin
2022-05-16 11:18 ` Jan Kara
2022-05-16 11:47 ` Christian Brauner
2022-05-17  6:38 ` Christoph Hellwig
2022-05-18 10:49   ` [PATCH v2] sparse: fix incorrect " Vasily Averin
2022-05-18 11:12     ` Jan Kara
2022-05-18 13:22     ` Christoph Hellwig [this message]
2022-05-18 14:44     ` Christian Brauner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YoTzGfqtbt1Bvemj@infradead.org \
    --to=hch@infradead.org \
    --cc=amir73il@gmail.com \
    --cc=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=kernel@openvz.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=repnop@google.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=vvs@openvz.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).