All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Schmitz <schmitzmic@gmail.com>
To: Linus Torvalds <torvalds@linux-foundation.org>,
	Christoph Hellwig <hch@lst.de>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>,
	linux-m68k <linux-m68k@lists.linux-m68k.org>
Subject: Re: [PATCH RFC v2] m68k: remove get_fs()/set_fs()
Date: Fri, 9 Jul 2021 12:05:14 +1200	[thread overview]
Message-ID: <5217860f-6574-24a3-2c6f-a827ccf3c123@gmail.com> (raw)
In-Reply-To: <CAHk-=wj2j-9g_bkuGPNMfjcs=X1E74h0Zo+zghT86bva8H+5Ng@mail.gmail.com>

Hi Linus,

On 9/07/21 6:20 am, Linus Torvalds wrote:
> On Thu, Jul 8, 2021 at 5:57 AM Christoph Hellwig <hch@lst.de> wrote:
>> I've force pushed a new version to the branch, can you give it a spin?
> Please stop playing broken games with __constant_copy_to_user().
>
> Now you didn't just break the return value, you broke the actual copy
> too. When it is supposed to do a 4-byte copy, the code now does *two*
> 4-byte copies, because that's the way __constant_copy_to_user_asm()
> works - it always does at least two accesses, and then the third one
> is conditional.
>
> So that "6, l, l, )" in
>
>          case 4:
>                  __constant_copy_to_user_asm(res, to, from, tmp, 6, l, l,);
>                  break;
>
> literally means "try to do 2x 'l' sized moves (but not a third one),
> and return 6 if it fails". All of which is very wrong indeed.

In order to get the correct number of bytes copied, the patch would have 
to look like:

        switch (n) {
         case 1:
-               __put_user_asm(res, *(u8 *)from, (u8 __user *)to, b, d, 1);
+               __constant_copy_to_user_asm(res, to, from, tmp, 1, b, );
                 break;
         case 2:
-               __put_user_asm(res, *(u16 *)from, (u16 __user *)to, w, 
r, 2);
+               __constant_copy_to_user_asm(res, to, from, tmp, 2, w, );
                 break;
         case 3:
                 __constant_copy_to_user_asm(res, to, from, tmp, 3, w, b,);
                 break;
         case 4:
-               __put_user_asm(res, *(u32 *)from, (u32 __user *)to, l, 
r, 4);
+               __constant_copy_to_user_asm(res, to, from, tmp, 4, l, );
                 break;

and __constant_copy_to_user_asm() changed to deal with an empty s2 
parameter. Probably too much work.


>
> So commit d36105c942e0 ("m68k: simplify the __constant_copy_to_user
> implementation") is very very broken.

Doesn't appear to matter - though I'll back out those changes to be safe.

Note that in this version, faults in __put_user_asm used from 
__constant_copy_to_user will return -EFAULT, not the remaining number of 
bytes to be copied, which might get confusing for the caller.

Cheers,

     Michael

>
> But the rest looks good to me. Of course, I entirely missed the fact
> that Andreas pointed out - "instr" was inside a string - so who knows
> what I missed this time.
>
>                 Linus

  reply	other threads:[~2021-07-09  0:05 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-08  1:48 [PATCH RFC v2] m68k: remove get_fs()/set_fs() Michael Schmitz
2021-07-08  2:51 ` Linus Torvalds
2021-07-08  3:01   ` Linus Torvalds
2021-07-08  3:37     ` Michael Schmitz
2021-07-08  4:31     ` Christoph Hellwig
2021-07-08  4:33       ` Michael Schmitz
2021-07-08  4:58         ` Christoph Hellwig
2021-07-08  5:48           ` Michael Schmitz
2021-07-08 12:57             ` Christoph Hellwig
2021-07-08 18:20               ` Linus Torvalds
2021-07-09  0:05                 ` Michael Schmitz [this message]
2021-07-08 19:28               ` Michael Schmitz
2021-07-09  0:31                 ` Michael Schmitz
2021-07-09  4:22                   ` Christoph Hellwig
2021-07-09  5:47                     ` Michael Schmitz
2021-07-09  7:29                     ` Geert Uytterhoeven
2021-07-09  8:34                       ` Michael Schmitz
2021-07-09  8:53                         ` Christoph Hellwig
2021-07-09  9:00                           ` Michael Schmitz
2021-07-09 11:20                             ` Geert Uytterhoeven
2021-07-09 19:25                               ` Michael Schmitz
2021-07-09 19:52                                 ` Michael Schmitz
2021-07-09 20:03                                   ` Linus Torvalds
2021-07-09 20:13                                     ` Linus Torvalds
2021-07-09 19:53                                 ` Linus Torvalds
2021-07-09 21:08                                   ` Michael Schmitz
2021-07-09 21:18                                     ` Linus Torvalds
2021-07-10  2:30                                       ` Michael Schmitz
2021-07-09 11:35                           ` Geert Uytterhoeven
2021-07-08  7:36     ` Andreas Schwab
2021-07-08  4:28   ` Christoph Hellwig

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=5217860f-6574-24a3-2c6f-a827ccf3c123@gmail.com \
    --to=schmitzmic@gmail.com \
    --cc=geert@linux-m68k.org \
    --cc=hch@lst.de \
    --cc=linux-m68k@lists.linux-m68k.org \
    --cc=torvalds@linux-foundation.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.