diff options
-rw-r--r-- | include/linux/audit.h | 9 | ||||
-rw-r--r-- | ipc/mqueue.c | 6 | ||||
-rw-r--r-- | kernel/auditsc.c | 54 |
3 files changed, 22 insertions, 47 deletions
diff --git a/include/linux/audit.h b/include/linux/audit.h index b7abfe0d6737..b7707e577b80 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h | |||
@@ -454,7 +454,7 @@ extern int __audit_mq_open(int oflag, mode_t mode, struct mq_attr __user *u_attr | |||
454 | extern int __audit_mq_timedsend(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec __user *u_abs_timeout); | 454 | extern int __audit_mq_timedsend(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec __user *u_abs_timeout); |
455 | extern int __audit_mq_timedreceive(mqd_t mqdes, size_t msg_len, unsigned int __user *u_msg_prio, const struct timespec __user *u_abs_timeout); | 455 | extern int __audit_mq_timedreceive(mqd_t mqdes, size_t msg_len, unsigned int __user *u_msg_prio, const struct timespec __user *u_abs_timeout); |
456 | extern int __audit_mq_notify(mqd_t mqdes, const struct sigevent __user *u_notification); | 456 | extern int __audit_mq_notify(mqd_t mqdes, const struct sigevent __user *u_notification); |
457 | extern int __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat); | 457 | extern void __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat); |
458 | extern int __audit_log_bprm_fcaps(struct linux_binprm *bprm, | 458 | extern int __audit_log_bprm_fcaps(struct linux_binprm *bprm, |
459 | const struct cred *new, | 459 | const struct cred *new, |
460 | const struct cred *old); | 460 | const struct cred *old); |
@@ -500,11 +500,10 @@ static inline int audit_mq_notify(mqd_t mqdes, const struct sigevent __user *u_n | |||
500 | return __audit_mq_notify(mqdes, u_notification); | 500 | return __audit_mq_notify(mqdes, u_notification); |
501 | return 0; | 501 | return 0; |
502 | } | 502 | } |
503 | static inline int audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat) | 503 | static inline void audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat) |
504 | { | 504 | { |
505 | if (unlikely(!audit_dummy_context())) | 505 | if (unlikely(!audit_dummy_context())) |
506 | return __audit_mq_getsetattr(mqdes, mqstat); | 506 | __audit_mq_getsetattr(mqdes, mqstat); |
507 | return 0; | ||
508 | } | 507 | } |
509 | 508 | ||
510 | static inline int audit_log_bprm_fcaps(struct linux_binprm *bprm, | 509 | static inline int audit_log_bprm_fcaps(struct linux_binprm *bprm, |
@@ -555,7 +554,7 @@ extern int audit_signals; | |||
555 | #define audit_mq_timedsend(d,l,p,t) ({ 0; }) | 554 | #define audit_mq_timedsend(d,l,p,t) ({ 0; }) |
556 | #define audit_mq_timedreceive(d,l,p,t) ({ 0; }) | 555 | #define audit_mq_timedreceive(d,l,p,t) ({ 0; }) |
557 | #define audit_mq_notify(d,n) ({ 0; }) | 556 | #define audit_mq_notify(d,n) ({ 0; }) |
558 | #define audit_mq_getsetattr(d,s) ({ 0; }) | 557 | #define audit_mq_getsetattr(d,s) ((void)0) |
559 | #define audit_log_bprm_fcaps(b, ncr, ocr) ({ 0; }) | 558 | #define audit_log_bprm_fcaps(b, ncr, ocr) ({ 0; }) |
560 | #define audit_log_capset(pid, ncr, ocr) ({ 0; }) | 559 | #define audit_log_capset(pid, ncr, ocr) ({ 0; }) |
561 | #define audit_ptrace(t) ((void)0) | 560 | #define audit_ptrace(t) ((void)0) |
diff --git a/ipc/mqueue.c b/ipc/mqueue.c index d9393f8e4c3e..7563611c6615 100644 --- a/ipc/mqueue.c +++ b/ipc/mqueue.c | |||
@@ -1150,11 +1150,7 @@ asmlinkage long sys_mq_getsetattr(mqd_t mqdes, | |||
1150 | omqstat = info->attr; | 1150 | omqstat = info->attr; |
1151 | omqstat.mq_flags = filp->f_flags & O_NONBLOCK; | 1151 | omqstat.mq_flags = filp->f_flags & O_NONBLOCK; |
1152 | if (u_mqstat) { | 1152 | if (u_mqstat) { |
1153 | ret = audit_mq_getsetattr(mqdes, &mqstat); | 1153 | audit_mq_getsetattr(mqdes, &mqstat); |
1154 | if (ret != 0) { | ||
1155 | spin_unlock(&info->lock); | ||
1156 | goto out_fput; | ||
1157 | } | ||
1158 | if (mqstat.mq_flags & O_NONBLOCK) | 1154 | if (mqstat.mq_flags & O_NONBLOCK) |
1159 | filp->f_flags |= O_NONBLOCK; | 1155 | filp->f_flags |= O_NONBLOCK; |
1160 | else | 1156 | else |
diff --git a/kernel/auditsc.c b/kernel/auditsc.c index fbed62e05bce..c50178c7e245 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c | |||
@@ -145,12 +145,6 @@ struct audit_aux_data_mq_notify { | |||
145 | struct sigevent notification; | 145 | struct sigevent notification; |
146 | }; | 146 | }; |
147 | 147 | ||
148 | struct audit_aux_data_mq_getsetattr { | ||
149 | struct audit_aux_data d; | ||
150 | mqd_t mqdes; | ||
151 | struct mq_attr mqstat; | ||
152 | }; | ||
153 | |||
154 | struct audit_aux_data_execve { | 148 | struct audit_aux_data_execve { |
155 | struct audit_aux_data d; | 149 | struct audit_aux_data d; |
156 | int argc; | 150 | int argc; |
@@ -248,6 +242,10 @@ struct audit_context { | |||
248 | mode_t perm_mode; | 242 | mode_t perm_mode; |
249 | unsigned long qbytes; | 243 | unsigned long qbytes; |
250 | } ipc; | 244 | } ipc; |
245 | struct { | ||
246 | mqd_t mqdes; | ||
247 | struct mq_attr mqstat; | ||
248 | } mq_getsetattr; | ||
251 | }; | 249 | }; |
252 | 250 | ||
253 | #if AUDIT_DEBUG | 251 | #if AUDIT_DEBUG |
@@ -1269,6 +1267,15 @@ static void show_special(struct audit_context *context, int *call_panic) | |||
1269 | return; | 1267 | return; |
1270 | } | 1268 | } |
1271 | break; } | 1269 | break; } |
1270 | case AUDIT_MQ_GETSETATTR: { | ||
1271 | struct mq_attr *attr = &context->mq_getsetattr.mqstat; | ||
1272 | audit_log_format(ab, | ||
1273 | "mqdes=%d mq_flags=0x%lx mq_maxmsg=%ld mq_msgsize=%ld " | ||
1274 | "mq_curmsgs=%ld ", | ||
1275 | context->mq_getsetattr.mqdes, | ||
1276 | attr->mq_flags, attr->mq_maxmsg, | ||
1277 | attr->mq_msgsize, attr->mq_curmsgs); | ||
1278 | break; } | ||
1272 | } | 1279 | } |
1273 | audit_log_end(ab); | 1280 | audit_log_end(ab); |
1274 | } | 1281 | } |
@@ -1377,16 +1384,6 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts | |||
1377 | axi->notification.sigev_signo); | 1384 | axi->notification.sigev_signo); |
1378 | break; } | 1385 | break; } |
1379 | 1386 | ||
1380 | case AUDIT_MQ_GETSETATTR: { | ||
1381 | struct audit_aux_data_mq_getsetattr *axi = (void *)aux; | ||
1382 | audit_log_format(ab, | ||
1383 | "mqdes=%d mq_flags=0x%lx mq_maxmsg=%ld mq_msgsize=%ld " | ||
1384 | "mq_curmsgs=%ld ", | ||
1385 | axi->mqdes, | ||
1386 | axi->mqstat.mq_flags, axi->mqstat.mq_maxmsg, | ||
1387 | axi->mqstat.mq_msgsize, axi->mqstat.mq_curmsgs); | ||
1388 | break; } | ||
1389 | |||
1390 | case AUDIT_EXECVE: { | 1387 | case AUDIT_EXECVE: { |
1391 | struct audit_aux_data_execve *axi = (void *)aux; | 1388 | struct audit_aux_data_execve *axi = (void *)aux; |
1392 | audit_log_execve_info(context, &ab, axi); | 1389 | audit_log_execve_info(context, &ab, axi); |
@@ -2316,30 +2313,13 @@ int __audit_mq_notify(mqd_t mqdes, const struct sigevent __user *u_notification) | |||
2316 | * @mqdes: MQ descriptor | 2313 | * @mqdes: MQ descriptor |
2317 | * @mqstat: MQ flags | 2314 | * @mqstat: MQ flags |
2318 | * | 2315 | * |
2319 | * Returns 0 for success or NULL context or < 0 on error. | ||
2320 | */ | 2316 | */ |
2321 | int __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat) | 2317 | void __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat) |
2322 | { | 2318 | { |
2323 | struct audit_aux_data_mq_getsetattr *ax; | ||
2324 | struct audit_context *context = current->audit_context; | 2319 | struct audit_context *context = current->audit_context; |
2325 | 2320 | context->mq_getsetattr.mqdes = mqdes; | |
2326 | if (!audit_enabled) | 2321 | context->mq_getsetattr.mqstat = *mqstat; |
2327 | return 0; | 2322 | context->type = AUDIT_MQ_GETSETATTR; |
2328 | |||
2329 | if (likely(!context)) | ||
2330 | return 0; | ||
2331 | |||
2332 | ax = kmalloc(sizeof(*ax), GFP_ATOMIC); | ||
2333 | if (!ax) | ||
2334 | return -ENOMEM; | ||
2335 | |||
2336 | ax->mqdes = mqdes; | ||
2337 | ax->mqstat = *mqstat; | ||
2338 | |||
2339 | ax->d.type = AUDIT_MQ_GETSETATTR; | ||
2340 | ax->d.next = context->aux; | ||
2341 | context->aux = (void *)ax; | ||
2342 | return 0; | ||
2343 | } | 2323 | } |
2344 | 2324 | ||
2345 | /** | 2325 | /** |