Commit 1d252fb8 authored by Ahmed S. Darwish's avatar Ahmed S. Darwish Committed by Linus Torvalds

smack: do not dereference NULL ipc object

In the SYSV ipc msgctl(),semctl(),shmctl() family, if the user passed *_INFO
as the desired operation, no specific object is meant to be controlled and
only system-wide information is returned.  This leads to a NULL IPC object in
the LSM hooks if the _INFO flag is given.

Avoid dereferencing this NULL pointer in Smack ipc *ctl() methods.
Signed-off-by: default avatarAhmed S. Darwish <darwish.07@gmail.com>
Acked-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 4ebf8984
...@@ -1508,7 +1508,7 @@ static int smack_shm_associate(struct shmid_kernel *shp, int shmflg) ...@@ -1508,7 +1508,7 @@ static int smack_shm_associate(struct shmid_kernel *shp, int shmflg)
*/ */
static int smack_shm_shmctl(struct shmid_kernel *shp, int cmd) static int smack_shm_shmctl(struct shmid_kernel *shp, int cmd)
{ {
char *ssp = smack_of_shm(shp); char *ssp;
int may; int may;
switch (cmd) { switch (cmd) {
...@@ -1532,6 +1532,7 @@ static int smack_shm_shmctl(struct shmid_kernel *shp, int cmd) ...@@ -1532,6 +1532,7 @@ static int smack_shm_shmctl(struct shmid_kernel *shp, int cmd)
return -EINVAL; return -EINVAL;
} }
ssp = smack_of_shm(shp);
return smk_curacc(ssp, may); return smk_curacc(ssp, may);
} }
...@@ -1616,7 +1617,7 @@ static int smack_sem_associate(struct sem_array *sma, int semflg) ...@@ -1616,7 +1617,7 @@ static int smack_sem_associate(struct sem_array *sma, int semflg)
*/ */
static int smack_sem_semctl(struct sem_array *sma, int cmd) static int smack_sem_semctl(struct sem_array *sma, int cmd)
{ {
char *ssp = smack_of_sem(sma); char *ssp;
int may; int may;
switch (cmd) { switch (cmd) {
...@@ -1645,6 +1646,7 @@ static int smack_sem_semctl(struct sem_array *sma, int cmd) ...@@ -1645,6 +1646,7 @@ static int smack_sem_semctl(struct sem_array *sma, int cmd)
return -EINVAL; return -EINVAL;
} }
ssp = smack_of_sem(sma);
return smk_curacc(ssp, may); return smk_curacc(ssp, may);
} }
...@@ -1730,7 +1732,7 @@ static int smack_msg_queue_associate(struct msg_queue *msq, int msqflg) ...@@ -1730,7 +1732,7 @@ static int smack_msg_queue_associate(struct msg_queue *msq, int msqflg)
*/ */
static int smack_msg_queue_msgctl(struct msg_queue *msq, int cmd) static int smack_msg_queue_msgctl(struct msg_queue *msq, int cmd)
{ {
char *msp = smack_of_msq(msq); char *msp;
int may; int may;
switch (cmd) { switch (cmd) {
...@@ -1752,6 +1754,7 @@ static int smack_msg_queue_msgctl(struct msg_queue *msq, int cmd) ...@@ -1752,6 +1754,7 @@ static int smack_msg_queue_msgctl(struct msg_queue *msq, int cmd)
return -EINVAL; return -EINVAL;
} }
msp = smack_of_msq(msq);
return smk_curacc(msp, may); return smk_curacc(msp, may);
} }
......
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