ipc/shm: fix shmat() nil address after round-down when remapping
authorDavidlohr Bueso <[email protected]>
Fri, 25 May 2018 21:47:30 +0000 (14:47 -0700)
committerLinus Torvalds <[email protected]>
Sat, 26 May 2018 01:12:11 +0000 (18:12 -0700)
commit8f89c007b6dec16a1793cb88de88fcc02117bbbc
tree8fad454a036ae457f9329d884687da84ff2c5746
parenta73ab244f0dad8fffb3291b905f73e2d3eaa7c00
ipc/shm: fix shmat() nil address after round-down when remapping

shmat()'s SHM_REMAP option forbids passing a nil address for; this is in
fact the very first thing we check for.  Andrea reported that for
SHM_RND|SHM_REMAP cases we can end up bypassing the initial addr check,
but we need to check again if the address was rounded down to nil.  As
of this patch, such cases will return -EINVAL.

Link: http://lkml.kernel.org/r/20180503204934.kk63josdu6u53fbd@linux-n805
Signed-off-by: Davidlohr Bueso <[email protected]>
Reported-by: Andrea Arcangeli <[email protected]>
Cc: Joe Lawrence <[email protected]>
Cc: Manfred Spraul <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
ipc/shm.c