From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754028AbbIGQ6Y (ORCPT ); Mon, 7 Sep 2015 12:58:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35468 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753379AbbIGQ6V (ORCPT ); Mon, 7 Sep 2015 12:58:21 -0400 Date: Mon, 7 Sep 2015 12:58:18 -0400 From: Richard Guy Briggs To: linux-audit@redhat.com, linux-kernel@vger.kernel.org Cc: sgrubb@redhat.com, pmoore@redhat.com, eparis@redhat.com, v.rathor@gmail.com, ctcard@hotmail.com Subject: Re: [PATCH V1] audit: add warning that an old auditd may be starved out by a new auditd Message-ID: <20150907165818.GH8140@madcap2.tricolour.ca> References: <5e786f07b6d8a19927c70345c14bd1a452164d38.1441644314.git.rgb@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5e786f07b6d8a19927c70345c14bd1a452164d38.1441644314.git.rgb@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 15/09/07, Richard Guy Briggs wrote: > 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 Ok, self-nack on this one for a couple of problems... netlink_getsockbyportid() is static to af_netlink.c and "pid" should be task_tgid_vnr(current). Otherwise, any opinions on this approach? > --- > 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 > - RGB -- Richard Guy Briggs Senior Software Engineer, Kernel Security, AMER ENG Base Operating Systems, Red Hat Remote, Ottawa, Canada Voice: +1.647.777.2635, Internal: (81) 32635, Alt: +1.613.693.0684x3545