linux-security-module.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Moore <paul@paul-moore.com>
To: Casey Schaufler <casey@schaufler-ca.com>
Cc: casey.schaufler@intel.com, jmorris@namei.org,
	linux-security-module@vger.kernel.org, selinux@vger.kernel.org,
	linux-audit@redhat.com, keescook@chromium.org,
	john.johansen@canonical.com, penguin-kernel@i-love.sakura.ne.jp,
	sds@tycho.nsa.gov, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v30 24/28] Audit: Add framework for auxiliary records
Date: Sun, 5 Dec 2021 21:45:03 -0500	[thread overview]
Message-ID: <CAHC9VhS+jaTFbca7OFxoZ6uoUyaRoxjtm0m-K92px=61XUja5Q@mail.gmail.com> (raw)
In-Reply-To: <20211124014332.36128-25-casey@schaufler-ca.com>

On Tue, Nov 23, 2021 at 9:10 PM Casey Schaufler <casey@schaufler-ca.com> wrote:
>
> Add a list for auxiliary record data to the audit_buffer structure.
> Add the audit_stamp information to the audit_buffer as there's no
> guarantee that there will be an audit_context containing the stamp
> associated with the event. At audit_log_end() time create auxiliary
> records (none are currently defined) as have been added to the list.
>
> Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
> ---
>  kernel/audit.c   | 85 ++++++++++++++++++++++++++++++++++++++++++------
>  kernel/audit.h   |  1 +
>  kernel/auditsc.c |  2 ++
>  3 files changed, 78 insertions(+), 10 deletions(-)

...

> diff --git a/kernel/audit.c b/kernel/audit.c
> index 069cd4c81a61..2b22498d3532 100644
> --- a/kernel/audit.c
> +++ b/kernel/audit.c
> @@ -2393,6 +2403,61 @@ void audit_log_end(struct audit_buffer *ab)
>                 wake_up_interruptible(&kauditd_wait);
>         } else
>                 audit_log_lost("rate limit exceeded");
> +}
> +
> +/**
> + * audit_log_end - end one audit record
> + * @ab: the audit_buffer
> + *
> + * Let __audit_log_end() handle the message while the buffer housekeeping
> + * is done here.
> + * If there are other records that have been deferred for the event
> + * create them here.
> + */
> +void audit_log_end(struct audit_buffer *ab)
> +{
> +       struct audit_context_entry *entry;
> +       struct audit_context mcontext;
> +       struct audit_context *mctx;
> +       struct audit_buffer *mab;
> +       struct list_head *l;
> +       struct list_head *n;
> +
> +       if (!ab)
> +               return;
> +
> +       __audit_log_end(ab);
> +
> +       if (list_empty(&ab->aux_records)) {
> +               audit_buffer_free(ab);
> +               return;
> +       }
> +
> +       if (ab->ctx == NULL) {
> +               mcontext.context = AUDIT_CTX_AUXRECORD;

More on this below, but I don't think we need, or want, the line above.

> diff --git a/kernel/audit.h b/kernel/audit.h
> index 56560846f3b0..f87da8e0a5a4 100644
> --- a/kernel/audit.h
> +++ b/kernel/audit.h
> @@ -112,6 +112,7 @@ struct audit_context {
>                 AUDIT_CTX_UNUSED,       /* audit_context is currently unused */
>                 AUDIT_CTX_SYSCALL,      /* in use by syscall */
>                 AUDIT_CTX_URING,        /* in use by io_uring */
> +               AUDIT_CTX_AUXRECORD,    /* in use for auxiliary records */
>         } context;

We shouldn't need to do this here, and I wouldn't recommend this as a
solution even if we were running into problems in audit_log_exit().
The "context" field in the audit_context struct is to identify the
execution context of the task which is generating the audit record(s).

I'm trying to think of a case in this patchset where you would find
"audit_context->context == AUDIT_CTX_AUXRECORD" and I keep coming up
blank, are you certain you hit that case with the code you posted
here?  If so, could you help me understand that situation?

--
paul moore
www.paul-moore.com

  reply	other threads:[~2021-12-06  2:45 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20211124014332.36128-1-casey.ref@schaufler-ca.com>
2021-11-24  1:43 ` [PATCH v30 00/28] LSM: Module stacking for AppArmor Casey Schaufler
2021-11-24  1:43   ` [PATCH v30 01/28] integrity: disassociate ima_filter_rule from security_audit_rule Casey Schaufler
2021-12-06  2:43     ` Paul Moore
2021-11-24  1:43   ` [PATCH v30 02/28] LSM: Infrastructure management of the sock security Casey Schaufler
2021-11-24  1:43   ` [PATCH v30 03/28] LSM: Add the lsmblob data structure Casey Schaufler
2021-12-06  2:44     ` Paul Moore
2021-11-24  1:43   ` [PATCH v30 04/28] LSM: provide lsm name and id slot mappings Casey Schaufler
2021-11-24  1:43   ` [PATCH v30 05/28] IMA: avoid label collisions with stacked LSMs Casey Schaufler
2021-11-24  1:43   ` [PATCH v30 06/28] LSM: Use lsmblob in security_audit_rule_match Casey Schaufler
2021-11-24 13:19     ` kernel test robot
2021-12-06  2:44     ` Paul Moore
2021-11-24  1:43   ` [PATCH v30 07/28] LSM: Use lsmblob in security_kernel_act_as Casey Schaufler
2021-11-24  1:43   ` [PATCH v30 08/28] LSM: Use lsmblob in security_secctx_to_secid Casey Schaufler
2021-11-24  1:43   ` [PATCH v30 09/28] LSM: Use lsmblob in security_secid_to_secctx Casey Schaufler
2021-11-24  1:43   ` [PATCH v30 10/28] LSM: Use lsmblob in security_ipc_getsecid Casey Schaufler
2021-11-24  1:43   ` [PATCH v30 11/28] LSM: Use lsmblob in security_task_getsecid Casey Schaufler
2021-11-24  1:43   ` [PATCH v30 12/28] LSM: Use lsmblob in security_inode_getsecid Casey Schaufler
2021-11-24  1:43   ` [PATCH v30 13/28] LSM: Use lsmblob in security_cred_getsecid Casey Schaufler
2021-11-24  1:43   ` [PATCH v30 14/28] LSM: Specify which LSM to display Casey Schaufler
2021-11-24  1:43   ` [PATCH v30 15/28] LSM: Ensure the correct LSM context releaser Casey Schaufler
2021-11-24  1:43   ` [PATCH v30 16/28] LSM: Use lsmcontext in security_secid_to_secctx Casey Schaufler
2021-11-24  1:43   ` [PATCH v30 17/28] LSM: Use lsmcontext in security_inode_getsecctx Casey Schaufler
2021-11-24  1:43   ` [PATCH v30 18/28] LSM: security_secid_to_secctx in netlink netfilter Casey Schaufler
2021-11-24  1:43   ` [PATCH v30 19/28] NET: Store LSM netlabel data in a lsmblob Casey Schaufler
2021-11-24  1:43   ` [PATCH v30 20/28] binder: Pass LSM identifier for confirmation Casey Schaufler
2021-11-24  1:43   ` [PATCH v30 21/28] LSM: Extend security_secid_to_secctx to include module selection Casey Schaufler
2021-11-24  1:43   ` [PATCH v30 22/28] Audit: Keep multiple LSM data in audit_names Casey Schaufler
2021-12-06  2:44     ` Paul Moore
2021-11-24  1:43   ` [PATCH v30 23/28] Audit: Create audit_stamp structure Casey Schaufler
2021-12-06  2:44     ` Paul Moore
2021-11-24  1:43   ` [PATCH v30 24/28] Audit: Add framework for auxiliary records Casey Schaufler
2021-12-06  2:45     ` Paul Moore [this message]
2021-11-24  1:43   ` [PATCH v30 25/28] Audit: Add record for multiple task security contexts Casey Schaufler
2021-12-06  2:45     ` Paul Moore
2021-11-24  1:43   ` [PATCH v30 26/28] Audit: Add record for multiple object " Casey Schaufler
2021-11-24  7:41     ` kernel test robot
2021-11-24 13:40     ` kernel test robot
2021-12-06  2:45     ` Paul Moore
2021-11-24  1:43   ` [PATCH v30 27/28] LSM: Add /proc attr entry for full LSM context Casey Schaufler
2021-11-24  1:43   ` [PATCH v30 28/28] 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='CAHC9VhS+jaTFbca7OFxoZ6uoUyaRoxjtm0m-K92px=61XUja5Q@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=keescook@chromium.org \
    --cc=linux-audit@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --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).