Re: [PATCH] sh: traps: Fix kernel unaligned access fixup in branch delay slots
From: Arnd Bergmann
Date: Fri Oct 23 2026 - 03:26:32 EST
On Fri, Oct 23, 2026, at 09:15, Geert Uytterhoeven wrote:
> On Fri, 23 Oct 2026 at 09:09, Arnd Bergmann <arnd@xxxxxxxx> wrote:
>> On Fri, Oct 23, 2026, at 01:34, Florian Fuchs wrote:
>> > @@ -287,8 +287,10 @@ static inline int handle_delayslot(struct pt_regs *regs,
>> > insn_size_t instruction;
>> > void __user *addr = (void __user *)(regs->pc +
>> > instruction_size(old_instruction));
>> > + struct mem_access *insn_ma = user_mode(regs) ?
>> > + &user_mem_access : &kernel_mem_access;
>> >
>> > - if (copy_from_user(&instruction, addr, sizeof(instruction))) {
>> > + if (insn_ma->from(&instruction, addr, sizeof(instruction))) {
>> > /* the instruction-fetch faulted */
>> > if (user_mode(regs))
>> > return -EFAULT;
>>
>> The "insn_ma" pointer is always the same as the 'ma' argument
>> you already pass, as both are set based on 'user_mode(regs)'.
>> Why not just use the pointer you already have?
>
> That would also handle handle_trapped_io(), which passes
> &trapped_io_access, right?
Indeed, that would be bad. The patch looks fine then.
Acked-by: Arnd Bergmann <arnd@xxxxxxxx>