From: Andrew Morton <akpm@linux-foundation.org>
To: "Andrew G. Morgan" <morgan@kernel.org>
Cc: "Serge E. Hallyn" <serue@us.ibm.com>,
lkml <linux-kernel@vger.kernel.org>,
Linux Security Modules List
<linux-security-module@vger.kernel.org>
Subject: Re: [PATCH] security: protect legacy apps from insufficient privilege
Date: Wed, 21 May 2008 22:41:37 -0700 [thread overview]
Message-ID: <20080521224137.8d5c0089.akpm@linux-foundation.org> (raw)
In-Reply-To: <483444C1.6050308@kernel.org>
On Wed, 21 May 2008 08:50:25 -0700 "Andrew G. Morgan" <morgan@kernel.org> wrote:
> + CAP_FOR_EACH_U32(i) {
> + if (i >= tocopy) {
> + /*
> + * Legacy capability sets have no upper bits
> + */
> + bprm->cap_post_exec_permitted.cap[i] = 0;
> + } else {
> + __u32 value_cpu;
> + /*
> + * pP' = (X & fP) | (pI & fI)
> + */
> + value_cpu = le32_to_cpu(caps->data[i].permitted);
> + bprm->cap_post_exec_permitted.cap[i] = (
> + current->cap_bset.cap[i] & value_cpu
> + ) | (
> + current->cap_inheritable.cap[i] &
> + le32_to_cpu(caps->data[i].inheritable)
> + );
> + if (value_cpu &
> + ~bprm->cap_post_exec_permitted.cap[i]) {
> + /*
> + * insufficient to execute correctly
> + */
> + ret = -EPERM;
> + }
> + }
> }
That makes my eyes say ow. The 80-col thing is a pain.
With a judiciously placed `continue' we can do this:
CAP_FOR_EACH_U32(i) {
__u32 value_cpu;
if (i >= tocopy) {
/*
* Legacy capability sets have no upper bits
*/
bprm->cap_post_exec_permitted.cap[i] = 0;
continue;
}
/*
* pP' = (X & fP) | (pI & fI)
*/
value_cpu = le32_to_cpu(caps->data[i].permitted);
bprm->cap_post_exec_permitted.cap[i] =
(current->cap_bset.cap[i] & value_cpu) |
(current->cap_inheritable.cap[i] &
le32_to_cpu(caps->data[i].inheritable));
if (value_cpu & ~bprm->cap_post_exec_permitted.cap[i]) {
/*
* insufficient to execute correctly
*/
ret = -EPERM;
}
}
OK?
next prev parent reply other threads:[~2008-05-22 5:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-21 15:50 Andrew G. Morgan
2008-05-21 20:34 ` Serge E. Hallyn
2008-05-22 5:18 ` Andrew G. Morgan
2008-05-22 5:41 ` Andrew Morton [this message]
2008-05-22 13:19 ` Andrew G. Morgan
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=20080521224137.8d5c0089.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=morgan@kernel.org \
--cc=serue@us.ibm.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
all inboxes | Powered by JetHome®