提交 e8148f75 编写于 作者: W WANG Cong 提交者: Linus Torvalds

ipc: clean up ipc/shm.c

Use the macro shm_ids().

Remove useless check for a userspace pointer, because copy_to_user()
will check it.

Some style cleanups.
Signed-off-by: NWANG Cong <wangcong@zeuux.org>
Cc: Nadia Derbey <Nadia.Derbey@bull.net>
Cc: Pierre Peiffer <peifferp@gmail.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 8cd3ac3a
...@@ -75,7 +75,7 @@ void shm_init_ns(struct ipc_namespace *ns) ...@@ -75,7 +75,7 @@ void shm_init_ns(struct ipc_namespace *ns)
ns->shm_ctlall = SHMALL; ns->shm_ctlall = SHMALL;
ns->shm_ctlmni = SHMMNI; ns->shm_ctlmni = SHMMNI;
ns->shm_tot = 0; ns->shm_tot = 0;
ipc_init_ids(&ns->ids[IPC_SHM_IDS]); ipc_init_ids(&shm_ids(ns));
} }
/* /*
...@@ -644,7 +644,7 @@ asmlinkage long sys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf) ...@@ -644,7 +644,7 @@ asmlinkage long sys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf)
if (err) if (err)
return err; return err;
memset(&shminfo,0,sizeof(shminfo)); memset(&shminfo, 0, sizeof(shminfo));
shminfo.shmmni = shminfo.shmseg = ns->shm_ctlmni; shminfo.shmmni = shminfo.shmseg = ns->shm_ctlmni;
shminfo.shmmax = ns->shm_ctlmax; shminfo.shmmax = ns->shm_ctlmax;
shminfo.shmall = ns->shm_ctlall; shminfo.shmall = ns->shm_ctlall;
...@@ -669,7 +669,7 @@ asmlinkage long sys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf) ...@@ -669,7 +669,7 @@ asmlinkage long sys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf)
if (err) if (err)
return err; return err;
memset(&shm_info,0,sizeof(shm_info)); memset(&shm_info, 0, sizeof(shm_info));
down_read(&shm_ids(ns).rw_mutex); down_read(&shm_ids(ns).rw_mutex);
shm_info.used_ids = shm_ids(ns).in_use; shm_info.used_ids = shm_ids(ns).in_use;
shm_get_stat (ns, &shm_info.shm_rss, &shm_info.shm_swp); shm_get_stat (ns, &shm_info.shm_rss, &shm_info.shm_swp);
...@@ -678,7 +678,7 @@ asmlinkage long sys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf) ...@@ -678,7 +678,7 @@ asmlinkage long sys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf)
shm_info.swap_successes = 0; shm_info.swap_successes = 0;
err = ipc_get_maxid(&shm_ids(ns)); err = ipc_get_maxid(&shm_ids(ns));
up_read(&shm_ids(ns).rw_mutex); up_read(&shm_ids(ns).rw_mutex);
if(copy_to_user (buf, &shm_info, sizeof(shm_info))) { if (copy_to_user(buf, &shm_info, sizeof(shm_info))) {
err = -EFAULT; err = -EFAULT;
goto out; goto out;
} }
...@@ -692,11 +692,6 @@ asmlinkage long sys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf) ...@@ -692,11 +692,6 @@ asmlinkage long sys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf)
struct shmid64_ds tbuf; struct shmid64_ds tbuf;
int result; int result;
if (!buf) {
err = -EFAULT;
goto out;
}
if (cmd == SHM_STAT) { if (cmd == SHM_STAT) {
shp = shm_lock(ns, shmid); shp = shm_lock(ns, shmid);
if (IS_ERR(shp)) { if (IS_ERR(shp)) {
...@@ -712,7 +707,7 @@ asmlinkage long sys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf) ...@@ -712,7 +707,7 @@ asmlinkage long sys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf)
} }
result = 0; result = 0;
} }
err=-EACCES; err = -EACCES;
if (ipcperms (&shp->shm_perm, S_IRUGO)) if (ipcperms (&shp->shm_perm, S_IRUGO))
goto out_unlock; goto out_unlock;
err = security_shm_shmctl(shp, cmd); err = security_shm_shmctl(shp, cmd);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册