public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Helge Deller' <deller@gmx.de>,
	OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: "linux-parisc@vger.kernel.org" <linux-parisc@vger.kernel.org>
Subject: RE: [PATCH] fat: Use pointer to d_name[0] in put_user() for compat case
Date: Mon, 14 Feb 2022 11:11:13 +0000	[thread overview]
Message-ID: <01801d084adf442aa5b8dc4bf1eee771@AcuMS.aculab.com> (raw)
In-Reply-To: <ffebaea4-8135-6e2e-fca1-8e9f118ef70b@gmx.de>

From: Helge Deller
> Sent: 14 February 2022 11:05
> 
> On 2/14/22 10:26, David Laight wrote:
> > From: David Laight
> >> Sent: 14 February 2022 09:12
> >>
> >> From: Helge Deller
> >>> Sent: 13 February 2022 22:10
> >>>
> >>> The put_user(val,ptr) macro wants a pointer in the second parameter, but in
> >>> fat_ioctl_filldir() the d_name field references a whole "array of chars".
> >>> Usually the compiler automatically converts it and uses a pointer to that
> >>> array, but it's more clean to explicitly give the real pointer to where someting
> >>> is put, which is in this case the first character of the d_name[] array.
> >>
> >> That just isn't true.
> >>
> >> In C both x->char_array and &x->char_array[0] have the same type
> >> 'char *'.
> >>
> >> The 'bug' is caused by put_user() trying to do:
> >> 	__typeof__(ptr) __ptr = ptr;
> >> where __typeof__ is returning char[n] not char *.
> >>
> >> I've tried a few things but can't get __typeof__ to
> >> generate a suitable type for both a simple type and array.
> >
> > Actually the issue is that put_user() writes a single variable
> > and needs a pointer to one.
> > So changing to:
> > 	put_user(0, &array[0]);
> > is probably fine.
> 
> Ok.
> 
> > But the description is all wrong.
> 
> I agree it can be improved.
> Would you mind proposing a better description?

put_user() needs a pointer to a simple type.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

  reply	other threads:[~2022-02-14 11:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-13 22:10 [PATCH] fat: Use pointer to d_name[0] in put_user() for compat case Helge Deller
2022-02-14  7:59 ` OGAWA Hirofumi
2022-02-14  9:12 ` David Laight
2022-02-14  9:26   ` David Laight
2022-02-14 11:05     ` Helge Deller
2022-02-14 11:11       ` David Laight [this message]
2022-02-14  9:27   ` Andreas Schwab
2022-02-14 10:13     ` Helge Deller

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=01801d084adf442aa5b8dc4bf1eee771@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=akpm@linux-foundation.org \
    --cc=deller@gmx.de \
    --cc=hirofumi@mail.parknet.co.jp \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.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