All of lore.kernel.org
 help / color / mirror / Atom feed
From: Casey Schaufler <casey@schaufler-ca.com>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: keescook@chromium.org, jmorris@namei.org,
	linux-security-module@vger.kernel.org,
	john.johansen@canonical.com, selinux@tycho.nsa.gov,
	Casey Schaufler <casey@schaufler-ca.com>
Subject: Re: [PATCH v5] LSM: Multiple concurrent LSMs
Date: Wed, 24 Oct 2012 11:32:48 -0700	[thread overview]
Message-ID: <50883450.8040301@schaufler-ca.com> (raw)
In-Reply-To: <201210242225.EFC43782.FLFQMHOOVFJOSt@I-love.SAKURA.ne.jp>

On 10/24/2012 6:25 AM, Tetsuo Handa wrote:
> Kees Cook wrote:
>> prctl control needs special handling. When an option is unhandled,
>> it'll return -ENOSYS. Also, some prctls return non-zero results, so
>> they could mask each other. I think it would make sense to walk the
>> composer list as long as the return value is -ENOSYS. As soon as it
>> isn't, then stop the call chain and return the value. Ultimately, this
>> means that the LSM order defines who get access to a given prctl
>> option (though with caps last).

I don't see why you think prctl is a special case. For starters,
only Yama does anything with it, and Yama does the expected
"call cap if you care" thingy. Yes, the -ENOSYS return is there,
but the current implementation will handle it correctly because
it's in cap_task_prctl.

What am I missing?

>>
>> int i, rc, called = 0;
>> for (i = 1; i < lsm_count; i++) {
>>     if (!composer_ops[i]->task_prctl)
>>         continue;
>>     rc = composer_ops[i]->task_prctl(option, arg2, arg3, arg4, arg5);
>>     called = 1;
>>     if (rc != -ENOSYS)
>>         return rc;
>> }
>> if (!called and composer_ops[0]->task_prctl)
>>     return composer_ops[0]->task_prctl(option, arg2, arg3, arg4, arg5);
>> return rc;
> With optimization, security_task_prctl() would look like below? I removed
> "int called" usage so that LSM modules which implement ->task_prctl need not to
> call cap_task_prctl(). Also, I assume "for (i = 1; i < lsm_count; i++)" will be
> changed to "for (i = 0; i < lsm_count; i++)" if this optimization is accepted.
>
> int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
> 			unsigned long arg4, unsigned long arg5)
> {
> 	int i;
> 	for (i = 1; i < lsm_count; i++) {
> 		int rc;
> 		if (!composer_ops[i]->task_prctl)
> 			continue;
> 		rc = composer_ops[i]->task_prctl(option, arg2, arg3, arg4, arg5);
> 		if (rc != -ENOSYS)
> 			return rc;
> 	}
> 	return cap_task_prctl(option, arg2, arg3, arg4, arg5);
> }
>
> Same thing applies to security_bprm_set_creds() etc. so that LSM modules which
> implement ->bprm_set_creds need not to call cap_bprm_set_creds()?
>
> int security_bprm_set_creds(struct linux_binprm *bprm)
> {
> 	int i;
> 	for (i = 1; i < lsm_count; i++) {
> 		int rc;
> 		if (!composer_ops[i]->bprm_set_creds)
> 			continue;
> 		rc = composer_ops[i]->bprm_set_creds(bprm);
> 		if (rc)
> 			return rc;
> 	}
> 	return cap_bprm_set_creds(bprm);
> }
>
> Casey Schaufler wrote:
>> I still think that we want to "call all" rather than "bail on fail".
> If prctl() is "bail out upon handled" and security_bprm_set_creds() is
> "bail out upon fail", wouldn't it look natural to do like below?
>
> int security_inode_permission(struct inode *inode, int mask)
> {
>  	if (unlikely(IS_PRIVATE(inode)))
>  		return 0;
> 	for (i = 1; i < lsm_count; i++) {
> 		int rc;
> 		if (!composer_ops[i]->inode_permission)
> 			continue;
> 		rc = composer_ops[i]->inode_permission(inode, mask);
> 		if (rc)
> 			return rc;
> 	}
> 	return 0;
> }
> --
> To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

  parent reply	other threads:[~2012-10-24 18:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-19 20:07 [PATCH v5] LSM: Multiple concurrent LSMs Casey Schaufler
     [not found] ` <CAGXu5jJKWZMJbX+kQZb1Qe64EjuZMEubCgtiV4COXWo9=hqPiQ@mail.gmail.com>
2012-10-19 21:39   ` Casey Schaufler
     [not found]   ` <201210242225.EFC43782.FLFQMHOOVFJOSt@I-love.SAKURA.ne.jp>
2012-10-24 18:32     ` Casey Schaufler [this message]
     [not found]     ` <201210250650.HAJ18213.FMtVQOFHJOLOFS@I-love.SAKURA.ne.jp>
     [not found]       ` <CAGXu5jKdLnDCpDzteY1v3aStAxAezdOykKUN1gDt69BZcBvwEA@mail.gmail.com>
     [not found]         ` <201210252116.DBJ56717.tVFFLJOOOSQHFM@I-love.SAKURA.ne.jp>
     [not found]           ` <201210252128.EGC12919.OFtFSMHQOOVLFJ@I-love.SAKURA.ne.jp>
     [not found]             ` <201210270127.BJF52683.QtMFVOFOLJSFOH@I-love.SAKURA.ne.jp>
2012-10-26 16:52               ` [PATCH v5.1] " Casey Schaufler
     [not found] ` <201210211206.DEI34330.FLFQMtFOOSJOHV@I-love.SAKURA.ne.jp>
2012-10-22 17:16   ` [PATCH v5] " Casey Schaufler
     [not found]   ` <201210211337.DAF60411.FMHOVSJOQOFtFL@I-love.SAKURA.ne.jp>
2012-10-22 17:47     ` 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=50883450.8040301@schaufler-ca.com \
    --to=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=penguin-kernel@I-love.SAKURA.ne.jp \
    --cc=selinux@tycho.nsa.gov \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.