From: Paul Moore <paul@paul-moore.com>
To: Florian Westphal <fw@strlen.de>
Cc: Richard Weinberger <richard@nod.at>,
netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
pabeni@redhat.com, kuba@kernel.org, edumazet@google.com,
davem@davemloft.net, kadlec@netfilter.org, pablo@netfilter.org,
rgb@redhat.com, upstream+net@sigma-star.at
Subject: Re: [PATCH] netfilter: Record uid and gid in xt_AUDIT
Date: Wed, 9 Oct 2024 22:02:57 -0400 [thread overview]
Message-ID: <CAHC9VhTC=KAXe6w9xTG_rY4zAnNvPv-brQ7cTYftcty866inCw@mail.gmail.com> (raw)
In-Reply-To: <20241009223409.GE3714@breakpoint.cc>
On Wed, Oct 9, 2024 at 6:34 PM Florian Westphal <fw@strlen.de> wrote:
> Paul Moore <paul@paul-moore.com> wrote:
> > On Wed, Oct 9, 2024 at 5:34 PM Florian Westphal <fw@strlen.de> wrote:
> > > Richard Weinberger <richard@nod.at> wrote:
> > > > When recording audit events for new outgoing connections,
> > > > it is helpful to log the user info of the associated socket,
> > > > if available.
> > > > Therefore, check if the skb has a socket, and if it does,
> > > > log the owning fsuid/fsgid.
> > >
> > > AFAIK audit isn't namespace aware at all (neither netns nor userns), so I
> > > wonder how to handle this.
> > >
> > > We can't reject adding a -j AUDIT rule for non-init-net (we could, but I'm sure
> > > it'll break some setups...).
> > >
> > > But I wonder if we should at least skip the uid if the user namespace is
> > > 'something else'.
> >
> > This isn't unique to netfilter and the approach we take in the rest of
> > audit is to always display UIDs/GIDs in the context of the
> > init_user_ns; grep for from_kuid() in kernel/audit*.c.
>
> Hmm, audit_netlink_ok() bails with -ECONNREFUSED for current_user_ns()
> != &init_user_ns, so audit_log_common_recv_msg() won't be called from
> tasks that reside in a different userns.
We have a requirement that the audit daemon and audit management tools
run in the initial user namespace, but these are the audit collection
and configuration mechanisms, not the audit record generation
mechanisms. Regardless of the namespace limitations on auditd and
auditctl, we want to collect audit records across the system, which is
what we are doing in audit_tg().
> If you say its fine and audit can figure out that the retuned
> uid is not related to the initial user namespace, then ok.
>
> I was worried audit records could blame wrong/bogus user id.
Correct me if I'm wrong, but by using from_kXid(&init_user_ns, Xid) we
get the ID number that is correct for the init namespace, yes? If so,
that's what we want as right now all of the audit records, filters,
etc. are intended to be set from the context of the initial namespace.
--
paul-moore.com
next prev parent reply other threads:[~2024-10-10 2:03 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-09 20:32 [PATCH] netfilter: Record uid and gid in xt_AUDIT Richard Weinberger
2024-10-09 21:33 ` Florian Westphal
2024-10-09 21:46 ` Paul Moore
2024-10-09 22:34 ` Florian Westphal
2024-10-10 2:02 ` Paul Moore [this message]
2024-10-10 17:59 ` Florian Westphal
2024-10-10 19:13 ` Paul Moore
2024-10-10 6:27 ` Richard Weinberger
2024-10-10 13:48 ` Florian Westphal
2024-10-10 13:53 ` Jan Engelhardt
2024-10-10 20:09 ` Richard Weinberger
2024-10-11 1:27 ` Florian Westphal
2024-10-11 13:12 ` Richard Weinberger
2024-10-09 22:02 ` Paul Moore
2024-10-10 6:24 ` Richard Weinberger
2024-10-10 19:09 ` Paul Moore
2024-10-10 20:40 ` Richard Weinberger
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='CAHC9VhTC=KAXe6w9xTG_rY4zAnNvPv-brQ7cTYftcty866inCw@mail.gmail.com' \
--to=paul@paul-moore.com \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=kadlec@netfilter.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
--cc=rgb@redhat.com \
--cc=richard@nod.at \
--cc=upstream+net@sigma-star.at \
/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).