aboutsummaryrefslogtreecommitdiff
path: root/net/lapb/lapb_in.c
diff options
context:
space:
mode:
authorDave Hansen <[email protected]>2019-01-02 13:56:55 -0800
committerThomas Gleixner <[email protected]>2019-01-15 10:33:45 +0100
commita31e184e4f69965c99c04cc5eb8a4920e0c63737 (patch)
tree41cdfacc6ef3adb6c7cd0c283770cf2e79531de5 /net/lapb/lapb_in.c
parent7e6fc2f50a3197d0e82d1c0e86282976c9e6c8a4 (diff)
x86/pkeys: Properly copy pkey state at fork()
Memory protection key behavior should be the same in a child as it was in the parent before a fork. But, there is a bug that resets the state in the child at fork instead of preserving it. The creation of new mm's is a bit convoluted. At fork(), the code does: 1. memcpy() the parent mm to initialize child 2. mm_init() to initalize some select stuff stuff 3. dup_mmap() to create true copies that memcpy() did not do right For pkeys two bits of state need to be preserved across a fork: 'execute_only_pkey' and 'pkey_allocation_map'. Those are preserved by the memcpy(), but mm_init() invokes init_new_context() which overwrites 'execute_only_pkey' and 'pkey_allocation_map' with "new" values. The author of the code erroneously believed that init_new_context is *only* called at execve()-time. But, alas, init_new_context() is used at execve() and fork(). The result is that, after a fork(), the child's pkey state ends up looking like it does after an execve(), which is totally wrong. pkeys that are already allocated can be allocated again, for instance. To fix this, add code called by dup_mmap() to copy the pkey state from parent to child explicitly. Also add a comment above init_new_context() to make it more clear to the next poor sod what this code is used for. Fixes: e8c24d3a23a ("x86/pkeys: Allocation/free syscalls") Signed-off-by: Dave Hansen <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Thomas Gleixner <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: Borislav Petkov <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Will Deacon <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Joerg Roedel <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
Diffstat (limited to 'net/lapb/lapb_in.c')
0 files changed, 0 insertions, 0 deletions