diff options
Diffstat (limited to 'ipc')
| -rw-r--r-- | ipc/mqueue.c | 9 | ||||
| -rw-r--r-- | ipc/msg.c | 1 | ||||
| -rw-r--r-- | ipc/sem.c | 1 | ||||
| -rw-r--r-- | ipc/shm.c | 41 | ||||
| -rw-r--r-- | ipc/util.c | 1 |
5 files changed, 32 insertions, 21 deletions
diff --git a/ipc/mqueue.c b/ipc/mqueue.c index c8943b53d8e6..4e776f9c80e7 100644 --- a/ipc/mqueue.c +++ b/ipc/mqueue.c | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | * This file is released under the GPL. | 11 | * This file is released under the GPL. |
| 12 | */ | 12 | */ |
| 13 | 13 | ||
| 14 | #include <linux/capability.h> | ||
| 14 | #include <linux/init.h> | 15 | #include <linux/init.h> |
| 15 | #include <linux/pagemap.h> | 16 | #include <linux/pagemap.h> |
| 16 | #include <linux/file.h> | 17 | #include <linux/file.h> |
| @@ -660,7 +661,7 @@ asmlinkage long sys_mq_open(const char __user *u_name, int oflag, mode_t mode, | |||
| 660 | if (fd < 0) | 661 | if (fd < 0) |
| 661 | goto out_putname; | 662 | goto out_putname; |
| 662 | 663 | ||
| 663 | down(&mqueue_mnt->mnt_root->d_inode->i_sem); | 664 | mutex_lock(&mqueue_mnt->mnt_root->d_inode->i_mutex); |
| 664 | dentry = lookup_one_len(name, mqueue_mnt->mnt_root, strlen(name)); | 665 | dentry = lookup_one_len(name, mqueue_mnt->mnt_root, strlen(name)); |
| 665 | if (IS_ERR(dentry)) { | 666 | if (IS_ERR(dentry)) { |
| 666 | error = PTR_ERR(dentry); | 667 | error = PTR_ERR(dentry); |
| @@ -697,7 +698,7 @@ out_putfd: | |||
| 697 | out_err: | 698 | out_err: |
| 698 | fd = error; | 699 | fd = error; |
| 699 | out_upsem: | 700 | out_upsem: |
| 700 | up(&mqueue_mnt->mnt_root->d_inode->i_sem); | 701 | mutex_unlock(&mqueue_mnt->mnt_root->d_inode->i_mutex); |
| 701 | out_putname: | 702 | out_putname: |
| 702 | putname(name); | 703 | putname(name); |
| 703 | return fd; | 704 | return fd; |
| @@ -714,7 +715,7 @@ asmlinkage long sys_mq_unlink(const char __user *u_name) | |||
| 714 | if (IS_ERR(name)) | 715 | if (IS_ERR(name)) |
| 715 | return PTR_ERR(name); | 716 | return PTR_ERR(name); |
| 716 | 717 | ||
| 717 | down(&mqueue_mnt->mnt_root->d_inode->i_sem); | 718 | mutex_lock(&mqueue_mnt->mnt_root->d_inode->i_mutex); |
| 718 | dentry = lookup_one_len(name, mqueue_mnt->mnt_root, strlen(name)); | 719 | dentry = lookup_one_len(name, mqueue_mnt->mnt_root, strlen(name)); |
| 719 | if (IS_ERR(dentry)) { | 720 | if (IS_ERR(dentry)) { |
| 720 | err = PTR_ERR(dentry); | 721 | err = PTR_ERR(dentry); |
| @@ -735,7 +736,7 @@ out_err: | |||
| 735 | dput(dentry); | 736 | dput(dentry); |
| 736 | 737 | ||
| 737 | out_unlock: | 738 | out_unlock: |
| 738 | up(&mqueue_mnt->mnt_root->d_inode->i_sem); | 739 | mutex_unlock(&mqueue_mnt->mnt_root->d_inode->i_mutex); |
| 739 | putname(name); | 740 | putname(name); |
| 740 | if (inode) | 741 | if (inode) |
| 741 | iput(inode); | 742 | iput(inode); |
| @@ -15,6 +15,7 @@ | |||
| 15 | * (c) 1999 Manfred Spraul <manfreds@colorfullife.com> | 15 | * (c) 1999 Manfred Spraul <manfreds@colorfullife.com> |
| 16 | */ | 16 | */ |
| 17 | 17 | ||
| 18 | #include <linux/capability.h> | ||
| 18 | #include <linux/config.h> | 19 | #include <linux/config.h> |
| 19 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
| 20 | #include <linux/msg.h> | 21 | #include <linux/msg.h> |
| @@ -73,6 +73,7 @@ | |||
| 73 | #include <linux/security.h> | 73 | #include <linux/security.h> |
| 74 | #include <linux/syscalls.h> | 74 | #include <linux/syscalls.h> |
| 75 | #include <linux/audit.h> | 75 | #include <linux/audit.h> |
| 76 | #include <linux/capability.h> | ||
| 76 | #include <linux/seq_file.h> | 77 | #include <linux/seq_file.h> |
| 77 | #include <asm/uaccess.h> | 78 | #include <asm/uaccess.h> |
| 78 | #include "util.h" | 79 | #include "util.h" |
| @@ -27,6 +27,7 @@ | |||
| 27 | #include <linux/security.h> | 27 | #include <linux/security.h> |
| 28 | #include <linux/syscalls.h> | 28 | #include <linux/syscalls.h> |
| 29 | #include <linux/audit.h> | 29 | #include <linux/audit.h> |
| 30 | #include <linux/capability.h> | ||
| 30 | #include <linux/ptrace.h> | 31 | #include <linux/ptrace.h> |
| 31 | #include <linux/seq_file.h> | 32 | #include <linux/seq_file.h> |
| 32 | 33 | ||
| @@ -34,8 +35,6 @@ | |||
| 34 | 35 | ||
| 35 | #include "util.h" | 36 | #include "util.h" |
| 36 | 37 | ||
| 37 | #define shm_flags shm_perm.mode | ||
| 38 | |||
| 39 | static struct file_operations shm_file_operations; | 38 | static struct file_operations shm_file_operations; |
| 40 | static struct vm_operations_struct shm_vm_ops; | 39 | static struct vm_operations_struct shm_vm_ops; |
| 41 | 40 | ||
| @@ -148,7 +147,7 @@ static void shm_close (struct vm_area_struct *shmd) | |||
| 148 | shp->shm_dtim = get_seconds(); | 147 | shp->shm_dtim = get_seconds(); |
| 149 | shp->shm_nattch--; | 148 | shp->shm_nattch--; |
| 150 | if(shp->shm_nattch == 0 && | 149 | if(shp->shm_nattch == 0 && |
| 151 | shp->shm_flags & SHM_DEST) | 150 | shp->shm_perm.mode & SHM_DEST) |
| 152 | shm_destroy (shp); | 151 | shm_destroy (shp); |
| 153 | else | 152 | else |
| 154 | shm_unlock(shp); | 153 | shm_unlock(shp); |
| @@ -157,14 +156,22 @@ static void shm_close (struct vm_area_struct *shmd) | |||
| 157 | 156 | ||
| 158 | static int shm_mmap(struct file * file, struct vm_area_struct * vma) | 157 | static int shm_mmap(struct file * file, struct vm_area_struct * vma) |
| 159 | { | 158 | { |
| 160 | file_accessed(file); | 159 | int ret; |
| 161 | vma->vm_ops = &shm_vm_ops; | 160 | |
| 162 | shm_inc(file->f_dentry->d_inode->i_ino); | 161 | ret = shmem_mmap(file, vma); |
| 163 | return 0; | 162 | if (ret == 0) { |
| 163 | vma->vm_ops = &shm_vm_ops; | ||
| 164 | shm_inc(file->f_dentry->d_inode->i_ino); | ||
| 165 | } | ||
| 166 | |||
| 167 | return ret; | ||
| 164 | } | 168 | } |
| 165 | 169 | ||
| 166 | static struct file_operations shm_file_operations = { | 170 | static struct file_operations shm_file_operations = { |
| 167 | .mmap = shm_mmap | 171 | .mmap = shm_mmap, |
| 172 | #ifndef CONFIG_MMU | ||
| 173 | .get_unmapped_area = shmem_get_unmapped_area, | ||
| 174 | #endif | ||
| 168 | }; | 175 | }; |
| 169 | 176 | ||
| 170 | static struct vm_operations_struct shm_vm_ops = { | 177 | static struct vm_operations_struct shm_vm_ops = { |
| @@ -197,7 +204,7 @@ static int newseg (key_t key, int shmflg, size_t size) | |||
| 197 | return -ENOMEM; | 204 | return -ENOMEM; |
| 198 | 205 | ||
| 199 | shp->shm_perm.key = key; | 206 | shp->shm_perm.key = key; |
| 200 | shp->shm_flags = (shmflg & S_IRWXUGO); | 207 | shp->shm_perm.mode = (shmflg & S_IRWXUGO); |
| 201 | shp->mlock_user = NULL; | 208 | shp->mlock_user = NULL; |
| 202 | 209 | ||
| 203 | shp->shm_perm.security = NULL; | 210 | shp->shm_perm.security = NULL; |
| @@ -337,7 +344,7 @@ static inline unsigned long copy_shmid_from_user(struct shm_setbuf *out, void __ | |||
| 337 | 344 | ||
| 338 | out->uid = tbuf.shm_perm.uid; | 345 | out->uid = tbuf.shm_perm.uid; |
| 339 | out->gid = tbuf.shm_perm.gid; | 346 | out->gid = tbuf.shm_perm.gid; |
| 340 | out->mode = tbuf.shm_flags; | 347 | out->mode = tbuf.shm_perm.mode; |
| 341 | 348 | ||
| 342 | return 0; | 349 | return 0; |
| 343 | } | 350 | } |
| @@ -350,7 +357,7 @@ static inline unsigned long copy_shmid_from_user(struct shm_setbuf *out, void __ | |||
| 350 | 357 | ||
| 351 | out->uid = tbuf_old.shm_perm.uid; | 358 | out->uid = tbuf_old.shm_perm.uid; |
| 352 | out->gid = tbuf_old.shm_perm.gid; | 359 | out->gid = tbuf_old.shm_perm.gid; |
| 353 | out->mode = tbuf_old.shm_flags; | 360 | out->mode = tbuf_old.shm_perm.mode; |
| 354 | 361 | ||
| 355 | return 0; | 362 | return 0; |
| 356 | } | 363 | } |
| @@ -552,13 +559,13 @@ asmlinkage long sys_shmctl (int shmid, int cmd, struct shmid_ds __user *buf) | |||
| 552 | if (!is_file_hugepages(shp->shm_file)) { | 559 | if (!is_file_hugepages(shp->shm_file)) { |
| 553 | err = shmem_lock(shp->shm_file, 1, user); | 560 | err = shmem_lock(shp->shm_file, 1, user); |
| 554 | if (!err) { | 561 | if (!err) { |
| 555 | shp->shm_flags |= SHM_LOCKED; | 562 | shp->shm_perm.mode |= SHM_LOCKED; |
| 556 | shp->mlock_user = user; | 563 | shp->mlock_user = user; |
| 557 | } | 564 | } |
| 558 | } | 565 | } |
| 559 | } else if (!is_file_hugepages(shp->shm_file)) { | 566 | } else if (!is_file_hugepages(shp->shm_file)) { |
| 560 | shmem_lock(shp->shm_file, 0, shp->mlock_user); | 567 | shmem_lock(shp->shm_file, 0, shp->mlock_user); |
| 561 | shp->shm_flags &= ~SHM_LOCKED; | 568 | shp->shm_perm.mode &= ~SHM_LOCKED; |
| 562 | shp->mlock_user = NULL; | 569 | shp->mlock_user = NULL; |
| 563 | } | 570 | } |
| 564 | shm_unlock(shp); | 571 | shm_unlock(shp); |
| @@ -597,7 +604,7 @@ asmlinkage long sys_shmctl (int shmid, int cmd, struct shmid_ds __user *buf) | |||
| 597 | goto out_unlock_up; | 604 | goto out_unlock_up; |
| 598 | 605 | ||
| 599 | if (shp->shm_nattch){ | 606 | if (shp->shm_nattch){ |
| 600 | shp->shm_flags |= SHM_DEST; | 607 | shp->shm_perm.mode |= SHM_DEST; |
| 601 | /* Do not find it any more */ | 608 | /* Do not find it any more */ |
| 602 | shp->shm_perm.key = IPC_PRIVATE; | 609 | shp->shm_perm.key = IPC_PRIVATE; |
| 603 | shm_unlock(shp); | 610 | shm_unlock(shp); |
| @@ -636,7 +643,7 @@ asmlinkage long sys_shmctl (int shmid, int cmd, struct shmid_ds __user *buf) | |||
| 636 | 643 | ||
| 637 | shp->shm_perm.uid = setbuf.uid; | 644 | shp->shm_perm.uid = setbuf.uid; |
| 638 | shp->shm_perm.gid = setbuf.gid; | 645 | shp->shm_perm.gid = setbuf.gid; |
| 639 | shp->shm_flags = (shp->shm_flags & ~S_IRWXUGO) | 646 | shp->shm_perm.mode = (shp->shm_perm.mode & ~S_IRWXUGO) |
| 640 | | (setbuf.mode & S_IRWXUGO); | 647 | | (setbuf.mode & S_IRWXUGO); |
| 641 | shp->shm_ctim = get_seconds(); | 648 | shp->shm_ctim = get_seconds(); |
| 642 | break; | 649 | break; |
| @@ -769,7 +776,7 @@ invalid: | |||
| 769 | BUG(); | 776 | BUG(); |
| 770 | shp->shm_nattch--; | 777 | shp->shm_nattch--; |
| 771 | if(shp->shm_nattch == 0 && | 778 | if(shp->shm_nattch == 0 && |
| 772 | shp->shm_flags & SHM_DEST) | 779 | shp->shm_perm.mode & SHM_DEST) |
| 773 | shm_destroy (shp); | 780 | shm_destroy (shp); |
| 774 | else | 781 | else |
| 775 | shm_unlock(shp); | 782 | shm_unlock(shp); |
| @@ -894,7 +901,7 @@ static int sysvipc_shm_proc_show(struct seq_file *s, void *it) | |||
| 894 | return seq_printf(s, format, | 901 | return seq_printf(s, format, |
| 895 | shp->shm_perm.key, | 902 | shp->shm_perm.key, |
| 896 | shp->id, | 903 | shp->id, |
| 897 | shp->shm_flags, | 904 | shp->shm_perm.mode, |
| 898 | shp->shm_segsz, | 905 | shp->shm_segsz, |
| 899 | shp->shm_cprid, | 906 | shp->shm_cprid, |
| 900 | shp->shm_lprid, | 907 | shp->shm_lprid, |
diff --git a/ipc/util.c b/ipc/util.c index 23f1cec150c1..38b9a0af3bd8 100644 --- a/ipc/util.c +++ b/ipc/util.c | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | #include <linux/smp_lock.h> | 20 | #include <linux/smp_lock.h> |
| 21 | #include <linux/vmalloc.h> | 21 | #include <linux/vmalloc.h> |
| 22 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
| 23 | #include <linux/capability.h> | ||
| 23 | #include <linux/highuid.h> | 24 | #include <linux/highuid.h> |
| 24 | #include <linux/security.h> | 25 | #include <linux/security.h> |
| 25 | #include <linux/rcupdate.h> | 26 | #include <linux/rcupdate.h> |
