ipc/shm: Fix shmat mmap nil-page protection
am: f0ae01568e
Change-Id: I53489954b39ece583120b8462d57a969ab1e972f
This commit is contained in:
commit
75e2698872
1 changed files with 9 additions and 4 deletions
13
ipc/shm.c
13
ipc/shm.c
|
@ -1083,8 +1083,8 @@ out_unlock1:
|
|||
* "raddr" thing points to kernel space, and there has to be a wrapper around
|
||||
* this.
|
||||
*/
|
||||
long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
|
||||
unsigned long shmlba)
|
||||
long do_shmat(int shmid, char __user *shmaddr, int shmflg,
|
||||
ulong *raddr, unsigned long shmlba)
|
||||
{
|
||||
struct shmid_kernel *shp;
|
||||
unsigned long addr;
|
||||
|
@ -1105,8 +1105,13 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
|
|||
goto out;
|
||||
else if ((addr = (ulong)shmaddr)) {
|
||||
if (addr & (shmlba - 1)) {
|
||||
if (shmflg & SHM_RND)
|
||||
addr &= ~(shmlba - 1); /* round down */
|
||||
/*
|
||||
* 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
|
||||
#ifndef __ARCH_FORCE_SHMLBA
|
||||
if (addr & ~PAGE_MASK)
|
||||
|
|
Loading…
Add table
Reference in a new issue