2007-11-25 05:53:58

by Casey Schaufler

[permalink] [raw]
Subject: [PATCH] -mm (2.6.24-rc3-mm1) Smack using capabilities 32 and 33

diff -uprN libcap-2.02/libcap/include/linux/capability.h libcap-2.02-smack/libcap/include/linux/capability.h
--- libcap-2.02/libcap/include/linux/capability.h 2007-11-10 09:34:04.000000000 -0800
+++ libcap-2.02-smack/libcap/include/linux/capability.h 2007-11-24 13:35:38.000000000 -0800
@@ -314,6 +314,23 @@ typedef struct kernel_cap_struct {

#define CAP_SETFCAP 31

+/* Override MAC access.
+ The base kernel enforces no MAC policy.
+ An LSM may enforce a MAC policy, and if it does and it chooses
+ to implement capability based overrides of that policy, this is
+ the capability it should use to do so. */
+
+#define CAP_MAC_OVERRIDE 32
+
+/* Allow MAC configuration or state changes.
+ The base kernel requires no MAC configuration.
+ An LSM may enforce a MAC policy, and if it does and it chooses
+ to implement capability based checks on modifications to that
+ policy or the data required to maintain it, this is the
+ capability it should use to do so. */
+
+#define CAP_MAC_ADMIN 33
+
/*
* Bit location of each capability (used by user-space library and kernel)
*/
@@ -334,7 +351,8 @@ typedef struct kernel_cap_struct {
|CAP_TO_MASK(CAP_DAC_OVERRIDE) \
|CAP_TO_MASK(CAP_DAC_READ_SEARCH) \
|CAP_TO_MASK(CAP_FOWNER) \
- |CAP_TO_MASK(CAP_FSETID))
+ |CAP_TO_MASK(CAP_FSETID) \
+ |CAP_TO_MASK(CAP_MAC_OVERRIDE))

#if _LINUX_CAPABILITY_U32S != 2
# error Fix up hand-coded capability macro initializers


Attachments:
libcap-2.02.patch (1.49 kB)

2007-11-25 16:40:45

by Andrew G. Morgan

[permalink] [raw]
Subject: Re: [PATCH] -mm (2.6.24-rc3-mm1) Smack using capabilities 32 and 33

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1



Casey Schaufler wrote:
> diff -uprN -X linux-2.6.24-rc3-mm1-base/Documentation/dontdiff linux-2.6.24-rc3-mm1-base/include/linux/capability.h linux-2.6.24-rc3-mm1-smack/include/linux/capability.h
> --- linux-2.6.24-rc3-mm1-base/include/linux/capability.h 2007-11-22 01:51:36.000000000 -0800
> +++ linux-2.6.24-rc3-mm1-smack/include/linux/capability.h 2007-11-24 11:26:51.000000000 -0800
> @@ -314,6 +314,23 @@ typedef struct kernel_cap_struct {
>
> #define CAP_SETFCAP 31
>
> +/* Override MAC access.
> + The base kernel enforces no MAC policy.
> + An LSM may enforce a MAC policy, and if it does and it chooses
> + to implement capability based overrides of that policy, this is
> + the capability it should use to do so. */
> +
> +#define CAP_MAC_OVERRIDE 32
> +
> +/* Allow MAC configuration or state changes.
> + The base kernel requires no MAC configuration.
> + An LSM may enforce a MAC policy, and if it does and it chooses
> + to implement capability based checks on modifications to that
> + policy or the data required to maintain it, this is the
> + capability it should use to do so. */
> +
> +#define CAP_MAC_ADMIN 33
> +
> /*
> * Bit location of each capability (used by user-space library and kernel)
> */
> @@ -334,7 +351,8 @@ typedef struct kernel_cap_struct {
> | CAP_TO_MASK(CAP_DAC_OVERRIDE) \
> | CAP_TO_MASK(CAP_DAC_READ_SEARCH) \
> | CAP_TO_MASK(CAP_FOWNER) \
> - | CAP_TO_MASK(CAP_FSETID))
> + | CAP_TO_MASK(CAP_FSETID) \

The following looks a bit fishy:
> + | CAP_TO_MASK(CAP_MAC_OVERRIDE))

(1<<32) & 0xffffffff == 0

I think you need to define CAP_FS_MASK_B1.

Cheers

Andrew
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHSaPvmwytjiwfWMwRAjC8AJ9V4pntMzw4ayK1lb5mgUdjKYlCPQCeLkkz
jas90SJYDo58pQ8Skw1IK60=
=5PUQ
-----END PGP SIGNATURE-----

2007-11-25 17:13:41

by Casey Schaufler

[permalink] [raw]
Subject: Re: [PATCH] -mm (2.6.24-rc3-mm1) Smack using capabilities 32 and 33


--- Andrew Morgan <[email protected]> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
>
>
> Casey Schaufler wrote:
> > diff -uprN -X linux-2.6.24-rc3-mm1-base/Documentation/dontdiff
> linux-2.6.24-rc3-mm1-base/include/linux/capability.h
> linux-2.6.24-rc3-mm1-smack/include/linux/capability.h
> > --- linux-2.6.24-rc3-mm1-base/include/linux/capability.h 2007-11-22
> 01:51:36.000000000 -0800
> > +++ linux-2.6.24-rc3-mm1-smack/include/linux/capability.h 2007-11-24
> 11:26:51.000000000 -0800
> > @@ -314,6 +314,23 @@ typedef struct kernel_cap_struct {
> >
> > #define CAP_SETFCAP 31
> >
> > +/* Override MAC access.
> > + The base kernel enforces no MAC policy.
> > + An LSM may enforce a MAC policy, and if it does and it chooses
> > + to implement capability based overrides of that policy, this is
> > + the capability it should use to do so. */
> > +
> > +#define CAP_MAC_OVERRIDE 32
> > +
> > +/* Allow MAC configuration or state changes.
> > + The base kernel requires no MAC configuration.
> > + An LSM may enforce a MAC policy, and if it does and it chooses
> > + to implement capability based checks on modifications to that
> > + policy or the data required to maintain it, this is the
> > + capability it should use to do so. */
> > +
> > +#define CAP_MAC_ADMIN 33
> > +
> > /*
> > * Bit location of each capability (used by user-space library and kernel)
> > */
> > @@ -334,7 +351,8 @@ typedef struct kernel_cap_struct {
> > | CAP_TO_MASK(CAP_DAC_OVERRIDE) \
> > | CAP_TO_MASK(CAP_DAC_READ_SEARCH) \
> > | CAP_TO_MASK(CAP_FOWNER) \
> > - | CAP_TO_MASK(CAP_FSETID))
> > + | CAP_TO_MASK(CAP_FSETID) \
>
> The following looks a bit fishy:
> > + | CAP_TO_MASK(CAP_MAC_OVERRIDE))
>
> (1<<32) & 0xffffffff == 0
>
> I think you need to define CAP_FS_MASK_B1.

I think you're right, and I'll need to use it, too.


Casey Schaufler
[email protected]

2007-11-26 16:28:31

by Serge E. Hallyn

[permalink] [raw]
Subject: Re: [PATCH] -mm (2.6.24-rc3-mm1) Smack using capabilities 32 and 33

Quoting Casey Schaufler ([email protected]):
> From: Casey Schaufler <[email protected]>
>
> This patch takes advantage of the increase in capability bits
> to allocate capabilities for Mandatory Access Control. Whereas
> Smack was overloading a previously allocated capability it is
> now using a pair, one for overriding access control checks and
> the other for changes to the MAC configuration.
>
> The two capabilities allocated should be obvious in their intent.
> The comments in capability.h are intended to make it clear that
> there is no intention that implementations of MAC LSM modules
> be any more constrained by the presence of these capabilities
> than an implementation of DAC LSM modules are by the analogous
> DAC capabilities.
>
> Signed-off-by: Casey Schaufler <[email protected]>
>
> ---
>
> The companion patch for libcap-2.02 is provided as an attachment.
> The attachment is not a kernel patch, although it would be easy to
> mistake it for one.
>
> Thank you.
>
> include/linux/capability.h | 20 +++++++++++++++++++-
> security/smack/smack.h | 8 --------
> security/smack/smack_lsm.c | 8 ++++----
> security/smack/smackfs.c | 12 ++++++------
> 4 files changed, 29 insertions(+), 19 deletions(-)
>
> diff -uprN -X linux-2.6.24-rc3-mm1-base/Documentation/dontdiff linux-2.6.24-rc3-mm1-base/include/linux/capability.h linux-2.6.24-rc3-mm1-smack/include/linux/capability.h
> --- linux-2.6.24-rc3-mm1-base/include/linux/capability.h 2007-11-22 01:51:36.000000000 -0800
> +++ linux-2.6.24-rc3-mm1-smack/include/linux/capability.h 2007-11-24 11:26:51.000000000 -0800
> @@ -314,6 +314,23 @@ typedef struct kernel_cap_struct {
>
> #define CAP_SETFCAP 31
>
> +/* Override MAC access.
> + The base kernel enforces no MAC policy.
> + An LSM may enforce a MAC policy, and if it does and it chooses
> + to implement capability based overrides of that policy, this is
> + the capability it should use to do so. */
> +
> +#define CAP_MAC_OVERRIDE 32
> +
> +/* Allow MAC configuration or state changes.
> + The base kernel requires no MAC configuration.
> + An LSM may enforce a MAC policy, and if it does and it chooses
> + to implement capability based checks on modifications to that
> + policy or the data required to maintain it, this is the
> + capability it should use to do so. */
> +
> +#define CAP_MAC_ADMIN 33
> +

I do like the descriptions.

(Will wait for Andrew's comments to be addressed before reviewing the
rest)

thanks,
-serge