From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Richard Guy Briggs <rgb@redhat.com>
Cc: Netfilter Developer Mailing List
<netfilter-devel@vger.kernel.org>,
linux-audit@redhat.com, Florian Westphal <fw@strlen.de>,
Thomas Woerner <twoerner@redhat.com>,
Thomas Graf <tgraf@infradead.org>, Eric Paris <eparis@redhat.com>,
Paul Moore <pmoore@redhat.com>, Steve Grubb <sgrubb@redhat.com>
Subject: Re: [PATCH 3/6 RFC] netfilter: audit only on xtables and ebtables syscall rule or standalone
Date: Wed, 24 May 2017 19:36:06 +0200 [thread overview]
Message-ID: <20170524173606.GB7439@salvia> (raw)
In-Reply-To: <ac9a2120311288328a81d3e07a68857ebd32a21b.1495124188.git.rgb@redhat.com>
On Thu, May 18, 2017 at 01:21:49PM -0400, Richard Guy Briggs wrote:
> There were syscall events unsolicited by any audit rule caused by a missing
> !audit_dummy_context() check before creating an
> iptables/ip6tables/arptables/ebtables NETFILTER_CFG record. Check
> !audit_dummy_context() before creating the NETFILTER_CFG record.
>
> The vast majority of observed unaccompanied records are caused by the fedora
> default rule: "-a never,task" and the occasional early startup one is I believe
> caused by the iptables filter table module hard linked into the kernel rather
> than a loadable module. The !audit_dummy_context() check above should avoid
> them. Audit only when there is an existing syscall audit rule, otherwise issue
> a standalone record only on table modification rather than empty table
> creation.
>
> Add subject attributes to the new standalone NETFILTER_CFGSOLO record using
> a newly exported audit_log_task().
This new NETFILTER_CFGSOLO looks like audit infra is missing some way
to export a revision / context to userspace? It's duplicating quite a
bit of the code from what I can see in this patch.
> diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
> index 0714a66..8bee3f5 100644
> --- a/include/uapi/linux/audit.h
> +++ b/include/uapi/linux/audit.h
> @@ -112,6 +112,7 @@
> #define AUDIT_FEATURE_CHANGE 1328 /* audit log listing feature changes */
> #define AUDIT_REPLACE 1329 /* Replace auditd if this packet unanswerd */
> #define AUDIT_KERN_MODULE 1330 /* Kernel Module events */
> +#define AUDIT_NETFILTER_CFGSOLO 1331 /* Netfilter chain modifications standalone */
>
> #define AUDIT_AVC 1400 /* SE Linux avc denial or grant */
> #define AUDIT_SELINUX_ERR 1401 /* Internal SE Linux Errors */
> diff --git a/kernel/auditsc.c b/kernel/auditsc.c
> index b2dcbe6..8ac38e6 100644
> --- a/kernel/auditsc.c
> +++ b/kernel/auditsc.c
> @@ -2383,7 +2383,7 @@ void __audit_log_kern_module(char *name)
> context->type = AUDIT_KERN_MODULE;
> }
>
> -static void audit_log_task(struct audit_buffer *ab)
> +void audit_log_task(struct audit_buffer *ab)
> {
> kuid_t auid, uid;
> kgid_t gid;
> @@ -2404,6 +2404,7 @@ static void audit_log_task(struct audit_buffer *ab)
> audit_log_untrustedstring(ab, get_task_comm(comm, current));
> audit_log_d_path_exe(ab, current->mm);
> }
> +EXPORT_SYMBOL_GPL(audit_log_task);
>
> /**
> * audit_core_dumps - record information about processes that end abnormally
> diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
> index 13d7fe2..743f9e6 100644
> --- a/net/bridge/netfilter/ebtables.c
> +++ b/net/bridge/netfilter/ebtables.c
> @@ -1071,12 +1071,25 @@ static int do_replace_finish(struct net *net, struct ebt_replace *repl,
> if (audit_enabled) {
> struct audit_buffer *ab;
>
> - ab = audit_log_start(current->audit_context, GFP_KERNEL,
> - AUDIT_NETFILTER_CFG);
> - if (ab) {
> - audit_log_format(ab, "table=%s family=%u entries=%u",
> - repl->name, AF_BRIDGE, repl->nentries);
> - audit_log_end(ab);
> + if(!audit_dummy_context()) {
> + ab = audit_log_start(current->audit_context, GFP_KERNEL,
> + AUDIT_NETFILTER_CFG);
> + if (ab) {
> + audit_log_format(ab, "family=%u table=%s entries=%u",
> + AF_BRIDGE, repl->name,
> + repl->nentries);
> + audit_log_end(ab);
> + }
> + } else if(repl->nentries) {
> + ab = audit_log_start(NULL, GFP_KERNEL,
> + AUDIT_NETFILTER_CFGSOLO);
> + if (ab) {
> + audit_log_task(ab);
> + audit_log_format(ab, " family=%u table=%s entries=%u",
> + AF_BRIDGE, repl->name,
> + repl->nentries);
> + audit_log_end(ab);
> + }
If you have no other way, probably it is a good idea to wrap this code
around a function, eg. ebt_audit_replace_finish() ?
next prev parent reply other threads:[~2017-05-24 17:36 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-18 17:21 [PATCH 0/6 RFC] Address NETFILTER_CFG issues Richard Guy Briggs
2017-05-18 17:21 ` [PATCH 1/6 RFC] netfilter: normalize x_table function declarations Richard Guy Briggs
2017-05-24 17:37 ` Pablo Neira Ayuso
2017-05-24 22:30 ` Richard Guy Briggs
2017-05-18 17:21 ` [PATCH 2/6 RFC] netfilter: normalize ebtables " Richard Guy Briggs
2017-05-18 17:21 ` [PATCH 3/6 RFC] netfilter: audit only on xtables and ebtables syscall rule or standalone Richard Guy Briggs
2017-05-24 17:36 ` Pablo Neira Ayuso [this message]
2017-05-24 18:09 ` Richard Guy Briggs
2017-06-02 15:25 ` Paul Moore
2017-05-18 17:21 ` [PATCH 4/6 RFC] netfilter: ebtables: audit table registration Richard Guy Briggs
2017-06-02 15:27 ` Paul Moore
2017-05-18 17:21 ` [PATCH 5/6 RFC] netfilter: add audit operation field Richard Guy Briggs
2017-06-02 15:28 ` Paul Moore
2017-05-18 17:21 ` [PATCH 6/6 RFC] netfilter: add audit netns ID Richard Guy Briggs
2017-05-24 17:31 ` Pablo Neira Ayuso
2017-05-24 18:04 ` Richard Guy Briggs
2017-05-24 19:44 ` Eric W. Biederman
2017-06-02 15:32 ` Paul Moore
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170524173606.GB7439@salvia \
--to=pablo@netfilter.org \
--cc=eparis@redhat.com \
--cc=fw@strlen.de \
--cc=linux-audit@redhat.com \
--cc=netfilter-devel@vger.kernel.org \
--cc=pmoore@redhat.com \
--cc=rgb@redhat.com \
--cc=sgrubb@redhat.com \
--cc=tgraf@infradead.org \
--cc=twoerner@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).