History

Revert "x86/fault: BUG() when uaccess helpers fault on kernel addresses"

This reverts commit 9da3f2b74054406f87dff7101a569217ffceb29b. It was well-intentioned, but wrong. Overriding the exception tables for instructions for random reasons is just wrong, and that is what the new code did. It caused problems for tracing, and it caused problems for strncpy_from_user(), because the new checks made perfectly valid use cases break, rather than catch things that did bad things. Unchecked user space accesses are a problem, but that's not a reason to add invalid checks that then people have to work around with silly flags (in this case, that 'kernel_uaccess_faults_ok' flag, which is just an odd way to say "this commit was wrong" and was sprinked into random places to hide the wrongness). The real fix to unchecked user space accesses is to get rid of the special "let's not check __get_user() and __put_user() at all" logic. Make __{get|put}_user() be just aliases to the regular {get|put}_user() functions, and make it impossible to access user space without having the proper checks in places. The raison d'être of the special double-underscore versions used to be that the range check was expensive, and if you did multiple user accesses, you'd do the range check up front (like the signal frame handling code, for example). But SMAP (on x86) and PAN (on ARM) have made that optimization pointless, because the _real_ expense is the "set CPU flag to allow user space access". Do let's not break the valid cases to catch invalid cases that shouldn't even exist.

Linus Torvalds committed 7 years ago

Commit 53a41cb1 parent 5908e6b4 files · +0 −72Browse files

Showing the changes to include/linux (1 of 4 files). Show all

Unified · Split

include/linux/sched.h+0−6
@@ -739,12 +739,6 @@ struct task_struct { · 738 unmodified lines
739 unsigned use_memdelay:1;739 unsigned use_memdelay:1;
740#endif740#endif
741 741
742 /*
743 * May usercopy functions fault on kernel addresses?
744 * This is not just a single bit because this can potentially nest.
745 */
746 unsigned int kernel_uaccess_faults_ok;
747
748 unsigned long atomic_flags; /* Flags requiring atomic access. */742 unsigned long atomic_flags; /* Flags requiring atomic access. */
749 743
750 struct restart_block restart_block;744 struct restart_block restart_block;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t