shmat() for 0 (or <PAGESIZE with RND flag) has to fail with REMAPs
PATCH 1/1 shmat() for 0 (or <PAGESIZE with RND flag) has to fail with REMAPs
From: Rafael David Tinoco <[email protected]>
According to upstream thread (https://lkml.org/lkml/2018/5/28/2056),
cve-2017-5669 needs to address the "new" way of handling nil addresses for shmat() when used with MAP_FIXED or SHM_REMAP flags.
- mapping nil-page is OK on lower addresses with MAP_FIXED (or else X11 is broken)
- mapping nil-page is NOT OK with SHM_REMAP on lower addresses
Addresses Davidlohr Bueso's comments/changes:
commit 8f89c007b6de
Author: Davidlohr Bueso <[email protected]> Date: Fri May 25 14:47:30 2018 -0700
ipc/shm: fix shmat() nil address after round-down when remapping
commit a73ab244f0da
Author: Davidlohr Bueso <[email protected]> Date: Fri May 25 14:47:27 2018 -0700
Revert "ipc/shm: Fix shmat mmap nil-page protection"
For previously test made based on:
commit 95e91b831f87
Author: Davidlohr Bueso <[email protected]> Date: Mon Feb 27 14:28:24 2017 -0800
ipc/shm: Fix shmat mmap nil-page protection
--- testcases/cve/cve-2017-5669.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
testcases/cve/cve-2017-5669.c +8 -1
@@ -28,6 +28,9 @@* is just to see if we get an access error or some other unexpected behaviour. * * See commit 95e91b831f (ipc/shm: Fix shmat mmap nil-page protection) +* See commit a73ab244f0da (Revert "ipc/shm: Fix shmat mmap nil-page protect...) +* See commit 8f89c007b6de (ipc/shm: fix shmat() nil address after round-dow...) +* See https://github.com/linux-test-project/ltp/issues/319 */ #include <sys/types.h> #include <sys/ipc.h>
@@ -60,7 +63,11 @@ static void cleanup(void)static void run (void ) {tst_res (TINFO ,"Attempting to attach shared memory to null page" ); - shm_addr =shmat (shm_id, ((void *)1 ),SHM_RND ); +/* +* shmat() for 0 (or < PAGESIZE with RND flag) has to fail with REMAPs +* https://github.com/linux-test-project/ltp/issues/319 +*/ + shm_addr =shmat (shm_id, ((void *)1 ),SHM_RND |SHM_REMAP );if (shm_addr == (void *)-1 ) { shm_addr =NULL ;if (errno ==EINVAL ) {
Signature · 1 line
2.17.1
PATCH 1/1 shmat() for 0 (or <PAGESIZE with RND flag) has to fail with REMAPs
Please consider From: Rafael David Tinoco <[email protected]>
Quoted 69 lines · Rafael David Tinoco
From: Rafael David Tinoco <[email protected]>
According to upstream thread (https://lkml.org/lkml/2018/5/28/2056),
cve-2017-5669 needs to address the "new" way of handling nil addresses forshmat()when used withMAP_FIXEDorSHM_REMAPflags.- mapping nil-page is OK on lower addresses with
MAP_FIXED(or else X11 is broken)
- mapping nil-page is NOT OK withSHM_REMAPon lower addressesAddresses Davidlohr Bueso's comments/changes:
commit
8f89c007b6deAuthor: Davidlohr Bueso <[email protected]> Date: Fri May 25 14:47:30 2018 -0700ipc/shm: fix
shmat()nil address after round-down when remappingcommit
a73ab244f0daAuthor: Davidlohr Bueso <[email protected]> Date: Fri May 25 14:47:27 2018 -0700Revert "ipc/shm: Fix shmat mmap nil-page protection"
For previously test made based on:
commit
95e91b831f87Author: Davidlohr Bueso <[email protected]> Date: Mon Feb 27 14:28:24 2017 -0800ipc/shm: Fix shmat mmap nil-page protection
Signed-off-by Rafael David Tinoco <[email protected]>---
testcases/cve/cve-2017-5669.c| 9 ++++++++-1 file changed, 8 insertions(+), 1 deletion(-)testcases/cve/cve-2017-5669.c +8
-1@@ -28,6 +28,9 @@* is just to see if we get an access error or some other unexpected behaviour. * * See commit 95e91b831f (ipc/shm: Fix shmat mmap nil-page protection) +* See commit a73ab244f0da (Revert "ipc/shm: Fix shmat mmap nil-page protect...) +* See commit 8f89c007b6de (ipc/shm: fix shmat() nil address after round-dow...) +* See https://github.com/linux-test-project/ltp/issues/319 */ #include <sys/types.h> #include <sys/ipc.h> @@ -60,7 +63,11 @@ static void cleanup(void)static void run (void ) {tst_res (TINFO ,"Attempting to attach shared memory to null page" ); - shm_addr =shmat (shm_id, ((void *)1 ),SHM_RND ); +/* +* shmat() for 0 (or < PAGESIZE with RND flag) has to fail with REMAPs +* https://github.com/linux-test-project/ltp/issues/319 +*/ + shm_addr =shmat (shm_id, ((void *)1 ),SHM_RND |SHM_REMAP );if (shm_addr == (void *)-1 ) { shm_addr =NULL ;if (errno ==EINVAL ) {Signature · 1 line
2.17.1
PATCH 1/1 shmat() for 0 (or <PAGESIZE with RND flag) has to fail with REMAPs
In reply to Rafael David Tinoco----- Original Message -----
Quoted 4 lines
From: Rafael David Tinoco <[email protected]>
Updated patch (submitted on github as pull request) has been pushed.
Regards,
Jan