diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2018-08-16 11:10:56 -0700 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2018-08-16 11:10:56 -0700 |
commit | 13fe7056bebb4015c6231a07a1be4d3aebbfe979 (patch) | |
tree | 8aefa59a61c081c402bc85f2b47c17e1374eabdd /ipc/shm.c | |
parent | ed9800100f1a70154c11cfa0ccc0b9ff51e3436a (diff) | |
parent | 100294cee9a98bfd4d6cb2d1c8a8aef0e959b0c4 (diff) | |
download | linux-13fe7056bebb4015c6231a07a1be4d3aebbfe979.tar.bz2 |
Merge branch 'next' into for-linus
Prepare input updates for 4.19 merge window.
Diffstat (limited to 'ipc/shm.c')
-rw-r--r-- | ipc/shm.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/ipc/shm.c b/ipc/shm.c index 3cf48988d68c..d73269381ec7 100644 --- a/ipc/shm.c +++ b/ipc/shm.c @@ -1363,14 +1363,17 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, if (addr) { if (addr & (shmlba - 1)) { - /* - * Round down to the nearest multiple of shmlba. - * For sane do_mmap_pgoff() parameters, avoid - * round downs that trigger nil-page and MAP_FIXED. - */ - if ((shmflg & SHM_RND) && addr >= shmlba) - addr &= ~(shmlba - 1); - else + if (shmflg & SHM_RND) { + addr &= ~(shmlba - 1); /* round down */ + + /* + * Ensure that the round-down is non-nil + * when remapping. This can happen for + * cases when addr < shmlba. + */ + if (!addr && (shmflg & SHM_REMAP)) + goto out; + } else #ifndef __ARCH_FORCE_SHMLBA if (addr & ~PAGE_MASK) #endif |