summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-02-21 16:25:50 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-02-21 16:25:50 -0500
commitb8989bccd6a0ad49db4795afca56a733e1c19099 (patch)
treeb9f974ea3ee701e75bcd5225497ba0a472322d1c /kernel
parentc9341ee0af4df0af8b727873ef851227345defed (diff)
parentfe8e52b9b9100c486051aaf5208dbf4072bb87b1 (diff)
Merge branch 'stable-4.11' of git://git.infradead.org/users/pcmoore/audit
Pull audit updates from Paul Moore: "The audit changes for v4.11 are relatively small compared to what we did for v4.10, both in terms of size and impact. - two patches from Steve tweak the formatting for some of the audit records to make them more consistent with other audit records. - three patches from Richard record the name of a module on module load, fix the logging of sockaddr information when using socketcall() on 32-bit systems, and add the ability to reset audit's lost record counter. - my lone patch just fixes an annoying style nit that I was reminded about by one of Richard's patches. All these patches pass our test suite" * 'stable-4.11' of git://git.infradead.org/users/pcmoore/audit: audit: remove unnecessary curly braces from switch/case statements audit: log module name on init_module audit: log 32-bit socketcalls audit: add feature audit_lost reset audit: Make AUDIT_ANOM_ABEND event normalized audit: Make AUDIT_KERNEL event conform to the specification
Diffstat (limited to 'kernel')
-rw-r--r--kernel/audit.c12
-rw-r--r--kernel/audit.h3
-rw-r--r--kernel/auditsc.c40
-rw-r--r--kernel/module.c5
4 files changed, 44 insertions, 16 deletions
diff --git a/kernel/audit.c b/kernel/audit.c
index 6e399bb69d7c..e794544f5e63 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -121,7 +121,7 @@ u32 audit_sig_sid = 0;
121 3) suppressed due to audit_rate_limit 121 3) suppressed due to audit_rate_limit
122 4) suppressed due to audit_backlog_limit 122 4) suppressed due to audit_backlog_limit
123*/ 123*/
124static atomic_t audit_lost = ATOMIC_INIT(0); 124static atomic_t audit_lost = ATOMIC_INIT(0);
125 125
126/* The netlink socket. */ 126/* The netlink socket. */
127static struct sock *audit_sock; 127static struct sock *audit_sock;
@@ -1058,6 +1058,12 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
1058 if (err < 0) 1058 if (err < 0)
1059 return err; 1059 return err;
1060 } 1060 }
1061 if (s.mask == AUDIT_STATUS_LOST) {
1062 u32 lost = atomic_xchg(&audit_lost, 0);
1063
1064 audit_log_config_change("lost", 0, lost, 1);
1065 return lost;
1066 }
1061 break; 1067 break;
1062 } 1068 }
1063 case AUDIT_GET_FEATURE: 1069 case AUDIT_GET_FEATURE:
@@ -1349,7 +1355,9 @@ static int __init audit_init(void)
1349 panic("audit: failed to start the kauditd thread (%d)\n", err); 1355 panic("audit: failed to start the kauditd thread (%d)\n", err);
1350 } 1356 }
1351 1357
1352 audit_log(NULL, GFP_KERNEL, AUDIT_KERNEL, "initialized"); 1358 audit_log(NULL, GFP_KERNEL, AUDIT_KERNEL,
1359 "state=initialized audit_enabled=%u res=1",
1360 audit_enabled);
1353 1361
1354 return 0; 1362 return 0;
1355} 1363}
diff --git a/kernel/audit.h b/kernel/audit.h
index 960d49c9db5e..ca579880303a 100644
--- a/kernel/audit.h
+++ b/kernel/audit.h
@@ -199,6 +199,9 @@ struct audit_context {
199 struct { 199 struct {
200 int argc; 200 int argc;
201 } execve; 201 } execve;
202 struct {
203 char *name;
204 } module;
202 }; 205 };
203 int fds[2]; 206 int fds[2];
204 struct audit_proctitle proctitle; 207 struct audit_proctitle proctitle;
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index cf1fa43512c1..d6a8de5f8fa3 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1221,7 +1221,7 @@ static void show_special(struct audit_context *context, int *call_panic)
1221 context->ipc.perm_mode); 1221 context->ipc.perm_mode);
1222 } 1222 }
1223 break; } 1223 break; }
1224 case AUDIT_MQ_OPEN: { 1224 case AUDIT_MQ_OPEN:
1225 audit_log_format(ab, 1225 audit_log_format(ab,
1226 "oflag=0x%x mode=%#ho mq_flags=0x%lx mq_maxmsg=%ld " 1226 "oflag=0x%x mode=%#ho mq_flags=0x%lx mq_maxmsg=%ld "
1227 "mq_msgsize=%ld mq_curmsgs=%ld", 1227 "mq_msgsize=%ld mq_curmsgs=%ld",
@@ -1230,8 +1230,8 @@ static void show_special(struct audit_context *context, int *call_panic)
1230 context->mq_open.attr.mq_maxmsg, 1230 context->mq_open.attr.mq_maxmsg,
1231 context->mq_open.attr.mq_msgsize, 1231 context->mq_open.attr.mq_msgsize,
1232 context->mq_open.attr.mq_curmsgs); 1232 context->mq_open.attr.mq_curmsgs);
1233 break; } 1233 break;
1234 case AUDIT_MQ_SENDRECV: { 1234 case AUDIT_MQ_SENDRECV:
1235 audit_log_format(ab, 1235 audit_log_format(ab,
1236 "mqdes=%d msg_len=%zd msg_prio=%u " 1236 "mqdes=%d msg_len=%zd msg_prio=%u "
1237 "abs_timeout_sec=%ld abs_timeout_nsec=%ld", 1237 "abs_timeout_sec=%ld abs_timeout_nsec=%ld",
@@ -1240,12 +1240,12 @@ static void show_special(struct audit_context *context, int *call_panic)
1240 context->mq_sendrecv.msg_prio, 1240 context->mq_sendrecv.msg_prio,
1241 context->mq_sendrecv.abs_timeout.tv_sec, 1241 context->mq_sendrecv.abs_timeout.tv_sec,
1242 context->mq_sendrecv.abs_timeout.tv_nsec); 1242 context->mq_sendrecv.abs_timeout.tv_nsec);
1243 break; } 1243 break;
1244 case AUDIT_MQ_NOTIFY: { 1244 case AUDIT_MQ_NOTIFY:
1245 audit_log_format(ab, "mqdes=%d sigev_signo=%d", 1245 audit_log_format(ab, "mqdes=%d sigev_signo=%d",
1246 context->mq_notify.mqdes, 1246 context->mq_notify.mqdes,
1247 context->mq_notify.sigev_signo); 1247 context->mq_notify.sigev_signo);
1248 break; } 1248 break;
1249 case AUDIT_MQ_GETSETATTR: { 1249 case AUDIT_MQ_GETSETATTR: {
1250 struct mq_attr *attr = &context->mq_getsetattr.mqstat; 1250 struct mq_attr *attr = &context->mq_getsetattr.mqstat;
1251 audit_log_format(ab, 1251 audit_log_format(ab,
@@ -1255,19 +1255,24 @@ static void show_special(struct audit_context *context, int *call_panic)
1255 attr->mq_flags, attr->mq_maxmsg, 1255 attr->mq_flags, attr->mq_maxmsg,
1256 attr->mq_msgsize, attr->mq_curmsgs); 1256 attr->mq_msgsize, attr->mq_curmsgs);
1257 break; } 1257 break; }
1258 case AUDIT_CAPSET: { 1258 case AUDIT_CAPSET:
1259 audit_log_format(ab, "pid=%d", context->capset.pid); 1259 audit_log_format(ab, "pid=%d", context->capset.pid);
1260 audit_log_cap(ab, "cap_pi", &context->capset.cap.inheritable); 1260 audit_log_cap(ab, "cap_pi", &context->capset.cap.inheritable);
1261 audit_log_cap(ab, "cap_pp", &context->capset.cap.permitted); 1261 audit_log_cap(ab, "cap_pp", &context->capset.cap.permitted);
1262 audit_log_cap(ab, "cap_pe", &context->capset.cap.effective); 1262 audit_log_cap(ab, "cap_pe", &context->capset.cap.effective);
1263 break; } 1263 break;
1264 case AUDIT_MMAP: { 1264 case AUDIT_MMAP:
1265 audit_log_format(ab, "fd=%d flags=0x%x", context->mmap.fd, 1265 audit_log_format(ab, "fd=%d flags=0x%x", context->mmap.fd,
1266 context->mmap.flags); 1266 context->mmap.flags);
1267 break; } 1267 break;
1268 case AUDIT_EXECVE: { 1268 case AUDIT_EXECVE:
1269 audit_log_execve_info(context, &ab); 1269 audit_log_execve_info(context, &ab);
1270 break; } 1270 break;
1271 case AUDIT_KERN_MODULE:
1272 audit_log_format(ab, "name=");
1273 audit_log_untrustedstring(ab, context->module.name);
1274 kfree(context->module.name);
1275 break;
1271 } 1276 }
1272 audit_log_end(ab); 1277 audit_log_end(ab);
1273} 1278}
@@ -2368,6 +2373,15 @@ void __audit_mmap_fd(int fd, int flags)
2368 context->type = AUDIT_MMAP; 2373 context->type = AUDIT_MMAP;
2369} 2374}
2370 2375
2376void __audit_log_kern_module(char *name)
2377{
2378 struct audit_context *context = current->audit_context;
2379
2380 context->module.name = kmalloc(strlen(name) + 1, GFP_KERNEL);
2381 strcpy(context->module.name, name);
2382 context->type = AUDIT_KERN_MODULE;
2383}
2384
2371static void audit_log_task(struct audit_buffer *ab) 2385static void audit_log_task(struct audit_buffer *ab)
2372{ 2386{
2373 kuid_t auid, uid; 2387 kuid_t auid, uid;
@@ -2411,7 +2425,7 @@ void audit_core_dumps(long signr)
2411 if (unlikely(!ab)) 2425 if (unlikely(!ab))
2412 return; 2426 return;
2413 audit_log_task(ab); 2427 audit_log_task(ab);
2414 audit_log_format(ab, " sig=%ld", signr); 2428 audit_log_format(ab, " sig=%ld res=1", signr);
2415 audit_log_end(ab); 2429 audit_log_end(ab);
2416} 2430}
2417 2431
diff --git a/kernel/module.c b/kernel/module.c
index 3d8f126208e3..e2eec4b47143 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -61,6 +61,7 @@
61#include <linux/pfn.h> 61#include <linux/pfn.h>
62#include <linux/bsearch.h> 62#include <linux/bsearch.h>
63#include <linux/dynamic_debug.h> 63#include <linux/dynamic_debug.h>
64#include <linux/audit.h>
64#include <uapi/linux/module.h> 65#include <uapi/linux/module.h>
65#include "module-internal.h" 66#include "module-internal.h"
66 67
@@ -3608,6 +3609,8 @@ static int load_module(struct load_info *info, const char __user *uargs,
3608 goto free_copy; 3609 goto free_copy;
3609 } 3610 }
3610 3611
3612 audit_log_kern_module(mod->name);
3613
3611 /* Reserve our place in the list. */ 3614 /* Reserve our place in the list. */
3612 err = add_unformed_module(mod); 3615 err = add_unformed_module(mod);
3613 if (err) 3616 if (err)
@@ -3696,7 +3699,7 @@ static int load_module(struct load_info *info, const char __user *uargs,
3696 mod->name, after_dashes); 3699 mod->name, after_dashes);
3697 } 3700 }
3698 3701
3699 /* Link in to syfs. */ 3702 /* Link in to sysfs. */
3700 err = mod_sysfs_setup(mod, info, mod->kp, mod->num_kp); 3703 err = mod_sysfs_setup(mod, info, mod->kp, mod->num_kp);
3701 if (err < 0) 3704 if (err < 0)
3702 goto coming_cleanup; 3705 goto coming_cleanup;