Linux Security Modules development
 help / color / mirror / Atom feed
From: Mimi Zohar <zohar@linux.ibm.com>
To: Casey Schaufler <casey@schaufler-ca.com>,
	casey.schaufler@intel.com, jmorris@namei.org,
	linux-security-module@vger.kernel.org, selinux@vger.kernel.org,
	Matthew Garrett <mjg59@google.com>
Cc: keescook@chromium.org, john.johansen@canonical.com,
	penguin-kernel@i-love.sakura.ne.jp, paul@paul-moore.com,
	sds@tycho.nsa.gov
Subject: Re: [PATCH v12 03/25] LSM: Use lsmblob in security_audit_rule_match
Date: Tue, 31 Dec 2019 12:14:57 -0500	[thread overview]
Message-ID: <1577812497.5874.97.camel@linux.ibm.com> (raw)
In-Reply-To: <20191224231915.7208-4-casey@schaufler-ca.com>

[Cc'ing Matthew Garret based on the additional bprm call to
process_measurement() - commit d906c10d8a31 ("IMA: Support using new
creds in appraisal policy")]

On Tue, 2019-12-24 at 15:18 -0800, Casey Schaufler wrote:
> diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c
> index f19a895ad7cd..193ddd55420b 100644
> --- a/security/integrity/ima/ima_policy.c
> +++ b/security/integrity/ima/ima_policy.c
> @@ -414,6 +414,7 @@ static bool ima_match_rules(struct ima_rule_entry *rule, struct inode *inode,
>  	for (i = 0; i < MAX_LSM_RULES; i++) {
>  		int rc = 0;
>  		u32 osid;
> +		struct lsmblob blob;
> 
>  		if (!rule->lsm[i].rule)
>  			continue;
> @@ -423,7 +424,8 @@ static bool ima_match_rules(struct ima_rule_entry *rule, struct inode *inode,
>  		case LSM_OBJ_ROLE:
>  		case LSM_OBJ_TYPE:
>  			security_inode_getsecid(inode, &osid);
> -			rc = security_filter_rule_match(osid,
> +			lsmblob_init(&blob, osid);
> +			rc = security_filter_rule_match(&blob,
>  							rule->lsm[i].type,
>  							Audit_equal,
>  							rule->lsm[i].rule);
> @@ -431,7 +433,8 @@ static bool ima_match_rules(struct ima_rule_entry *rule, struct inode *inode,
>  		case LSM_SUBJ_USER:
>  		case LSM_SUBJ_ROLE:
>  		case LSM_SUBJ_TYPE:
> -			rc = security_filter_rule_match(secid,
> +			lsmblob_init(&blob, secid);
> +			rc = security_filter_rule_match(&blob,

On the bprm hook, IMA calls process_measurement() twice.  The first
time the secid is passed as an argument based on a call to
security_task_getsecid(), while the second time it is based on
security_cred_getsecid().  process_measurement() passes the correct
secid converted to a blob, but instead of using the passed variable,
this code uses the locally defined blob field.  A later patch removes
the the lsmblob_init(), leaving the local blob uninitialized.
 Something is terribly wrong here.

Mimi

>  							rule->lsm[i].type,
>  							Audit_equal,
>  							rule->lsm[i].rule);



> 


  reply	other threads:[~2019-12-31 17:15 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20191224231915.7208-1-casey.ref@schaufler-ca.com>
2019-12-24 23:18 ` [PATCH v12 00/25] LSM: Module stacking for AppArmor Casey Schaufler
2019-12-24 23:18   ` [PATCH v12 01/25] LSM: Infrastructure management of the sock security Casey Schaufler
2019-12-24 23:18   ` [PATCH v12 02/25] LSM: Create and manage the lsmblob data structure Casey Schaufler
2019-12-24 23:18   ` [PATCH v12 03/25] LSM: Use lsmblob in security_audit_rule_match Casey Schaufler
2019-12-31 17:14     ` Mimi Zohar [this message]
2019-12-31 17:36       ` Casey Schaufler
2019-12-24 23:18   ` [PATCH v12 04/25] LSM: Use lsmblob in security_kernel_act_as Casey Schaufler
2019-12-24 23:18   ` [PATCH v12 05/25] net: Prepare UDS for security module stacking Casey Schaufler
2019-12-24 23:18   ` [PATCH v12 06/25] LSM: Use lsmblob in security_secctx_to_secid Casey Schaufler
2019-12-24 23:18   ` [PATCH v12 07/25] LSM: Use lsmblob in security_secid_to_secctx Casey Schaufler
2019-12-24 23:18   ` [PATCH v12 08/25] LSM: Use lsmblob in security_ipc_getsecid Casey Schaufler
2019-12-24 23:18   ` [PATCH v12 09/25] LSM: Use lsmblob in security_task_getsecid Casey Schaufler
2019-12-24 23:19   ` [PATCH v12 10/25] LSM: Use lsmblob in security_inode_getsecid Casey Schaufler
2019-12-24 23:19   ` [PATCH v12 11/25] LSM: Use lsmblob in security_cred_getsecid Casey Schaufler
2019-12-24 23:19   ` [PATCH v12 12/25] IMA: Change internal interfaces to use lsmblobs Casey Schaufler
2019-12-24 23:19   ` [PATCH v12 13/25] LSM: Specify which LSM to display Casey Schaufler
2019-12-24 23:19   ` [PATCH v12 14/25] LSM: Ensure the correct LSM context releaser Casey Schaufler
2019-12-24 23:19   ` [PATCH v12 15/25] LSM: Use lsmcontext in security_secid_to_secctx Casey Schaufler
2019-12-24 23:19   ` [PATCH v12 16/25] LSM: Use lsmcontext in security_dentry_init_security Casey Schaufler
2019-12-24 23:19   ` [PATCH v12 17/25] LSM: Use lsmcontext in security_inode_getsecctx Casey Schaufler
2019-12-24 23:19   ` [PATCH v12 18/25] LSM: security_secid_to_secctx in netlink netfilter Casey Schaufler
2019-12-24 23:19   ` [PATCH v12 19/25] NET: Store LSM netlabel data in a lsmblob Casey Schaufler
2019-12-24 23:19   ` [PATCH v12 20/25] LSM: Verify LSM display sanity in binder Casey Schaufler
2019-12-24 23:19   ` [PATCH v12 21/25] Audit: Add subj_LSM fields when necessary Casey Schaufler
2019-12-24 23:19   ` [PATCH v12 22/25] Audit: Include object data for all security modules Casey Schaufler
2019-12-24 23:19   ` [PATCH v12 23/25] NET: Add SO_PEERCONTEXT for multiple LSMs Casey Schaufler
2019-12-24 23:19   ` [PATCH v12 24/25] LSM: Add /proc attr entry for full LSM context Casey Schaufler
2019-12-24 23:19   ` [PATCH v12 25/25] AppArmor: Remove the exclusive flag Casey Schaufler
2019-12-24 23:58   ` [PATCH v12 00/25] LSM: Module stacking for AppArmor Casey Schaufler
2019-12-16 22:35 Casey Schaufler
2019-12-16 22:35 ` [PATCH v12 03/25] LSM: Use lsmblob in security_audit_rule_match Casey Schaufler
2019-12-17 17:34   ` Stephen Smalley
2019-12-17 22:01     ` Casey Schaufler
2019-12-17 23:47       ` Kees Cook
2019-12-18  0:28         ` Casey Schaufler
2019-12-18 13:16           ` Stephen Smalley
  -- strict thread matches above, loose matches on Subject: below --
2019-12-16 22:33 [PATCH v12 00/25] LSM: Module stacking for AppArmor Casey Schaufler
2019-12-16 22:33 ` [PATCH v12 03/25] LSM: Use lsmblob in security_audit_rule_match Casey Schaufler
2019-12-16 22:24 [PATCH v12 00/25] LSM: Module stacking for AppArmor Casey Schaufler
2019-12-16 22:24 ` [PATCH v12 03/25] LSM: Use lsmblob in security_audit_rule_match 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=1577812497.5874.97.camel@linux.ibm.com \
    --to=zohar@linux.ibm.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-security-module@vger.kernel.org \
    --cc=mjg59@google.com \
    --cc=paul@paul-moore.com \
    --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