diff options
Diffstat (limited to 'ipc')
-rw-r--r-- | ipc/mqueue.c | 2 | ||||
-rw-r--r-- | ipc/shm.c | 17 |
2 files changed, 15 insertions, 4 deletions
diff --git a/ipc/mqueue.c b/ipc/mqueue.c index 54b4077fed79..a8ddadbc7459 100644 --- a/ipc/mqueue.c +++ b/ipc/mqueue.c | |||
@@ -1156,10 +1156,12 @@ SYSCALL_DEFINE3(mq_getsetattr, mqd_t, mqdes, | |||
1156 | omqstat.mq_flags = filp->f_flags & O_NONBLOCK; | 1156 | omqstat.mq_flags = filp->f_flags & O_NONBLOCK; |
1157 | if (u_mqstat) { | 1157 | if (u_mqstat) { |
1158 | audit_mq_getsetattr(mqdes, &mqstat); | 1158 | audit_mq_getsetattr(mqdes, &mqstat); |
1159 | spin_lock(&filp->f_lock); | ||
1159 | if (mqstat.mq_flags & O_NONBLOCK) | 1160 | if (mqstat.mq_flags & O_NONBLOCK) |
1160 | filp->f_flags |= O_NONBLOCK; | 1161 | filp->f_flags |= O_NONBLOCK; |
1161 | else | 1162 | else |
1162 | filp->f_flags &= ~O_NONBLOCK; | 1163 | filp->f_flags &= ~O_NONBLOCK; |
1164 | spin_unlock(&filp->f_lock); | ||
1163 | 1165 | ||
1164 | inode->i_atime = inode->i_ctime = CURRENT_TIME; | 1166 | inode->i_atime = inode->i_ctime = CURRENT_TIME; |
1165 | } | 1167 | } |
@@ -39,6 +39,7 @@ | |||
39 | #include <linux/nsproxy.h> | 39 | #include <linux/nsproxy.h> |
40 | #include <linux/mount.h> | 40 | #include <linux/mount.h> |
41 | #include <linux/ipc_namespace.h> | 41 | #include <linux/ipc_namespace.h> |
42 | #include <linux/ima.h> | ||
42 | 43 | ||
43 | #include <asm/uaccess.h> | 44 | #include <asm/uaccess.h> |
44 | 45 | ||
@@ -340,6 +341,7 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params) | |||
340 | struct file * file; | 341 | struct file * file; |
341 | char name[13]; | 342 | char name[13]; |
342 | int id; | 343 | int id; |
344 | int acctflag = 0; | ||
343 | 345 | ||
344 | if (size < SHMMIN || size > ns->shm_ctlmax) | 346 | if (size < SHMMIN || size > ns->shm_ctlmax) |
345 | return -EINVAL; | 347 | return -EINVAL; |
@@ -364,23 +366,25 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params) | |||
364 | 366 | ||
365 | sprintf (name, "SYSV%08x", key); | 367 | sprintf (name, "SYSV%08x", key); |
366 | if (shmflg & SHM_HUGETLB) { | 368 | if (shmflg & SHM_HUGETLB) { |
367 | /* hugetlb_file_setup takes care of mlock user accounting */ | 369 | /* hugetlb_file_setup applies strict accounting */ |
368 | file = hugetlb_file_setup(name, size); | 370 | if (shmflg & SHM_NORESERVE) |
371 | acctflag = VM_NORESERVE; | ||
372 | file = hugetlb_file_setup(name, size, acctflag); | ||
369 | shp->mlock_user = current_user(); | 373 | shp->mlock_user = current_user(); |
370 | } else { | 374 | } else { |
371 | int acctflag = VM_ACCOUNT; | ||
372 | /* | 375 | /* |
373 | * Do not allow no accounting for OVERCOMMIT_NEVER, even | 376 | * Do not allow no accounting for OVERCOMMIT_NEVER, even |
374 | * if it's asked for. | 377 | * if it's asked for. |
375 | */ | 378 | */ |
376 | if ((shmflg & SHM_NORESERVE) && | 379 | if ((shmflg & SHM_NORESERVE) && |
377 | sysctl_overcommit_memory != OVERCOMMIT_NEVER) | 380 | sysctl_overcommit_memory != OVERCOMMIT_NEVER) |
378 | acctflag = 0; | 381 | acctflag = VM_NORESERVE; |
379 | file = shmem_file_setup(name, size, acctflag); | 382 | file = shmem_file_setup(name, size, acctflag); |
380 | } | 383 | } |
381 | error = PTR_ERR(file); | 384 | error = PTR_ERR(file); |
382 | if (IS_ERR(file)) | 385 | if (IS_ERR(file)) |
383 | goto no_file; | 386 | goto no_file; |
387 | ima_shm_check(file); | ||
384 | 388 | ||
385 | id = ipc_addid(&shm_ids(ns), &shp->shm_perm, ns->shm_ctlmni); | 389 | id = ipc_addid(&shm_ids(ns), &shp->shm_perm, ns->shm_ctlmni); |
386 | if (id < 0) { | 390 | if (id < 0) { |
@@ -565,11 +569,15 @@ static void shm_get_stat(struct ipc_namespace *ns, unsigned long *rss, | |||
565 | struct hstate *h = hstate_file(shp->shm_file); | 569 | struct hstate *h = hstate_file(shp->shm_file); |
566 | *rss += pages_per_huge_page(h) * mapping->nrpages; | 570 | *rss += pages_per_huge_page(h) * mapping->nrpages; |
567 | } else { | 571 | } else { |
572 | #ifdef CONFIG_SHMEM | ||
568 | struct shmem_inode_info *info = SHMEM_I(inode); | 573 | struct shmem_inode_info *info = SHMEM_I(inode); |
569 | spin_lock(&info->lock); | 574 | spin_lock(&info->lock); |
570 | *rss += inode->i_mapping->nrpages; | 575 | *rss += inode->i_mapping->nrpages; |
571 | *swp += info->swapped; | 576 | *swp += info->swapped; |
572 | spin_unlock(&info->lock); | 577 | spin_unlock(&info->lock); |
578 | #else | ||
579 | *rss += inode->i_mapping->nrpages; | ||
580 | #endif | ||
573 | } | 581 | } |
574 | 582 | ||
575 | total++; | 583 | total++; |
@@ -881,6 +889,7 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr) | |||
881 | file = alloc_file(path.mnt, path.dentry, f_mode, &shm_file_operations); | 889 | file = alloc_file(path.mnt, path.dentry, f_mode, &shm_file_operations); |
882 | if (!file) | 890 | if (!file) |
883 | goto out_free; | 891 | goto out_free; |
892 | ima_shm_check(file); | ||
884 | 893 | ||
885 | file->private_data = sfd; | 894 | file->private_data = sfd; |
886 | file->f_mapping = shp->shm_file->f_mapping; | 895 | file->f_mapping = shp->shm_file->f_mapping; |