Re: [PATCH v3] fs/proc/base.c: fix incorrect fmode_t casts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, May 22, 2022 at 03:08:42PM +0300, Vasily Averin wrote:
> diff --git a/fs/proc/base.c b/fs/proc/base.c
> index c1031843cc6a..4e4edf9db5f0 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;

Why not ...

	fmode_t mode = *(fmode_t *)ptr;

and then you don't need

> -				    ((mode & FMODE_READ ) ? S_IRUSR : 0) |
> -				    ((mode & FMODE_WRITE) ? S_IWUSR : 0));
> +				    ((*mode & FMODE_READ ) ? S_IRUSR : 0) |
> +				    ((*mode & FMODE_WRITE) ? S_IWUSR : 0));



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux