public inbox for linux-audit@redhat.com
 help / color / mirror / Atom feed
From: Casey Schaufler <casey@schaufler-ca.com>
To: Paul Moore <paul@paul-moore.com>
Cc: casey.schaufler@intel.com, linux-audit@redhat.com
Subject: Re: [PATCH v15 03/23] LSM: Use lsmblob in security_audit_rule_match
Date: Mon, 9 Mar 2020 16:58:37 -0700	[thread overview]
Message-ID: <d6d50183-c10b-e565-3e90-5fa7bc6b5841@schaufler-ca.com> (raw)
In-Reply-To: <CAHC9VhS+3K-AAzo2Z9iYTCx6wax0h2_grXayULDWsCFKezf8Jg@mail.gmail.com>

On 3/6/2020 2:01 PM, Paul Moore wrote:
> On Fri, Feb 21, 2020 at 7:04 PM Casey Schaufler <casey@schaufler-ca.com> wrote:
>> Change the secid parameter of security_audit_rule_match
>> to a lsmblob structure pointer. Pass the entry from the
>> lsmblob structure for the approprite slot to the LSM hook.
>>
>> Change the users of security_audit_rule_match to use the
>> lsmblob instead of a u32. In some cases this requires a
>> temporary conversion using lsmblob_init() that will go
>> away when other interfaces get converted.
>>
>> Reviewed-by: Kees Cook <keescook@chromium.org>
>> Reviewed-by: John Johansen <john.johansen@canonical.com>
>> Acked-by: Stephen Smalley <sds@tycho.nsa.gov>
>> Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
>> ---
>>  include/linux/security.h            |  7 ++++---
>>  kernel/auditfilter.c                |  6 ++++--
>>  kernel/auditsc.c                    | 14 ++++++++++----
>>  security/integrity/ima/ima.h        |  4 ++--
>>  security/integrity/ima/ima_policy.c |  7 +++++--
>>  security/security.c                 |  8 +++++---
>>  6 files changed, 30 insertions(+), 16 deletions(-)
> ...
>
>> diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
>> index 3a44abf4fced..509eb21eff7f 100644
>> --- a/kernel/auditfilter.c
>> +++ b/kernel/auditfilter.c
>> @@ -1327,6 +1327,7 @@ int audit_filter(int msgtype, unsigned int listtype)
>>                         struct audit_field *f = &e->rule.fields[i];
>>                         pid_t pid;
>>                         u32 sid;
>> +                       struct lsmblob blob;
>>
>>                         switch (f->type) {
>>                         case AUDIT_PID:
>> @@ -1357,8 +1358,9 @@ int audit_filter(int msgtype, unsigned int listtype)
>>                         case AUDIT_SUBJ_CLR:
>>                                 if (f->lsm_isset) {
>>                                         security_task_getsecid(current, &sid);
>> -                                       result = security_audit_rule_match(sid,
>> -                                                  f->type, f->op,
>> +                                       lsmblob_init(&blob, sid);
>> +                                       result = security_audit_rule_match(
>> +                                                  &blob, f->type, f->op,
>>                                                    f->lsm_rules);
> Unless I'm mistaken this patch is almost exclusively the following pattern:
>
>   lsmblob_init(blob, sid);
>   security_audit_rule_match(blob, ...);
>
> ... which means we are assigning every array member in @blob the same
> value of "sid" and then sending that into the LSM where each LSM is
> going to then have to index into that array, to all get the same
> value, and then do their match.  I'm assuming this will make more
> sense as I progress through the rest of the patchset, but right now it
> seems like we could get by just fine with a u32 here.

When I do the next version I'll put considerably more effort into
explaining the scaffolding strategy. I'm definitely in that area where
the advantage of keeping patches small and the advantage of making a
change obvious are at odds. This will apply to the next few patches in
the series as well.



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


  reply	other threads:[~2020-03-09 23:58 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200222000407.110158-1-casey.ref@schaufler-ca.com>
2020-02-22  0:03 ` [PATCH v15 00/23] LSM: Module stacking for AppArmor Casey Schaufler
2020-02-22  0:03   ` Casey Schaufler
2020-02-22  0:03   ` [PATCH v15 01/23] LSM: Infrastructure management of the sock security Casey Schaufler
2020-02-22  0:03     ` Casey Schaufler
2020-02-22  0:03   ` [PATCH v15 02/23] LSM: Create and manage the lsmblob data structure Casey Schaufler
2020-02-22  0:03     ` Casey Schaufler
2020-03-06 20:55     ` Paul Moore
2020-02-22  0:03   ` [PATCH v15 03/23] LSM: Use lsmblob in security_audit_rule_match Casey Schaufler
2020-02-22  0:03     ` Casey Schaufler
2020-03-06 22:01     ` Paul Moore
2020-03-09 23:58       ` Casey Schaufler [this message]
2020-03-10  0:55         ` Paul Moore
2020-02-22  0:03   ` [PATCH v15 07/23] LSM: Use lsmblob in security_secid_to_secctx Casey Schaufler
2020-02-22  0:03     ` Casey Schaufler
2020-03-07  1:17     ` Paul Moore
2020-02-22  0:03   ` [PATCH v15 08/23] LSM: Use lsmblob in security_ipc_getsecid Casey Schaufler
2020-02-22  0:03     ` Casey Schaufler
2020-03-07  1:21     ` Paul Moore
2020-02-22  0:04   ` [PATCH v15 09/23] LSM: Use lsmblob in security_task_getsecid Casey Schaufler
2020-02-22  0:04     ` Casey Schaufler
2020-02-22  0:04   ` [PATCH v15 10/23] LSM: Use lsmblob in security_inode_getsecid Casey Schaufler
2020-02-22  0:04     ` Casey Schaufler
2020-02-22  0:04   ` [PATCH v15 11/23] LSM: Use lsmblob in security_cred_getsecid Casey Schaufler
2020-02-22  0:04     ` Casey Schaufler
2020-03-07  1:36     ` Paul Moore
2020-02-22  0:04   ` [PATCH v15 12/23] IMA: Change internal interfaces to use lsmblobs Casey Schaufler
2020-02-22  0:04     ` Casey Schaufler
2020-02-22  0:04   ` [PATCH v15 14/23] LSM: Ensure the correct LSM context releaser Casey Schaufler
2020-02-22  0:04     ` Casey Schaufler
2020-02-22  0:04   ` [PATCH v15 15/23] LSM: Use lsmcontext in security_secid_to_secctx Casey Schaufler
2020-02-22  0:04     ` Casey Schaufler
2020-03-07  2:01     ` Paul Moore
2020-02-22  0:04   ` [PATCH v15 20/23] Audit: Add subj_LSM fields when necessary Casey Schaufler
2020-02-22  0:04     ` Casey Schaufler
2020-03-07  2:18     ` Paul Moore
2020-03-07  2:24     ` Paul Moore
2020-03-10  1:25       ` Casey Schaufler
2020-03-10 21:46         ` Paul Moore
2020-02-22  0:04   ` [PATCH v15 21/23] Audit: Include object data for all security modules Casey Schaufler
2020-02-22  0:04     ` Casey Schaufler
2020-03-07  2:31     ` Paul Moore
2020-03-09 17:45       ` Casey Schaufler
2020-03-09 17:59         ` Paul Moore
2020-03-09 23:01           ` Casey Schaufler
2020-03-10 21:42             ` Paul Moore
2020-02-27 17:29   ` [PATCH v15 00/23] LSM: Module stacking for AppArmor Casey Schaufler
2020-03-03 17:22     ` Casey Schaufler
2020-03-03 17:54       ` Paul Moore
2020-03-03 17:58         ` Casey Schaufler
2020-03-06 17:14       ` Steve Grubb
2020-03-09 17:15         ` 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=d6d50183-c10b-e565-3e90-5fa7bc6b5841@schaufler-ca.com \
    --to=casey@schaufler-ca.com \
    --cc=casey.schaufler@intel.com \
    --cc=linux-audit@redhat.com \
    --cc=paul@paul-moore.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