From: Michael Schmitz <schmitzmic@gmail.com>
To: Finn Thain <fthain@linux-m68k.org>
Cc: linux-m68k@vger.kernel.org, geert@linux-m68k.org,
gerg@linux-m68k.org, linux-m68k@lists.linux-m68k.org
Subject: Re: [PATCH v3 1/2] m68k: Handle __generic_copy_to_user faults more carefully
Date: Sun, 28 Apr 2024 15:51:37 +1200 [thread overview]
Message-ID: <314aaa18-e28c-851c-d746-10ecc46eed04@gmail.com> (raw)
In-Reply-To: <95677826-e3cb-9c1d-7d03-253a88aff3eb@linux-m68k.org>
Hi Finn,
Am 28.04.2024 um 15:28 schrieb Finn Thain:
> On Sun, 28 Apr 2024, Michael Schmitz wrote:
>
>> In my tests, the fault seen there had been caused by the movesl in the
>> section above, hence the fixup at 20b.
>>
>
> Well, that was my point. A fault at MOVE.W should get fixed up at 20b, not
> 50b. So the patch is wrong, isn't it?
You are correct there - the fault may have happened while there still
were longwords to transfer, even though the fault PC is after the loop.
The residual from the loop must be taken into account. I'll fix that.
>>>
>>> Should we put a NOP here to avoid having the unknown next instruction
>>> (label 9) in the exception table? We can't actually fix up a fault
>>> there unless by chance it was the MOVES that caused it.
>>
>> ... As to the unknown instructions following the final exception label:
>> These functions, though they contain inline assembly code are not
>> further inlined, and the instructions following the inline assembly are
>> simple boilerplate register restore stack saves that ought not to fault
>> (an invalid stack pointer would have faulted on function entry, if at
>> all).
>>
>
> But that's just luck. IMHO, the asm is a foot-gun even if it has not gone
> off yet.
If the compiler were to inline the entire function, that could happen,
yes. So for that reason, the NOP would be safer.
>
>> On balance, I am confident the code is correct as-is. You (and in
>> particular, Geert) may argue though that the NOP approach follows the
>> principle of least surprises, and can be considered safe to apply
>> without further testing on 68060 and Coldfire.
>>
>
> If you're saying that your patch addresses a different bug, fair enough.
Nah, I was just speculating that instead of bloating the exception table
(and risking to miss a bad kernel address as source of the transfer),
addition of NOPs might be considered the safer option.
>
> All I'm saying is that, since you're adding the NOP anyway, you could make
> better use of it.
I already am, in __generic_copy_to_user - there is no exception table
entry for the jump label at the end, so no loop.
Since I have to fix patch 1 anyway, I'll add the NOP at the end of
__clear_user and have the exception table end with that NOP.
> Anyway, like you, I am keen to hear from others regarding the API issue.
Too true ...
Cheers,
Michael
next prev parent reply other threads:[~2024-04-28 3:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-27 8:48 [PATCH v3 0/2] m68k uaccess fault handling fixes Michael Schmitz
2024-04-27 8:48 ` [PATCH v3 1/2] m68k: Handle __generic_copy_to_user faults more carefully Michael Schmitz
2024-04-27 9:34 ` Finn Thain
2024-04-27 23:16 ` Michael Schmitz
2024-04-28 3:28 ` Finn Thain
2024-04-28 3:51 ` Michael Schmitz [this message]
2024-04-28 8:03 ` Finn Thain
2024-04-27 8:48 ` [PATCH v3 2/2] m68k: improve __constant_copy_to_user_asm() fault handling Michael Schmitz
2024-04-27 9:24 ` Finn Thain
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=314aaa18-e28c-851c-d746-10ecc46eed04@gmail.com \
--to=schmitzmic@gmail.com \
--cc=fthain@linux-m68k.org \
--cc=geert@linux-m68k.org \
--cc=gerg@linux-m68k.org \
--cc=linux-m68k@lists.linux-m68k.org \
--cc=linux-m68k@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