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: jmorris@namei.org, linux-security-module@vger.kernel.org,
	john.johansen@canonical.com, selinux@tycho.nsa.gov,
	keescook@chromium.org, Casey Schaufler <casey@schaufler-ca.com>
Subject: Re: [PATCH v5] LSM: Multiple concurrent LSMs
Date: Mon, 22 Oct 2012 10:16:58 -0700	[thread overview]
Message-ID: <50857F8A.1090309@schaufler-ca.com> (raw)
In-Reply-To: <201210211206.DEI34330.FLFQMtFOOSJOHV@I-love.SAKURA.ne.jp>

On 10/20/2012 8:06 PM, Tetsuo Handa wrote:
> Casey Schaufler wrote:
>> +#define call_int_hook(RC, FUNC, ...)					\
>> +	do {								\
>> +		int called = 0;						\
>> +		int thisrc;						\
>> +		int i;							\
>> +									\
>> +		RC = 0;							\
>> +		for (i = 1; i < lsm_count; i++) {			\
>> +			if (!composer_ops[i]->FUNC)			\
>> +				continue;				\
>> +			thisrc = composer_ops[i]->FUNC(__VA_ARGS__);	\
>> +			if (thisrc)					\
>> +				RC = thisrc;				\
>> +			called = 1;					\
>> +		}							\
>> +		if (!called && composer_ops[0]->FUNC)			\
>> +			RC = composer_ops[0]->FUNC(__VA_ARGS__);	\
>> +	} while (0)
> Why can't we simplify like below? What is special with composer_ops[0] ?

composer_ops[0] is the capability operations. They get called if and
only if no LSM supplies something for a particular hook. LSMs are allowed
to call the capability hook themselves or not as they see fit. Thus the
special case for composer_ops[0].

>
> #define call_int_hook(RC, FUNC, ...)					\
> 	do {								\
> 		int i;							\
> 									\
> 		RC = 0;							\
> 		for (i = 0; i < lsm_count; i++) {			\
> 			if (!composer_ops[i]->FUNC)			\
> 				continue;				\
> 			RC = composer_ops[i]->FUNC(__VA_ARGS__);	\
> 			if (RC)						\
> 				break;					\
> 		}							\
> 	} while (0)
>
>
>
>>  int security_inode_alloc(struct inode *inode)
>>  {
>> -	inode->i_security = NULL;
>> -	return security_ops->inode_alloc_security(inode);
>> +	int i;
>> +	int rc;
>> +	struct lsm_blob tblob;
>> +	struct lsm_blob *bp = NULL;
>> +
>> +	memset(&tblob, 0, sizeof(tblob));
>> +	inode->i_security = &tblob;
>> +
>> +	for (rc = 0, i = 1; i < lsm_count && rc == 0; i++)
>> +		if (composer_ops[i]->inode_alloc_security)
>> +			rc = composer_ops[i]->inode_alloc_security(inode);
>> +
>> +	if (tblob.lsm_setcount != 0) {
>> +		if (rc == 0)
>> +			bp = kmemdup(&tblob, sizeof(tblob), GFP_KERNEL);
>> +		if (bp == NULL) {
>> +			if (rc == 0)
>> +				rc = -ENOMEM;
>> +			for (i--; i >= 1; i--) {
>> +				if (composer_ops[i]->inode_free_security)
> 	if (!composer_ops[i]->inode_free_security)


Yes, indeed.


>
>> +					continue;
>> +				composer_ops[i]->inode_free_security(inode);
>> +			}
>> +			lsm_blob_cleanup(rc, &tblob, __func__);
>> +		}
>> +	}
>> +	inode->i_security = bp;
>> +	return rc;
>>  }
> --
> 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-22 17:17 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
     [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   ` Casey Schaufler [this message]
     [not found]   ` <201210211337.DAF60411.FMHOVSJOQOFtFL@I-love.SAKURA.ne.jp>
2012-10-22 17:47     ` [PATCH v5] " 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=50857F8A.1090309@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.