public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH V1] audit: add warning that an old auditd may be starved out by a new auditd
@ 2015-09-07 16:48 Richard Guy Briggs
  2015-09-07 16:58 ` Richard Guy Briggs
  2015-09-08 14:57 ` Eric Paris
  0 siblings, 2 replies; 13+ messages in thread
From: Richard Guy Briggs @ 2015-09-07 16:48 UTC (permalink / raw)
  To: linux-audit, linux-kernel
  Cc: Richard Guy Briggs, sgrubb, pmoore, eparis, v.rathor, ctcard

Nothing prevents a new auditd starting up and replacing a valid
audit_pid when an old auditd is still running, effectively starving out
the old auditd since audit_pid no longer points to the old valid auditd.

There isn't an easy way to detect if an old auditd is still running on
the existing audit_pid other than attempting to send a message to see if
it fails.  If no message to auditd has been attempted since auditd died
unnaturally or got killed, audit_pid will still indicate it is alive.

Signed-off-by: Richard Guy Briggs <rgb@redhat.com>
---
Note: Would it be too bold to actually block the registration of a new
auditd if the netlink_getsockbyportid() call succeeded?  Would other
checks be appropriate?

 kernel/audit.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/kernel/audit.c b/kernel/audit.c
index 18cdfe2..1fa1e0d 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -872,6 +872,11 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
 		if (s.mask & AUDIT_STATUS_PID) {
 			int new_pid = s.pid;
 
+			if (audit_pid && new_pid &&
+			    !IS_ERR(netlink_getsockbyportid(audit_sock, audit_nlk_portid)))
+				pr_warn("auditd replaced by new auditd before normal shutdown: "
+					"(old)audit_pid=%d (by)pid=%d new_pid=%d",
+					audit_pid, pid, new_pid);
 			if ((!new_pid) && (task_tgid_vnr(current) != audit_pid))
 				return -EACCES;
 			if (audit_enabled != AUDIT_OFF)
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2015-09-17 22:40 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-07 16:48 [PATCH V1] audit: add warning that an old auditd may be starved out by a new auditd Richard Guy Briggs
2015-09-07 16:58 ` Richard Guy Briggs
2015-09-09 20:50   ` Paul Moore
2015-09-11 10:21     ` Richard Guy Briggs
2015-09-11 18:56       ` Paul Moore
2015-09-13 16:08         ` Richard Guy Briggs
2015-09-14 19:37           ` Paul Moore
2015-09-16 10:24             ` Richard Guy Briggs
2015-09-16 21:45               ` Paul Moore
2015-09-17 11:35                 ` Richard Guy Briggs
2015-09-17 22:40                   ` Paul Moore
2015-09-08 14:57 ` Eric Paris
2015-09-09  6:31   ` Richard Guy Briggs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox