ipc/shm: some shmat cleanups
Clean up early flag and address some minutia. Link: http://lkml.kernel.org/r/1486673582-6979-3-git-send-email-dave@stgolabs.net Signed-off-by: Davidlohr Bueso <dbueso@suse.de> Cc: Manfred Spraul <manfred@colorfullife.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
046aa1265f
commit
f0cb88026f
1 changed files with 7 additions and 9 deletions
16
ipc/shm.c
16
ipc/shm.c
|
@ -1095,11 +1095,11 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg,
|
||||||
ulong *raddr, unsigned long shmlba)
|
ulong *raddr, unsigned long shmlba)
|
||||||
{
|
{
|
||||||
struct shmid_kernel *shp;
|
struct shmid_kernel *shp;
|
||||||
unsigned long addr;
|
unsigned long addr = (unsigned long)shmaddr;
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
struct file *file;
|
struct file *file;
|
||||||
int err;
|
int err;
|
||||||
unsigned long flags;
|
unsigned long flags = MAP_SHARED;
|
||||||
unsigned long prot;
|
unsigned long prot;
|
||||||
int acc_mode;
|
int acc_mode;
|
||||||
struct ipc_namespace *ns;
|
struct ipc_namespace *ns;
|
||||||
|
@ -1111,7 +1111,8 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg,
|
||||||
err = -EINVAL;
|
err = -EINVAL;
|
||||||
if (shmid < 0)
|
if (shmid < 0)
|
||||||
goto out;
|
goto out;
|
||||||
else if ((addr = (ulong)shmaddr)) {
|
|
||||||
|
if (addr) {
|
||||||
if (addr & (shmlba - 1)) {
|
if (addr & (shmlba - 1)) {
|
||||||
/*
|
/*
|
||||||
* Round down to the nearest multiple of shmlba.
|
* Round down to the nearest multiple of shmlba.
|
||||||
|
@ -1126,13 +1127,10 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg,
|
||||||
#endif
|
#endif
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
flags = MAP_SHARED | MAP_FIXED;
|
|
||||||
} else {
|
|
||||||
if ((shmflg & SHM_REMAP))
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
flags = MAP_SHARED;
|
flags |= MAP_FIXED;
|
||||||
}
|
} else if ((shmflg & SHM_REMAP))
|
||||||
|
goto out;
|
||||||
|
|
||||||
if (shmflg & SHM_RDONLY) {
|
if (shmflg & SHM_RDONLY) {
|
||||||
prot = PROT_READ;
|
prot = PROT_READ;
|
||||||
|
|
Loading…
Add table
Reference in a new issue