Skip to content

Commit 51b3eae

Browse files
committed
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
2 parents de06dbf + fd97646 commit 51b3eae

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

include/uapi/linux/audit.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
#define AUDIT_SECCOMP 1326 /* Secure Computing event */
111111
#define AUDIT_PROCTITLE 1327 /* Proctitle emit event */
112112
#define AUDIT_FEATURE_CHANGE 1328 /* audit log listing feature changes */
113+
#define AUDIT_REPLACE 1329 /* Replace auditd if this packet unanswerd */
113114

114115
#define AUDIT_AVC 1400 /* SE Linux avc denial or grant */
115116
#define AUDIT_SELINUX_ERR 1401 /* Internal SE Linux Errors */

kernel/audit.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,16 @@ static int audit_set_feature(struct sk_buff *skb)
809809
return 0;
810810
}
811811

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+
812822
static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
813823
{
814824
u32 seq;
@@ -870,9 +880,17 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
870880
}
871881
if (s.mask & AUDIT_STATUS_PID) {
872882
int new_pid = s.pid;
883+
pid_t requesting_pid = task_tgid_vnr(current);
873884

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);
875887
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+
}
876894
if (audit_enabled != AUDIT_OFF)
877895
audit_log_config_change("audit_pid", new_pid, audit_pid, 1);
878896
audit_pid = new_pid;

kernel/audit_watch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ static struct audit_watch *audit_init_watch(char *path)
185185
return watch;
186186
}
187187

188-
/* Translate a watch string to kernel respresentation. */
188+
/* Translate a watch string to kernel representation. */
189189
int audit_to_watch(struct audit_krule *krule, char *path, int len, u32 op)
190190
{
191191
struct audit_watch *watch;

kernel/auditfilter.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ char *audit_unpack_string(void **bufp, size_t *remain, size_t len)
158158
return str;
159159
}
160160

161-
/* Translate an inode field to kernel respresentation. */
161+
/* Translate an inode field to kernel representation. */
162162
static inline int audit_to_inode(struct audit_krule *krule,
163163
struct audit_field *f)
164164
{
@@ -415,7 +415,7 @@ static int audit_field_valid(struct audit_entry *entry, struct audit_field *f)
415415
return 0;
416416
}
417417

418-
/* Translate struct audit_rule_data to kernel's rule respresentation. */
418+
/* Translate struct audit_rule_data to kernel's rule representation. */
419419
static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data,
420420
size_t datasz)
421421
{
@@ -593,7 +593,7 @@ static inline size_t audit_pack_string(void **bufp, const char *str)
593593
return len;
594594
}
595595

596-
/* Translate kernel rule respresentation to struct audit_rule_data. */
596+
/* Translate kernel rule representation to struct audit_rule_data. */
597597
static struct audit_rule_data *audit_krule_to_data(struct audit_krule *krule)
598598
{
599599
struct audit_rule_data *data;

0 commit comments

Comments
 (0)