public inbox for linux-audit@redhat.com
 help / color / mirror / Atom feed
* [PATCH 0/6] audit: add restricted capability read-only netlink multicast socket
@ 2013-01-24 18:15 Richard Guy Briggs
  2013-01-24 18:15 ` [PATCH 1/6] audit: refactor hold queue flush Richard Guy Briggs
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Richard Guy Briggs @ 2013-01-24 18:15 UTC (permalink / raw)
  To: linux-audit

Hi,

This is a patch set Eric Paris and I have been working on to add a restricted
capability read-only netlink multicast socket to kaudit to enable 
userspace clients such as systemd to consume audit logs, in addition to the
bidirectional auditd userspace client.

Currently, auditd has the CAP_AUDIT_CONTROL and CAP_AUDIT_WRITE capabilities
(bot uses CAP_NET_ADMIN).  The CAP_AUDIT_READ capability will be added for use
by read-only AUDIT_NLGRP_READLOG multicast group clients to the kaudit
subsystem.

https://bugzilla.redhat.com/show_bug.cgi?id=887992

Feedback please!

Richard Guy Briggs (6):
  audit: refactor hold queue flush
  audit: flatten kauditd_thread wait queue code
  audit: move kaudit thread start from auditd registration to kaudit
    init
  netlink: add send and receive capability requirement and capability
    flags
  audit: add the first netlink multicast socket group
  audit: send multicast messages only if there are listeners

 include/linux/netlink.h             |   4 +
 include/uapi/linux/audit.h          |   8 ++
 include/uapi/linux/capability.h     |   5 +-
 kernel/audit.c                      | 142 +++++++++++++++++++++++++-----------
 net/netlink/af_netlink.c            |  35 +++++++--
 security/selinux/include/classmap.h |   2 +-
 6 files changed, 144 insertions(+), 52 deletions(-)

-- 
1.8.0.2

^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: [PATCH] netlink: have netlink per-protocol bind function return an error code.
@ 2014-03-24 18:34 Richard Guy Briggs
  2014-04-18 17:34 ` [PATCH 0/6] audit: implement multicast socket for journald Richard Guy Briggs
  0 siblings, 1 reply; 8+ messages in thread
From: Richard Guy Briggs @ 2014-03-24 18:34 UTC (permalink / raw)
  To: David Miller
  Cc: linux-audit, linux-kernel, netfilter-devel, netdev, eparis,
	sgrubb, hadi

On 14/03/24, Richard Guy Briggs wrote:
> On 14/03/23, David Miller wrote:
> > From: Richard Guy Briggs <rgb@redhat.com>
> > Date: Fri, 21 Mar 2014 12:39:11 -0400
> > 
> > > @@ -1441,6 +1441,17 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr,
> > >  	if (!nladdr->nl_groups && (nlk->groups == NULL || !(u32)nlk->groups[0]))
> > >  		return 0;
> > >  
> > > +	if (nlk->netlink_bind && nladdr->nl_groups) {
> > > +		int i;
> > > +
> > > +		for (i = 0; i < nlk->ngroups; i++)
> > > +			if (test_bit(i, (long unsigned int *)&nladdr->nl_groups)) {
> > > +				err = nlk->netlink_bind(i);
> > > +				if (err)
> > > +					return err;
> > > +			}
> > > +	}
> > > +
> > 
> > You can't just leave a partially set of completed bindings in place.
> 
> In the general case, I agree.
> 
> > It's not valid to leave half-baked state like this.
> 
> In the one existing case (netfilter), it adds a module that is never
> unloaded.  (refcounts are bumped up and down, but I don't see an
> auto-reap based on cleared multicast group subscriptions.)  For that
> matter, netlink_realloc_groups() isn't reversed on error either.

Ok, in netlink_bind(), netlink_insert()/netlink_autobind() also need
to be undone with netlink_remove() if nlk->portid was not set.

> In the proposed case (audit) it is only a permissions check, so there is
> nothing to undo.
> 
> So, I was being lazy looking at the existing situation.
> 
> > If you return an error, all of the binding state changes must be
> > completely undone.
> 
> Is it time to add a ".unbind = netlink_unbind" to struct proto_ops
> netlink_ops?  (I am only half serious here...)

At this stage, that function would be a no-op for netfilter and audit.
Are there any out-of-tree users of this per-protocol bind function?

> > If you can't find a way to do this cleanly, you'll need to find
> > a way for the audit code to not return an error.
> 
> Fair enough.  I'll go back and look at updating subscriptions and
> listeners first and undoing those actions if the bind fails.  In the
> case of netlink_setsockopt() it is just one to undo, which is easy.
> netlink_bind() is a bit more complex, but doable.
> 
> The whole purpose here was to add a way for each protocol to be able to
> add its own permissions check and signal a way for netlink to refuse the
> subscription if the userspace process doesn't have the required
> permissions, so not returning an error defeats that whole purpose.
> 
> - RGB

- RGB

--
Richard Guy Briggs <rbriggs@redhat.com>
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

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

end of thread, other threads:[~2014-04-18 17:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-24 18:15 [PATCH 0/6] audit: add restricted capability read-only netlink multicast socket Richard Guy Briggs
2013-01-24 18:15 ` [PATCH 1/6] audit: refactor hold queue flush Richard Guy Briggs
2013-01-24 18:15 ` [PATCH 2/6] audit: flatten kauditd_thread wait queue code Richard Guy Briggs
2013-01-24 18:15 ` [PATCH 3/6] audit: move kaudit thread start from auditd registration to kaudit init Richard Guy Briggs
2013-01-24 18:15 ` [PATCH 4/6] netlink: add send and receive capability requirement and capability flags Richard Guy Briggs
2013-01-24 18:15 ` [PATCH 5/6] audit: add restricted capability read-only netlink multicast socket Richard Guy Briggs
2013-01-24 18:15 ` [PATCH 6/6] audit: send multicast messages only if there are listeners Richard Guy Briggs
  -- strict thread matches above, loose matches on Subject: below --
2014-03-24 18:34 [PATCH] netlink: have netlink per-protocol bind function return an error code Richard Guy Briggs
2014-04-18 17:34 ` [PATCH 0/6] audit: implement multicast socket for journald Richard Guy Briggs
2014-04-18 17:34   ` [PATCH 6/6] audit: send multicast messages only if there are listeners 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