From: Andy P. <at...@us...> - 2002-04-09 16:32:49
|
Update of /cvsroot/linux-vax/kernel-2.4/ipc In directory usw-pr-cvs1:/tmp/cvs-serv3087 Modified Files: msg.c sem.c shm.c util.c Log Message: synch 2.4.15 commit 22 Index: msg.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/ipc/msg.c,v retrieving revision 1.1.1.2 retrieving revision 1.2 diff -u -r1.1.1.2 -r1.2 --- msg.c 25 Feb 2001 23:14:57 -0000 1.1.1.2 +++ msg.c 9 Apr 2002 16:32:44 -0000 1.2 @@ -613,7 +613,7 @@ wake_up_process(msr->r_tsk); } else { msr->r_msg = msg; - msq->q_lspid = msr->r_tsk->pid; + msq->q_lrpid = msr->r_tsk->pid; msq->q_rtime = CURRENT_TIME; wake_up_process(msr->r_tsk); return 1; @@ -683,6 +683,9 @@ goto retry; } + msq->q_lspid = current->pid; + msq->q_stime = CURRENT_TIME; + if(!pipelined_send(msq,msg)) { /* noone is waiting for this message, enqueue it */ list_add_tail(&msg->m_list,&msq->q_messages); @@ -694,8 +697,6 @@ err = 0; msg = NULL; - msq->q_lspid = current->pid; - msq->q_stime = CURRENT_TIME; out_unlock_free: msg_unlock(msqid); @@ -742,6 +743,10 @@ if(msq==NULL) return -EINVAL; retry: + err = -EIDRM; + if (msg_checkid(msq,msqid)) + goto out_unlock; + err=-EACCES; if (ipcperms (&msq->q_perm, S_IRUGO)) goto out_unlock; Index: sem.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/ipc/sem.c,v retrieving revision 1.1.1.2 retrieving revision 1.2 diff -u -r1.1.1.2 -r1.2 --- sem.c 25 Feb 2001 23:14:57 -0000 1.1.1.2 +++ sem.c 9 Apr 2002 16:32:44 -0000 1.2 @@ -53,6 +53,8 @@ * * SMP-threaded, sysctl's added * (c) 1999 Manfred Spraul <man...@co...> + * Enforced range limit on SEM_UNDO + * (c) 2001 Red Hat Inc <al...@re...> */ #include <linux/config.h> @@ -256,8 +258,19 @@ curr->sempid = (curr->sempid << 16) | pid; curr->semval += sem_op; if (sop->sem_flg & SEM_UNDO) - un->semadj[sop->sem_num] -= sem_op; - + { + int undo = un->semadj[sop->sem_num] - sem_op; + /* + * Exceeding the undo range is an error. + */ + if (undo < (-SEMAEM - 1) || undo > SEMAEM) + { + /* Don't undo the undo */ + sop->sem_flg &= ~SEM_UNDO; + goto out_of_range; + } + un->semadj[sop->sem_num] = undo; + } if (curr->semval < 0) goto would_block; if (curr->semval > SEMVMX) Index: shm.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/ipc/shm.c,v retrieving revision 1.1.1.2 retrieving revision 1.2 diff -u -r1.1.1.2 -r1.2 --- shm.c 25 Feb 2001 23:14:57 -0000 1.1.1.2 +++ shm.c 9 Apr 2002 16:32:44 -0000 1.2 @@ -71,7 +71,9 @@ void __init shm_init (void) { ipc_init_ids(&shm_ids, 1); +#ifdef CONFIG_PROC_FS create_proc_read_entry("sysvipc/shm", 0, 0, sysvipc_shm_read_proc, NULL); +#endif } static inline int shm_checkid(struct shmid_kernel *s, int id) @@ -346,6 +348,7 @@ static void shm_get_stat (unsigned long *rss, unsigned long *swp) { + struct shmem_inode_info *info; int i; *rss = 0; @@ -359,10 +362,11 @@ if(shp == NULL) continue; inode = shp->shm_file->f_dentry->d_inode; - spin_lock (&inode->u.shmem_i.lock); + info = SHMEM_I(inode); + spin_lock (&info->lock); *rss += inode->i_mapping->nrpages; - *swp += inode->u.shmem_i.swapped; - spin_unlock (&inode->u.shmem_i.lock); + *swp += info->swapped; + spin_unlock (&info->lock); } } @@ -495,14 +499,21 @@ if (shp == NULL) goto out_up; err = shm_checkid(shp, shmid); - if (err == 0) { - if (shp->shm_nattch){ - shp->shm_flags |= SHM_DEST; - /* Do not find it any more */ - shp->shm_perm.key = IPC_PRIVATE; - } else - shm_destroy (shp); + if(err) + goto out_unlock_up; + if (current->euid != shp->shm_perm.uid && + current->euid != shp->shm_perm.cuid && + !capable(CAP_SYS_ADMIN)) { + err=-EPERM; + goto out_unlock_up; } + if (shp->shm_nattch){ + shp->shm_flags |= SHM_DEST; + /* Do not find it any more */ + shp->shm_perm.key = IPC_PRIVATE; + } else + shm_destroy (shp); + /* Unlock */ shm_unlock(shmid); up(&shm_ids.sem); @@ -597,6 +608,11 @@ shp = shm_lock(shmid); if(shp == NULL) return -EINVAL; + err = shm_checkid(shp,shmid); + if (err) { + shm_unlock(shmid); + return err; + } if (ipcperms(&shp->shm_perm, acc_mode)) { shm_unlock(shmid); return -EACCES; @@ -605,9 +621,9 @@ shp->shm_nattch++; shm_unlock(shmid); - down(¤t->mm->mmap_sem); + down_write(¤t->mm->mmap_sem); user_addr = (void *) do_mmap (file, addr, file->f_dentry->d_inode->i_size, prot, flags, 0); - up(¤t->mm->mmap_sem); + up_write(¤t->mm->mmap_sem); down (&shm_ids.sem); if(!(shp = shm_lock(shmid))) @@ -636,14 +652,14 @@ struct mm_struct *mm = current->mm; struct vm_area_struct *shmd, *shmdnext; - down(&mm->mmap_sem); + down_write(&mm->mmap_sem); for (shmd = mm->mmap; shmd; shmd = shmdnext) { shmdnext = shmd->vm_next; if (shmd->vm_ops == &shm_vm_ops && shmd->vm_start - (shmd->vm_pgoff << PAGE_SHIFT) == (ulong) shmaddr) do_munmap(mm, shmd->vm_start, shmd->vm_end - shmd->vm_start); } - up(&mm->mmap_sem); + up_write(&mm->mmap_sem); return 0; } Index: util.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/ipc/util.c,v retrieving revision 1.1.1.2 retrieving revision 1.2 diff -u -r1.1.1.2 -r1.2 --- util.c 25 Feb 2001 23:14:57 -0000 1.1.1.2 +++ util.c 9 Apr 2002 16:32:44 -0000 1.2 @@ -75,7 +75,7 @@ ids->size = 0; } ids->ary = SPIN_LOCK_UNLOCKED; - for(i=0;i<size;i++) + for(i=0;i<ids->size;i++) ids->entries[i].p = NULL; } |