linux-audit.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Paul Moore <paul@paul-moore.com>
To: Casey Schaufler <casey@schaufler-ca.com>
Cc: john.johansen@canonical.com, selinux@vger.kernel.org,
	James Morris <jmorris@namei.org>,
	linux-security-module@vger.kernel.org, linux-audit@redhat.com,
	casey.schaufler@intel.com, Stephen Smalley <sds@tycho.nsa.gov>
Subject: Re: [PATCH v28 22/25] Audit: Add record for multiple process LSM attributes
Date: Tue, 24 Aug 2021 10:45:15 -0400	[thread overview]
Message-ID: <CAHC9VhT-MfsU-azbV4QQ-asQFqdCG8fAeB-BOV3MKAdtSOW8Nw@mail.gmail.com> (raw)
In-Reply-To: <be20e3c8-a068-4aa2-be52-8601cf2d30a6@schaufler-ca.com>

On Fri, Aug 20, 2021 at 7:48 PM Casey Schaufler <casey@schaufler-ca.com> wrote:
> > On 8/20/2021 12:06 PM, Paul Moore wrote:
> >> Unless you explicitly enable audit on the kernel cmdline, e.g.
> >> "audit=1", processes started before userspace enables audit will not
> >> have a properly allocated audit_context; see the "if
> >> (likely(!audit_ever_enabled))" check at the top of audit_alloc() for
> >> the reason why.
>
> I found a hack-around that no one will like. I changed that check to be
>
> (likely(!audit_ever_enabled) && !lsm_multiple_contexts())
>
> It probably introduces a memory leak and/or performance degradation,
> but it has the desired affect.

I can't speak for everyone, but I know I don't like that as a solution
;)  I imagine such a change would also draw the ire of the never-audit
crowd and the distros themselves.  However, I understand the need to
just get *something* in place so you can continue to test/develop;
it's fine to keep that for now, but I'm going to be very disappointed
if that line finds its way into the next posted patchset revision.

I'm very much open to ideas but my gut feeling is that the end
solution is going to be changes to audit_log_start() and
audit_log_end().  In my mind the primary reason for this hunch is that
support for multiple LSMs[*] needs to be transparent to the various
callers in the kernel; this means the existing audit pattern of ...

  audit_log_start(...);
  audit_log_format(...);
  audit_log_end(...);

... should be preserved and be unchanged from what it is now.  We've
already talked in some general terms about what such changes might
look like, but to summarize the previous discussions, I think we would
need to think about the following things:

* Adding a timestamp/serial field to the audit_buffer struct, it could
even be in a union with the audit_context pointer as we would never
need both at the same time: if the audit_context ptr is non-NULL you
use that, otherwise you use the timestamp.  The audit_buffer timestamp
would not eliminate the need for the timestamp info in the
audit_context struct for what I hope are obvious reasons.

* Additional logic in audit_log_end() to generate additional ancillary
records for LSM labels.  This will likely mean storing the message
"type" passed to audit_log_start() in the audit_record struct and
using that information in audit_log_end() to decide if a LSM ancillary
record is needed.  Logistically this would likely mean converting the
existing audit_log_end() function into a static/private
__audit_log_end() and converting audit_log_end() into something like
this:

  void audit_log_end(ab)
  {
    __audit_log_end(ab); // rm the ab cleanup from __audit_log_end
    if (ab->anc_mlsm) {
      // generate the multiple lsm record
    }
    audit_buffer_free(ab);
  }

* Something else that I'm surely forgetting :)

At the end of all this we may find that the "local" audit_context
concept is no longer needed.  It was originally created to deal with
grouping ancillary records with non-syscall records into a single
event; while what we are talking about above is different, I believe
that our likely solution will also work to solve the original "local"
audit_context use case as well.  We'll have to see how this goes.

[*] I expect that the audit container ID work will have similar issues
and need a similar solution, I'm surprised it hasn't come up yet.

-- 
paul moore
www.paul-moore.com

--
Linux-audit mailing list
Linux-audit@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-audit


  reply	other threads:[~2021-08-24 14:45 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210722004758.12371-1-casey.ref@schaufler-ca.com>
2021-07-22  0:47 ` [PATCH v28 00/25] LSM: Module stacking for AppArmor Casey Schaufler
2021-07-22  0:47   ` [PATCH v28 01/25] LSM: Infrastructure management of the sock security Casey Schaufler
2021-07-22  0:47   ` [PATCH v28 02/25] LSM: Add the lsmblob data structure Casey Schaufler
2021-07-22  0:47   ` [PATCH v28 03/25] LSM: provide lsm name and id slot mappings Casey Schaufler
2021-07-22  0:47   ` [PATCH v28 04/25] IMA: avoid label collisions with stacked LSMs Casey Schaufler
2021-07-22  0:47   ` [PATCH v28 05/25] LSM: Use lsmblob in security_audit_rule_match Casey Schaufler
2021-07-22  0:47   ` [PATCH v28 06/25] LSM: Use lsmblob in security_kernel_act_as Casey Schaufler
2021-07-22  0:47   ` [PATCH v28 07/25] LSM: Use lsmblob in security_secctx_to_secid Casey Schaufler
2021-07-22  0:47   ` [PATCH v28 08/25] LSM: Use lsmblob in security_secid_to_secctx Casey Schaufler
2021-07-22  0:47   ` [PATCH v28 09/25] LSM: Use lsmblob in security_ipc_getsecid Casey Schaufler
2021-07-22  0:47   ` [PATCH v28 10/25] LSM: Use lsmblob in security_task_getsecid Casey Schaufler
2021-07-22  0:47   ` [PATCH v28 11/25] LSM: Use lsmblob in security_inode_getsecid Casey Schaufler
2021-07-22  0:47   ` [PATCH v28 12/25] LSM: Use lsmblob in security_cred_getsecid Casey Schaufler
2021-07-23 23:56     ` kernel test robot
2021-07-22  0:47   ` [PATCH v28 13/25] IMA: Change internal interfaces to use lsmblobs Casey Schaufler
2021-07-22  0:47   ` [PATCH v28 14/25] LSM: Specify which LSM to display Casey Schaufler
2021-07-22  0:47   ` [PATCH v28 15/25] LSM: Ensure the correct LSM context releaser Casey Schaufler
2021-07-22  0:47   ` [PATCH v28 16/25] LSM: Use lsmcontext in security_secid_to_secctx Casey Schaufler
2021-07-22  0:47   ` [PATCH v28 17/25] LSM: Use lsmcontext in security_inode_getsecctx Casey Schaufler
2021-07-22  0:47   ` [PATCH v28 18/25] LSM: security_secid_to_secctx in netlink netfilter Casey Schaufler
2021-07-22  0:47   ` [PATCH v28 19/25] NET: Store LSM netlabel data in a lsmblob Casey Schaufler
2021-07-22  0:47   ` [PATCH v28 20/25] LSM: Verify LSM display sanity in binder Casey Schaufler
2021-07-22  0:47   ` [PATCH v28 21/25] audit: support non-syscall auxiliary records Casey Schaufler
2021-07-22 17:02     ` kernel test robot
2021-07-22  0:47   ` [PATCH v28 22/25] Audit: Add record for multiple process LSM attributes Casey Schaufler
2021-07-22  4:08     ` kernel test robot
2021-08-12 20:59     ` Paul Moore
2021-08-12 22:38       ` Casey Schaufler
2021-08-13 15:31         ` Paul Moore
2021-08-13 18:48           ` Casey Schaufler
2021-08-13 20:43             ` Paul Moore
2021-08-13 21:47               ` Casey Schaufler
2021-08-16 18:57                 ` Paul Moore
2021-08-18 21:59                   ` Casey Schaufler
2021-08-19  0:47                     ` Paul Moore
2021-08-19  0:56                       ` Casey Schaufler
2021-08-19 22:41                         ` Casey Schaufler
2021-08-20 19:06                           ` Paul Moore
2021-08-20 19:17                             ` Casey Schaufler
2021-08-20 23:48                               ` Casey Schaufler
2021-08-24 14:45                                 ` Paul Moore [this message]
2021-08-24 15:20                                   ` Casey Schaufler
2021-08-24 16:14                                     ` Paul Moore
2021-07-22  0:47   ` [PATCH v28 23/25] Audit: Add record for multiple object " Casey Schaufler
2021-07-22  0:47   ` [PATCH v28 24/25] LSM: Add /proc attr entry for full LSM context Casey Schaufler
2021-07-22  0:47   ` [PATCH v28 25/25] AppArmor: Remove the exclusive flag Casey Schaufler

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=CAHC9VhT-MfsU-azbV4QQ-asQFqdCG8fAeB-BOV3MKAdtSOW8Nw@mail.gmail.com \
    --to=paul@paul-moore.com \
    --cc=casey.schaufler@intel.com \
    --cc=casey@schaufler-ca.com \
    --cc=jmorris@namei.org \
    --cc=john.johansen@canonical.com \
    --cc=linux-audit@redhat.com \
    --cc=linux-security-module@vger.kernel.org \
    --cc=sds@tycho.nsa.gov \
    --cc=selinux@vger.kernel.org \
    /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).