All of lore.kernel.org
 help / color / mirror / Atom feed
From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: Helge Deller <deller@gmx.de>
Cc: linux-kernel@vger.kernel.org,
	David Laight <David.Laight@aculab.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Andreas Schwab <schwab@linux-m68k.org>,
	linux-parisc@vger.kernel.org
Subject: Re: [PATCH v2] fat: Use pointer to simple type in put_user()
Date: Tue, 15 Feb 2022 01:08:30 +0900	[thread overview]
Message-ID: <87r185h1mp.fsf@mail.parknet.co.jp> (raw)
In-Reply-To: <Ygo+A9MREmC1H3kr@p100> (Helge Deller's message of "Mon, 14 Feb 2022 12:33:23 +0100")

Helge Deller <deller@gmx.de> writes:

> The put_user(val,ptr) macro wants a pointer to a simple type, but in
> fat_ioctl_filldir() the d_name field references an "array of chars".
> Be more accurate and explicitly give the pointer to the first character
> of the d_name[] array.
>
> I noticed that issue while trying to optimize the parisc put_user() macro
> and used an intermediate variable to store the pointer. In that case I
> got this error:
>
> In file included from include/linux/uaccess.h:11,
>                  from include/linux/compat.h:17,
>                  from fs/fat/dir.c:18:
> fs/fat/dir.c: In function ‘fat_ioctl_filldir’:
> fs/fat/dir.c:725:33: error: invalid initializer
>   725 |                 if (put_user(0, d2->d_name)                     ||         \
>       |                                 ^~
> include/asm/uaccess.h:152:33: note: in definition of macro ‘__put_user’
>   152 |         __typeof__(ptr) __ptr = ptr;                            \
>       |                                 ^~~
> fs/fat/dir.c:759:1: note: in expansion of macro ‘FAT_IOCTL_FILLDIR_FUNC’
>   759 | FAT_IOCTL_FILLDIR_FUNC(fat_ioctl_filldir, __fat_dirent)
>
>
> Andreas Schwab <schwab@linux-m68k.org> suggested to use
>    __typeof__(&*(ptr)) __ptr = ptr;
> instead. This works, but nevertheless it's probably reasonable to
> fix the original caller too.
>
> Signed-off-by: Helge Deller <deller@gmx.de>

Acked-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

> __
> v2: Adjusted the description with input from David Laight
>     <David.Laight@ACULAB.COM> and Andreas Schwab <schwab@linux-m68k.org>.
>
> diff --git a/fs/fat/dir.c b/fs/fat/dir.c
> index c4a274285858..249825017da7 100644
> --- a/fs/fat/dir.c
> +++ b/fs/fat/dir.c
> @@ -722,7 +722,7 @@ static int func(struct dir_context *ctx, const char *name, int name_len,   \
>  		if (name_len >= sizeof(d1->d_name))			   \
>  			name_len = sizeof(d1->d_name) - 1;		   \
>  									   \
> -		if (put_user(0, d2->d_name)			||	   \
> +		if (put_user(0, &d2->d_name[0])			||	   \
>  		    put_user(0, &d2->d_reclen)			||	   \
>  		    copy_to_user(d1->d_name, name, name_len)	||	   \
>  		    put_user(0, d1->d_name + name_len)		||	   \

-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

      reply	other threads:[~2022-02-14 16:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-14 11:33 [PATCH v2] fat: Use pointer to simple type in put_user() Helge Deller
2022-02-14 16:08 ` OGAWA Hirofumi [this message]

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=87r185h1mp.fsf@mail.parknet.co.jp \
    --to=hirofumi@mail.parknet.co.jp \
    --cc=David.Laight@aculab.com \
    --cc=akpm@linux-foundation.org \
    --cc=deller@gmx.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=schwab@linux-m68k.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 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.