1 From foo@baz Tue Dec 12 10:32:42 CET 2017
2 From: Steve Grubb <sgrubb@redhat.com>
3 Date: Tue, 17 Oct 2017 18:29:22 -0400
4 Subject: audit: Allow auditd to set pid to 0 to end auditing
6 From: Steve Grubb <sgrubb@redhat.com>
9 [ Upstream commit 33e8a907804428109ce1d12301c3365d619cc4df ]
11 The API to end auditing has historically been for auditd to set the
12 pid to 0. This patch restores that functionality.
14 See: https://github.com/linux-audit/audit-kernel/issues/69
16 Reviewed-by: Richard Guy Briggs <rgb@redhat.com>
17 Signed-off-by: Steve Grubb <sgrubb@redhat.com>
18 Signed-off-by: Paul Moore <paul@paul-moore.com>
19 Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
20 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22 kernel/audit.c | 29 ++++++++++++++++-------------
23 1 file changed, 16 insertions(+), 13 deletions(-)
27 @@ -1197,25 +1197,28 @@ static int audit_receive_msg(struct sk_b
29 struct pid *req_pid = task_tgid(current);
31 - /* sanity check - PID values must match */
32 - if (new_pid != pid_vnr(req_pid))
33 + /* Sanity check - PID values must match. Setting
34 + * pid to 0 is how auditd ends auditing. */
35 + if (new_pid && (new_pid != pid_vnr(req_pid)))
38 /* test the auditd connection */
39 audit_replace(req_pid);
41 auditd_pid = auditd_pid_vnr();
42 - /* only the current auditd can unregister itself */
43 - if ((!new_pid) && (new_pid != auditd_pid)) {
44 - audit_log_config_change("audit_pid", new_pid,
48 - /* replacing a healthy auditd is not allowed */
49 - if (auditd_pid && new_pid) {
50 - audit_log_config_change("audit_pid", new_pid,
54 + /* replacing a healthy auditd is not allowed */
56 + audit_log_config_change("audit_pid",
57 + new_pid, auditd_pid, 0);
60 + /* only current auditd can unregister itself */
61 + if (pid_vnr(req_pid) != auditd_pid) {
62 + audit_log_config_change("audit_pid",
63 + new_pid, auditd_pid, 0);