diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-03-19 20:52:49 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-03-19 20:52:49 -0400 |
commit | 51b3eae8dbe5e6fa9657b21388ad6642d6934952 (patch) | |
tree | abf011b095e0fe66ca9730c53e1054ae973ecdfe | |
parent | de06dbfa7861c9019eedefc0c356ba86e5098f1b (diff) | |
parent | fd97646b05957348e01be3d9de5c3d979b25c819 (diff) |
Merge branch 'stable-4.6' of git://git.infradead.org/users/pcmoore/audit
Pull audit updates from Paul Moore:
"A small set of patches for audit this time; just three in total and
one is a spelling fix.
The two patches with actual content are designed to help prevent new
instances of auditd from displacing an existing, functioning auditd
and to generate a log of the attempt. Not to worry, dead/stuck auditd
instances can still be replaced by a new instance without problem.
Nothing controversial, and everything passes our regression suite"
* 'stable-4.6' of git://git.infradead.org/users/pcmoore/audit:
audit: Fix typo in comment
audit: log failed attempts to change audit_pid configuration
audit: stop an old auditd being starved out by a new auditd
-rw-r--r-- | include/uapi/linux/audit.h | 1 | ||||
-rw-r--r-- | kernel/audit.c | 20 | ||||
-rw-r--r-- | kernel/audit_watch.c | 2 | ||||
-rw-r--r-- | kernel/auditfilter.c | 6 |
4 files changed, 24 insertions, 5 deletions
diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h index 843540c398eb..d820aa979620 100644 --- a/include/uapi/linux/audit.h +++ b/include/uapi/linux/audit.h | |||
@@ -110,6 +110,7 @@ | |||
110 | #define AUDIT_SECCOMP 1326 /* Secure Computing event */ | 110 | #define AUDIT_SECCOMP 1326 /* Secure Computing event */ |
111 | #define AUDIT_PROCTITLE 1327 /* Proctitle emit event */ | 111 | #define AUDIT_PROCTITLE 1327 /* Proctitle emit event */ |
112 | #define AUDIT_FEATURE_CHANGE 1328 /* audit log listing feature changes */ | 112 | #define AUDIT_FEATURE_CHANGE 1328 /* audit log listing feature changes */ |
113 | #define AUDIT_REPLACE 1329 /* Replace auditd if this packet unanswerd */ | ||
113 | 114 | ||
114 | #define AUDIT_AVC 1400 /* SE Linux avc denial or grant */ | 115 | #define AUDIT_AVC 1400 /* SE Linux avc denial or grant */ |
115 | #define AUDIT_SELINUX_ERR 1401 /* Internal SE Linux Errors */ | 116 | #define AUDIT_SELINUX_ERR 1401 /* Internal SE Linux Errors */ |
diff --git a/kernel/audit.c b/kernel/audit.c index 2651e423b2dc..678c3f000191 100644 --- a/kernel/audit.c +++ b/kernel/audit.c | |||
@@ -809,6 +809,16 @@ static int audit_set_feature(struct sk_buff *skb) | |||
809 | return 0; | 809 | return 0; |
810 | } | 810 | } |
811 | 811 | ||
812 | static int audit_replace(pid_t pid) | ||
813 | { | ||
814 | struct sk_buff *skb = audit_make_reply(0, 0, AUDIT_REPLACE, 0, 0, | ||
815 | &pid, sizeof(pid)); | ||
816 | |||
817 | if (!skb) | ||
818 | return -ENOMEM; | ||
819 | return netlink_unicast(audit_sock, skb, audit_nlk_portid, 0); | ||
820 | } | ||
821 | |||
812 | static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | 822 | static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) |
813 | { | 823 | { |
814 | u32 seq; | 824 | u32 seq; |
@@ -870,9 +880,17 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
870 | } | 880 | } |
871 | if (s.mask & AUDIT_STATUS_PID) { | 881 | if (s.mask & AUDIT_STATUS_PID) { |
872 | int new_pid = s.pid; | 882 | int new_pid = s.pid; |
883 | pid_t requesting_pid = task_tgid_vnr(current); | ||
873 | 884 | ||
874 | if ((!new_pid) && (task_tgid_vnr(current) != audit_pid)) | 885 | if ((!new_pid) && (requesting_pid != audit_pid)) { |
886 | audit_log_config_change("audit_pid", new_pid, audit_pid, 0); | ||
875 | return -EACCES; | 887 | return -EACCES; |
888 | } | ||
889 | if (audit_pid && new_pid && | ||
890 | audit_replace(requesting_pid) != -ECONNREFUSED) { | ||
891 | audit_log_config_change("audit_pid", new_pid, audit_pid, 0); | ||
892 | return -EEXIST; | ||
893 | } | ||
876 | if (audit_enabled != AUDIT_OFF) | 894 | if (audit_enabled != AUDIT_OFF) |
877 | audit_log_config_change("audit_pid", new_pid, audit_pid, 1); | 895 | audit_log_config_change("audit_pid", new_pid, audit_pid, 1); |
878 | audit_pid = new_pid; | 896 | audit_pid = new_pid; |
diff --git a/kernel/audit_watch.c b/kernel/audit_watch.c index 9f194aad0adc..3cf1c5978d39 100644 --- a/kernel/audit_watch.c +++ b/kernel/audit_watch.c | |||
@@ -185,7 +185,7 @@ static struct audit_watch *audit_init_watch(char *path) | |||
185 | return watch; | 185 | return watch; |
186 | } | 186 | } |
187 | 187 | ||
188 | /* Translate a watch string to kernel respresentation. */ | 188 | /* Translate a watch string to kernel representation. */ |
189 | int audit_to_watch(struct audit_krule *krule, char *path, int len, u32 op) | 189 | int audit_to_watch(struct audit_krule *krule, char *path, int len, u32 op) |
190 | { | 190 | { |
191 | struct audit_watch *watch; | 191 | struct audit_watch *watch; |
diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c index b8ff9e193753..94ca7b1e5e7e 100644 --- a/kernel/auditfilter.c +++ b/kernel/auditfilter.c | |||
@@ -158,7 +158,7 @@ char *audit_unpack_string(void **bufp, size_t *remain, size_t len) | |||
158 | return str; | 158 | return str; |
159 | } | 159 | } |
160 | 160 | ||
161 | /* Translate an inode field to kernel respresentation. */ | 161 | /* Translate an inode field to kernel representation. */ |
162 | static inline int audit_to_inode(struct audit_krule *krule, | 162 | static inline int audit_to_inode(struct audit_krule *krule, |
163 | struct audit_field *f) | 163 | struct audit_field *f) |
164 | { | 164 | { |
@@ -415,7 +415,7 @@ static int audit_field_valid(struct audit_entry *entry, struct audit_field *f) | |||
415 | return 0; | 415 | return 0; |
416 | } | 416 | } |
417 | 417 | ||
418 | /* Translate struct audit_rule_data to kernel's rule respresentation. */ | 418 | /* Translate struct audit_rule_data to kernel's rule representation. */ |
419 | static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data, | 419 | static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data, |
420 | size_t datasz) | 420 | size_t datasz) |
421 | { | 421 | { |
@@ -593,7 +593,7 @@ static inline size_t audit_pack_string(void **bufp, const char *str) | |||
593 | return len; | 593 | return len; |
594 | } | 594 | } |
595 | 595 | ||
596 | /* Translate kernel rule respresentation to struct audit_rule_data. */ | 596 | /* Translate kernel rule representation to struct audit_rule_data. */ |
597 | static struct audit_rule_data *audit_krule_to_data(struct audit_krule *krule) | 597 | static struct audit_rule_data *audit_krule_to_data(struct audit_krule *krule) |
598 | { | 598 | { |
599 | struct audit_rule_data *data; | 599 | struct audit_rule_data *data; |