[PATCH] ARM: uaccess: avoid alignment faults in copy_[from|to]_kernel_nofault

Arnd Bergmann arnd at arndb.de
Tue Jan 18 00:38:31 PST 2022


On Tue, Jan 18, 2022 at 9:28 AM Ard Biesheuvel <ardb at kernel.org> wrote:
>
> The helpers that are used to implement copy_from_kernel_nofault() and
> copy_to_kernel_nofault() cast a void* to a pointer to a wider type,
> which may result in alignment faults on ARM if the compiler decides to
> use double-word or multiple-word load/store instructions.
>
> So use the unaligned accessors where needed: when the type's size > 1
> and the input was not aligned already by the caller.
>
> Cc: <stable at vger.kernel.org>
> Fixes: 2df4c9a741a0 ("ARM: 9112/1: uaccess: add __{get,put}_kernel_nofault")
> Signed-off-by: Ard Biesheuvel <ardb at kernel.org>

Reviewed-by: Arnd Bergmann <arnd at arndb.de>

It took me a bit to see whythis works, maybe mention commit 2423de2e6f4d
("ARM: 9115/1: mm/maccess: fix unaligned copy_{from,to}_kernel_nofault")
in the description for clarification.

Did you run into actual faults, or did you find this problem by
reading the code?

         Arnd



More information about the linux-arm-kernel mailing list