aboutsummaryrefslogtreecommitdiff
path: root/lib/mpi/mpi-sub-ui.c
diff options
context:
space:
mode:
authorKees Cook <[email protected]>2022-09-19 13:16:48 -0700
committerAndrew Morton <[email protected]>2022-09-26 12:14:35 -0700
commit59298997df89e19aad426d4ae0a7e5037074da5a (patch)
treebd519e75ebd1570b528f9c7e3e2741c7d11055ea /lib/mpi/mpi-sub-ui.c
parent80e2b584f3abfc31c3fe5573007f0d1d10810fde (diff)
x86/uaccess: avoid check_object_size() in copy_from_user_nmi()
The check_object_size() helper under CONFIG_HARDENED_USERCOPY is designed to skip any checks where the length is known at compile time as a reasonable heuristic to avoid "likely known-good" cases. However, it can only do this when the copy_*_user() helpers are, themselves, inline too. Using find_vmap_area() requires taking a spinlock. The check_object_size() helper can call find_vmap_area() when the destination is in vmap memory. If show_regs() is called in interrupt context, it will attempt a call to copy_from_user_nmi(), which may call check_object_size() and then find_vmap_area(). If something in normal context happens to be in the middle of calling find_vmap_area() (with the spinlock held), the interrupt handler will hang forever. The copy_from_user_nmi() call is actually being called with a fixed-size length, so check_object_size() should never have been called in the first place. Given the narrow constraints, just replace the __copy_from_user_inatomic() call with an open-coded version that calls only into the sanitizers and not check_object_size(), followed by a call to raw_copy_from_user(). [[email protected]: no instrument_copy_from_user() in my tree...] Link: https://lkml.kernel.org/r/[email protected] Link: https://lore.kernel.org/all/CAOUHufaPshtKrTWOz7T7QFYUNVGFm0JBjvM700Nhf9qEL9b3EQ@mail.gmail.com Fixes: 0aef499f3172 ("mm/usercopy: Detect vmalloc overruns") Signed-off-by: Kees Cook <[email protected]> Reported-by: Yu Zhao <[email protected]> Reported-by: Florian Lehner <[email protected]> Suggested-by: Andrew Morton <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Tested-by: Florian Lehner <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Dave Hansen <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
Diffstat (limited to 'lib/mpi/mpi-sub-ui.c')
0 files changed, 0 insertions, 0 deletions