Skip to content

powerpc/lib/sstep: Don't use __{get/put}_user() on kernel addresses

Michael Petlan requested to merge mpetlan/centos-stream-9:my_bz2049226 into main

Bugzilla: https://bugzilla.redhat.com/2049226

upstream

commit e28d0b675056d072f1f11fa644d0efbb016bb7ce Author: Christophe Leroy christophe.leroy@csgroup.eu Date: Thu Sep 16 20:43:36 2021 +0200

description

In the old days, when we didn't have kernel userspace access protection and had set_fs(), it was wise to use __get_user() and friends to read kernel memory.

Nowadays, get_user() and put_user() are granting userspace access and are exclusively for userspace access.

Convert single step emulation functions to user_access_begin() and friends and use unsafe_get_user() and unsafe_put_user().

When addressing kernel addresses, there is no need to open userspace access. And for book3s/32 it is particularly important to no try and open userspace access on kernel address, because that would break the content of kernel space segment registers. No guard has been put against that risk in order to avoid degrading performance.

copy_from_kernel_nofault() and copy_to_kernel_nofault() should be used but they are out-of-line functions which would degrade performance. Those two functions are making use of __get_kernel_nofault() and __put_kernel_nofault() macros. Those two macros are just wrappers behind __get_user_size_goto() and __put_user_size_goto().

unsafe_get_user() and unsafe_put_user() are also wrappers of __get_user_size_goto() and __put_user_size_goto(). Use them to access kernel space. That allows refactoring userspace and kernelspace access.

Depends-on: 4fe5cda9 ("powerpc/uaccess: Implement user_read_access_begin and user_write_access_begin")

Link: https://lore.kernel.org/r/22831c9d17f948680a12c5292e7627288b15f713.1631817805.git.christophe.leroy@csgroup.eu

Signed-off-by: Michael Petlan mpetlan@redhat.com

Merge request reports