* [PATCH resend] define convenient securebits masks for prctl users
@ 2009-10-28 14:02 Serge E. Hallyn
[not found] ` <20091028140236.GA8157-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Serge E. Hallyn @ 2009-10-28 14:02 UTC (permalink / raw)
To: lkml
Cc: Andrew G. Morgan, Michael Kerrisk, Ulrich Drepper,
linux-api-u79uwXL29TY76Z2rM5mHXA, Stephen Rothwell
[ Are there any objections to exporting securebits.h? If not,
can this patch be pushed to linux-next? ]
The securebits are used by passing them to prctl with the
PR_{S,G}ET_SECUREBITS commands. But the defines must be
shifted to be used in prctl, which begs to be confused and
misused by userspace. So define some more convenient
values for userspace to specify. This way userspace does
prctl(PR_SET_SECUREBITS, SECBIT_NOROOT);
instead of
prctl(PR_SET_SECUREBITS, 1 << SECURE_NOROOT);
(Thanks to Michael for the idea)
This patch also adds include/linux/securebits to the installed headers.
Then perhaps it can be included by glibc's sys/prctl.h.
Changelog:
Oct 14: (Suggestions by Michael Kerrisk):
1. spell out SETUID in SECBIT_NO_SETUID*
2. SECBIT_X_LOCKED does not imply SECBIT_X
3. add definitions for keepcaps
Oct 14: As suggested by Michael Kerrisk, don't
use SB_* as that convention is already in
use. Use SECBIT_ prefix instead.
Signed-off-by: Serge E. Hallyn <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Acked-by: Andrew G. Morgan <morgan-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Acked-by: Michael Kerrisk <mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Ulrich Drepper <drepper-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
include/linux/Kbuild | 1 +
include/linux/securebits.h | 22 ++++++++++++++++------
2 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/include/linux/Kbuild b/include/linux/Kbuild
index 3e8bd18..94fe9f7 100644
--- a/include/linux/Kbuild
+++ b/include/linux/Kbuild
@@ -328,6 +328,7 @@ unifdef-y += scc.h
unifdef-y += sched.h
unifdef-y += screen_info.h
unifdef-y += sdla.h
+unifdef-y += securebits.h
unifdef-y += selinux_netlink.h
unifdef-y += sem.h
unifdef-y += serial_core.h
diff --git a/include/linux/securebits.h b/include/linux/securebits.h
index d2c5ed8..9ad109e 100644
--- a/include/linux/securebits.h
+++ b/include/linux/securebits.h
@@ -1,6 +1,13 @@
#ifndef _LINUX_SECUREBITS_H
#define _LINUX_SECUREBITS_H 1
+/* Each securesetting is implemented using two bits. One bit specifies
+ whether the setting is on or off. The other bit specify whether the
+ setting is locked or not. A setting which is locked cannot be
+ changed from user-level. */
+#define issecure_mask(X) (1 << (X))
+#define issecure(X) (issecure_mask(X) & current_cred_xxx(securebits))
+
#define SECUREBITS_DEFAULT 0x00000000
/* When set UID 0 has no special privileges. When unset, we support
@@ -12,6 +19,9 @@
#define SECURE_NOROOT 0
#define SECURE_NOROOT_LOCKED 1 /* make bit-0 immutable */
+#define SECBIT_NOROOT (issecure_mask(SECURE_NOROOT))
+#define SECBIT_NOROOT_LOCKED (issecure_mask(SECURE_NOROOT_LOCKED))
+
/* When set, setuid to/from uid 0 does not trigger capability-"fixup".
When unset, to provide compatiblility with old programs relying on
set*uid to gain/lose privilege, transitions to/from uid 0 cause
@@ -19,6 +29,10 @@
#define SECURE_NO_SETUID_FIXUP 2
#define SECURE_NO_SETUID_FIXUP_LOCKED 3 /* make bit-2 immutable */
+#define SECBIT_NO_SETUID_FIXUP (issecure_mask(SECURE_NO_SETUID_FIXUP))
+#define SECBIT_NO_SETUID_FIXUP_LOCKED \
+ (issecure_mask(SECURE_NO_SETUID_FIXUP_LOCKED))
+
/* When set, a process can retain its capabilities even after
transitioning to a non-root user (the set-uid fixup suppressed by
bit 2). Bit-4 is cleared when a process calls exec(); setting both
@@ -27,12 +41,8 @@
#define SECURE_KEEP_CAPS 4
#define SECURE_KEEP_CAPS_LOCKED 5 /* make bit-4 immutable */
-/* Each securesetting is implemented using two bits. One bit specifies
- whether the setting is on or off. The other bit specify whether the
- setting is locked or not. A setting which is locked cannot be
- changed from user-level. */
-#define issecure_mask(X) (1 << (X))
-#define issecure(X) (issecure_mask(X) & current_cred_xxx(securebits))
+#define SECBIT_KEEP_CAPS (issecure_mask(SECURE_KEEP_CAPS))
+#define SECBIT_KEEP_CAPS_LOCKED (issecure_mask(SECURE_KEEP_CAPS_LOCKED))
#define SECURE_ALL_BITS (issecure_mask(SECURE_NOROOT) | \
issecure_mask(SECURE_NO_SETUID_FIXUP) | \
--
1.6.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH resend] define convenient securebits masks for prctl users
[not found] ` <20091028140236.GA8157-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
@ 2009-10-29 2:33 ` Stephen Rothwell
2009-10-29 14:05 ` Serge E. Hallyn
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Rothwell @ 2009-10-29 2:33 UTC (permalink / raw)
To: Serge E. Hallyn
Cc: lkml, Andrew G. Morgan, Michael Kerrisk, Ulrich Drepper,
linux-api-u79uwXL29TY76Z2rM5mHXA, James Morris
[-- Attachment #1: Type: text/plain, Size: 1156 bytes --]
Hi Serge,
On Wed, 28 Oct 2009 09:02:36 -0500 "Serge E. Hallyn" <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org> wrote:
>
> [ Are there any objections to exporting securebits.h? If not,
> can this patch be pushed to linux-next? ]
I am not sure which tree this belongs in? Maybe security-testing (James
cc'd)?
> diff --git a/include/linux/securebits.h b/include/linux/securebits.h
> index d2c5ed8..9ad109e 100644
> --- a/include/linux/securebits.h
> +++ b/include/linux/securebits.h
> @@ -1,6 +1,13 @@
> #ifndef _LINUX_SECUREBITS_H
> #define _LINUX_SECUREBITS_H 1
>
> +/* Each securesetting is implemented using two bits. One bit specifies
> + whether the setting is on or off. The other bit specify whether the
> + setting is locked or not. A setting which is locked cannot be
> + changed from user-level. */
> +#define issecure_mask(X) (1 << (X))
> +#define issecure(X) (issecure_mask(X) & current_cred_xxx(securebits))
You want this second define protected by ifdef __KERNEL__ ...
--
Cheers,
Stephen Rothwell sfr-3FnU+UHB4dNDw9hX6IcOSA@public.gmane.org
http://www.canb.auug.org.au/~sfr/
[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH resend] define convenient securebits masks for prctl users
2009-10-29 2:33 ` Stephen Rothwell
@ 2009-10-29 14:05 ` Serge E. Hallyn
0 siblings, 0 replies; 3+ messages in thread
From: Serge E. Hallyn @ 2009-10-29 14:05 UTC (permalink / raw)
To: Stephen Rothwell
Cc: lkml, Andrew G. Morgan, Michael Kerrisk, Ulrich Drepper,
linux-api, James Morris
Quoting Stephen Rothwell (sfr@canb.auug.org.au):
> Hi Serge,
>
> On Wed, 28 Oct 2009 09:02:36 -0500 "Serge E. Hallyn" <serue@us.ibm.com> wrote:
> >
> > [ Are there any objections to exporting securebits.h? If not,
> > can this patch be pushed to linux-next? ]
>
> I am not sure which tree this belongs in? Maybe security-testing (James
> cc'd)?
I don't know why that didn't occur to me! Thanks, I'll pursue
that :)
> > diff --git a/include/linux/securebits.h b/include/linux/securebits.h
> > index d2c5ed8..9ad109e 100644
> > --- a/include/linux/securebits.h
> > +++ b/include/linux/securebits.h
> > @@ -1,6 +1,13 @@
> > #ifndef _LINUX_SECUREBITS_H
> > #define _LINUX_SECUREBITS_H 1
> >
> > +/* Each securesetting is implemented using two bits. One bit specifies
> > + whether the setting is on or off. The other bit specify whether the
> > + setting is locked or not. A setting which is locked cannot be
> > + changed from user-level. */
> > +#define issecure_mask(X) (1 << (X))
> > +#define issecure(X) (issecure_mask(X) & current_cred_xxx(securebits))
>
> You want this second define protected by ifdef __KERNEL__ ...
True, userspace doesn't need to see those. Will sanitize and resend.
thanks,
-serge
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-10-29 14:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-28 14:02 [PATCH resend] define convenient securebits masks for prctl users Serge E. Hallyn
[not found] ` <20091028140236.GA8157-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-10-29 2:33 ` Stephen Rothwell
2009-10-29 14:05 ` Serge E. Hallyn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).