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,
selinux@tycho.nsa.gov, john.johansen@canonical.com,
eparis@redhat.com, keescook@chromium.org,
Casey Schaufler <casey@schaufler-ca.com>
Subject: Re: [PATCH v6] LSM: Multiple concurrent LSMs
Date: Tue, 06 Nov 2012 17:38:09 -0800 [thread overview]
Message-ID: <5099BB81.6000506@schaufler-ca.com> (raw)
In-Reply-To: <201211062144.CFB09368.JOQMFHFFVSOLtO@I-love.SAKURA.ne.jp>
On 11/6/2012 4:44 AM, Tetsuo Handa wrote:
> Overall, this version can eliminate overhead caused by unimplemented hooks.
> Then, I think we can afford allowing legal registration of trivial LKM-based
> LSM modules after the init process starts; LSM modules which wants to use
> lsm_blobs are limited to COMPOSER_MAX but LSM modules which do not need
> lsm_blobs are allowed to chain as many as the administrator wants.
So if an LSM includes no hooks that use blobs none would get
allocated. Yama, for example. There would have to be a separate
load order from blob slot number. I'm tempted to say it's too
rare a case to worry about, but we have the example of Yama
sitting there challenging that assertion.
I will consider this.
> Below are trivial checks.
>
>
> +struct lsm_list {
> + struct list_head list;
> + struct security_operations *ops;
> +};
>
> +static void lsm_delist(struct security_operations *ops, struct
> list_head *list)
> +{
> +#ifdef CONFIG_SECURITY_COMPOSER_DEBUG
> + static int leaked;
> +#endif
> + struct lsm_list *lp;
> +
> + list_for_each_entry(lp, list, list) {
> + if (lp->ops == ops) {
> + list_del_init(&lp->list);
> +#ifdef CONFIG_SECURITY_COMPOSER_DEBUG
> + leaked += sizeof(*lp);
> + pr_warn("%s lsm %s leaking %d bytes\n", __func__,
> + ops->name, leaked);
> +#endif
> + return;
> + }
> + }
> +}
>
> sizeof(*lp) should be 32 rather than 12 on x86_32 unless CONFIG_SLOB=y .
So the reality is that I'd be happy to report the number of lsm_list
blobs rather than the size, if that would be more palatable. Or, not
report a quantity at all, just say "Leaked some bytes while delisting
an LSM" and be done. Do you feel strongly one way or the other? Does
anyone else care?
> Seems unsafe list deletion. I think we need to use _rcu version since somebody
> (kernel threads) may be walking on the list when lsm_delist_ops() is called by
> the init process.
Here's the question, and I don't know the answer. lsm_delist() gets called
under two conditions: an early memory allocation failure that will almost
certainly precede a fatal memory allocation error, or a call to
security_reset_ops(), which is strictly a one-time thing. Might it be
better to have a lock of some sort to deal with the unlikely case of a
call to lsm_delist than to use the _rcu versions? I honestly don't know
what the cost of using _rcu is, so it may not matter.
Of course, I'd be fine with a panic if the LSM list entry allocation
failed because it just should never happen. As far as security_reset_ops()
is concerned, I think we'd only have to sell one distribution on the
virtue of removing it. Maybe.
> Maybe we want noinline attribute, for inlining lsm_delist() into
> lsm_delist_ops() is a bloat. And so does noinline attribute to lsm_enlist().
I'm hesitant to try to second guess the compilers on this. If a
performance expert told me to do it, I would, but I'd hate to be too
clever.
> +extern struct security_operations *composer_ops[];
>
> No longer used variable.
Right you are.
> void security_bprm_committed_creds(struct linux_binprm *bprm)
> {
> - security_ops->bprm_committed_creds(bprm);
> + struct lsm_list *lp;
> +
> + list_for_each_entry(lp, &lsm_bprm_committed_creds, list)
> + lp->ops->bprm_committed_creds(bprm);
> }
>
> Seems unsafe list traversal. I think we need to use _rcu version since somebody
> (kernel threads) may be walking on the list when lsm_delist_ops() is called by
> the init process.
As discussed above, I'm OK to switch to _rcu if the performance
doesn't matter. It would be unfortunate to add unnecessary overhead
for such an extremely special case.
> + for (; successes >= 0; successes--)
> + note[successes]->cred_free(cred);
>
> Seems wrong starting point.
>
> note[successes++] = lp->ops;
>
> wants to start from --successes, which can be simplified like
>
> while (successes)
> note[--successes]->cred_free(cred);
Yup. Will fix for the next version.
--
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.
next prev parent reply other threads:[~2012-11-07 1:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <50986053.9060105@schaufler-ca.com>
[not found] ` <CAGXu5j+vyGrHSp8nBb8kevqe6cXFEzXXt3NuziJQPBSFcRj_JQ@mail.gmail.com>
2012-11-06 3:10 ` [PATCH v6] LSM: Multiple concurrent LSMs Casey Schaufler
[not found] ` <201211062144.CFB09368.JOQMFHFFVSOLtO@I-love.SAKURA.ne.jp>
2012-11-07 1:38 ` Casey Schaufler [this message]
[not found] ` <201211072215.FFD82885.HLVJFMSOOtFFOQ@I-love.SAKURA.ne.jp>
2012-11-09 1:28 ` Casey Schaufler
2012-11-09 14:39 ` Eric Paris
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=5099BB81.6000506@schaufler-ca.com \
--to=casey@schaufler-ca.com \
--cc=eparis@redhat.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.