Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 120703
b: refs/heads/master
c: 414c070
h: refs/heads/master
i:
  120701: 23861ab
  120699: 38e5b1c
  120695: 627b3f3
  120687: 5767ff5
  120671: e4fdda6
  120639: e031fcd
  120575: 5667568
v: v3
  • Loading branch information
David Howells authored and James Morris committed Nov 13, 2008
1 parent 1d724d1 commit ece08ef
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: da9592edebceeba1b9301beafe80ec8b9c2db0ce
refs/heads/master: 414c0708d0d60eccf8345c405ac81cf32c43e901
6 changes: 3 additions & 3 deletions trunk/ipc/mqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ static struct inode *mqueue_get_inode(struct super_block *sb, int mode,
inode = new_inode(sb);
if (inode) {
inode->i_mode = mode;
inode->i_uid = current->fsuid;
inode->i_gid = current->fsgid;
inode->i_uid = current_fsuid();
inode->i_gid = current_fsgid();
inode->i_blocks = 0;
inode->i_mtime = inode->i_ctime = inode->i_atime =
CURRENT_TIME;
Expand Down Expand Up @@ -507,7 +507,7 @@ static void __do_notify(struct mqueue_inode_info *info)
sig_i.si_code = SI_MESGQ;
sig_i.si_value = info->notify.sigev_value;
sig_i.si_pid = task_tgid_vnr(current);
sig_i.si_uid = current->uid;
sig_i.si_uid = current_uid();

kill_pid_info(info->notify.sigev_signo,
&sig_i, info->notify_owner);
Expand Down
5 changes: 3 additions & 2 deletions trunk/ipc/shm.c
Original file line number Diff line number Diff line change
Expand Up @@ -752,9 +752,10 @@ asmlinkage long sys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf)
goto out_unlock;

if (!capable(CAP_IPC_LOCK)) {
uid_t euid = current_euid();
err = -EPERM;
if (current->euid != shp->shm_perm.uid &&
current->euid != shp->shm_perm.cuid)
if (euid != shp->shm_perm.uid &&
euid != shp->shm_perm.cuid)
goto out_unlock;
if (cmd == SHM_LOCK &&
!current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur)
Expand Down
18 changes: 13 additions & 5 deletions trunk/ipc/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ int ipc_get_maxid(struct ipc_ids *ids)

int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size)
{
uid_t euid;
gid_t egid;
int id, err;

if (size > IPCMNI)
Expand All @@ -272,8 +274,9 @@ int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size)

ids->in_use++;

new->cuid = new->uid = current->euid;
new->gid = new->cgid = current->egid;
current_euid_egid(&euid, &egid);
new->cuid = new->uid = euid;
new->gid = new->cgid = egid;

new->seq = ids->seq++;
if(ids->seq > ids->seq_max)
Expand Down Expand Up @@ -616,13 +619,15 @@ void ipc_rcu_putref(void *ptr)

int ipcperms (struct kern_ipc_perm *ipcp, short flag)
{ /* flag will most probably be 0 or S_...UGO from <linux/stat.h> */
uid_t euid = current_euid();
int requested_mode, granted_mode, err;

if (unlikely((err = audit_ipc_obj(ipcp))))
return err;
requested_mode = (flag >> 6) | (flag >> 3) | flag;
granted_mode = ipcp->mode;
if (current->euid == ipcp->cuid || current->euid == ipcp->uid)
if (euid == ipcp->cuid ||
euid == ipcp->uid)
granted_mode >>= 6;
else if (in_group_p(ipcp->cgid) || in_group_p(ipcp->gid))
granted_mode >>= 3;
Expand Down Expand Up @@ -784,6 +789,7 @@ struct kern_ipc_perm *ipcctl_pre_down(struct ipc_ids *ids, int id, int cmd,
struct ipc64_perm *perm, int extra_perm)
{
struct kern_ipc_perm *ipcp;
uid_t euid;
int err;

down_write(&ids->rw_mutex);
Expand All @@ -803,8 +809,10 @@ struct kern_ipc_perm *ipcctl_pre_down(struct ipc_ids *ids, int id, int cmd,
if (err)
goto out_unlock;
}
if (current->euid == ipcp->cuid ||
current->euid == ipcp->uid || capable(CAP_SYS_ADMIN))

euid = current_euid();
if (euid == ipcp->cuid ||
euid == ipcp->uid || capable(CAP_SYS_ADMIN))
return ipcp;

err = -EPERM;
Expand Down

0 comments on commit ece08ef

Please sign in to comment.