Commit 8fcdd673 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

LSM: move struct shmid_kernel out of ipc/shm.c to include/linux/shm.h

Also move where we set sma->sem_perm.mode and .key to before ipc_addid() gets called.
parent daf90caf
...@@ -71,6 +71,19 @@ struct shm_info { ...@@ -71,6 +71,19 @@ struct shm_info {
}; };
#ifdef __KERNEL__ #ifdef __KERNEL__
struct shmid_kernel /* private to the kernel */
{
struct kern_ipc_perm shm_perm;
struct file * shm_file;
int id;
unsigned long shm_nattch;
unsigned long shm_segsz;
time_t shm_atim;
time_t shm_dtim;
time_t shm_ctim;
pid_t shm_cprid;
pid_t shm_lprid;
};
/* shm_mode upper byte flags */ /* shm_mode upper byte flags */
#define SHM_DEST 01000 /* segment will be destroyed on last detach */ #define SHM_DEST 01000 /* segment will be destroyed on last detach */
......
...@@ -129,6 +129,10 @@ static int newary (key_t key, int nsems, int semflg) ...@@ -129,6 +129,10 @@ static int newary (key_t key, int nsems, int semflg)
return -ENOMEM; return -ENOMEM;
} }
memset (sma, 0, size); memset (sma, 0, size);
sma->sem_perm.mode = (semflg & S_IRWXUGO);
sma->sem_perm.key = key;
id = ipc_addid(&sem_ids, &sma->sem_perm, sc_semmni); id = ipc_addid(&sem_ids, &sma->sem_perm, sc_semmni);
if(id == -1) { if(id == -1) {
ipc_free(sma, size); ipc_free(sma, size);
...@@ -136,9 +140,6 @@ static int newary (key_t key, int nsems, int semflg) ...@@ -136,9 +140,6 @@ static int newary (key_t key, int nsems, int semflg)
} }
used_sems += nsems; used_sems += nsems;
sma->sem_perm.mode = (semflg & S_IRWXUGO);
sma->sem_perm.key = key;
sma->sem_base = (struct sem *) &sma[1]; sma->sem_base = (struct sem *) &sma[1];
/* sma->sem_pending = NULL; */ /* sma->sem_pending = NULL; */
sma->sem_pending_last = &sma->sem_pending; sma->sem_pending_last = &sma->sem_pending;
......
...@@ -28,20 +28,6 @@ ...@@ -28,20 +28,6 @@
#include "util.h" #include "util.h"
struct shmid_kernel /* private to the kernel */
{
struct kern_ipc_perm shm_perm;
struct file * shm_file;
int id;
unsigned long shm_nattch;
unsigned long shm_segsz;
time_t shm_atim;
time_t shm_dtim;
time_t shm_ctim;
pid_t shm_cprid;
pid_t shm_lprid;
};
#define shm_flags shm_perm.mode #define shm_flags shm_perm.mode
static struct file_operations shm_file_operations; static struct file_operations shm_file_operations;
...@@ -193,6 +179,10 @@ static int newseg (key_t key, int shmflg, size_t size) ...@@ -193,6 +179,10 @@ static int newseg (key_t key, int shmflg, size_t size)
shp = (struct shmid_kernel *) kmalloc (sizeof (*shp), GFP_USER); shp = (struct shmid_kernel *) kmalloc (sizeof (*shp), GFP_USER);
if (!shp) if (!shp)
return -ENOMEM; return -ENOMEM;
shp->shm_perm.key = key;
shp->shm_flags = (shmflg & S_IRWXUGO);
sprintf (name, "SYSV%08x", key); sprintf (name, "SYSV%08x", key);
file = shmem_file_setup(name, size); file = shmem_file_setup(name, size);
error = PTR_ERR(file); error = PTR_ERR(file);
...@@ -203,8 +193,7 @@ static int newseg (key_t key, int shmflg, size_t size) ...@@ -203,8 +193,7 @@ static int newseg (key_t key, int shmflg, size_t size)
id = shm_addid(shp); id = shm_addid(shp);
if(id == -1) if(id == -1)
goto no_id; goto no_id;
shp->shm_perm.key = key;
shp->shm_flags = (shmflg & S_IRWXUGO);
shp->shm_cprid = current->pid; shp->shm_cprid = current->pid;
shp->shm_lprid = 0; shp->shm_lprid = 0;
shp->shm_atim = shp->shm_dtim = 0; shp->shm_atim = shp->shm_dtim = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment