Re: [PATCH] Implement file posix capabilities

2007-01-24 Thread Casey Schaufler

--- Bill O'Donnell <[EMAIL PROTECTED]> wrote:

> ... That said, can one expect, through
> the use of these enhanced capabilities,
> to be able to add some finer grain 
> capabilities based on a specific userid?

POSIX capabilities are explictly disjoint from
userids in the kernel, and this is by design.
You could provide limited capability sets to
users at the application layer.

> In Chris' ping example,
> the suid is removed from /bin/ping to restrict it to
> root, and a 
> capability added to allow any user to execute it. 
> Can that example
> be extended to make it so only a _particular_ user
> can execute it?

Give the file the capability and set an
ACL that allows only that user execute access.

> I realize with SELinux, one could achieve the goal,
> but as a stopgap,
> can capabilities be used to get there?

Certainly, as above.

> Thanks,
> Bill
> 
> -- 
> Bill O'Donnell
> SGI

Have a look in /etc/irix.cap on a Trix box
some time. I suspect there might be one in
your facility.



Casey Schaufler
[EMAIL PROTECTED]
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Implement file posix capabilities

2007-01-24 Thread Bill O'Donnell
I'm in the process of testing the (backported) capabilities patch 
and Kaigai's userspace tools on a SLES10 based x86-64 target (2.6.16).  
Chris Friedhoff's examples (http://www.friedhoff.org/fscaps.html)
run cleanly.  That said, can one expect, through the use of these
enhanced capabilities, to be able to add some finer grain 
capabilities based on a specific userid?  In Chris' ping example,
the suid is removed from /bin/ping to restrict it to root, and a 
capability added to allow any user to execute it.  Can that example
be extended to make it so only a _particular_ user can execute it?
I realize with SELinux, one could achieve the goal, but as a stopgap,
can capabilities be used to get there?
Thanks,
Bill

-- 
Bill O'Donnell
SGI
[EMAIL PROTECTED]
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Implement file posix capabilities

2007-01-24 Thread Bill O'Donnell
I'm in the process of testing the (backported) capabilities patch 
and Kaigai's userspace tools on a SLES10 based x86-64 target (2.6.16).  
Chris Friedhoff's examples (http://www.friedhoff.org/fscaps.html)
run cleanly.  That said, can one expect, through the use of these
enhanced capabilities, to be able to add some finer grain 
capabilities based on a specific userid?  In Chris' ping example,
the suid is removed from /bin/ping to restrict it to root, and a 
capability added to allow any user to execute it.  Can that example
be extended to make it so only a _particular_ user can execute it?
I realize with SELinux, one could achieve the goal, but as a stopgap,
can capabilities be used to get there?
Thanks,
Bill

-- 
Bill O'Donnell
SGI
[EMAIL PROTECTED]
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Implement file posix capabilities

2007-01-24 Thread Casey Schaufler

--- Bill O'Donnell [EMAIL PROTECTED] wrote:

 ... That said, can one expect, through
 the use of these enhanced capabilities,
 to be able to add some finer grain 
 capabilities based on a specific userid?

POSIX capabilities are explictly disjoint from
userids in the kernel, and this is by design.
You could provide limited capability sets to
users at the application layer.

 In Chris' ping example,
 the suid is removed from /bin/ping to restrict it to
 root, and a 
 capability added to allow any user to execute it. 
 Can that example
 be extended to make it so only a _particular_ user
 can execute it?

Give the file the capability and set an
ACL that allows only that user execute access.

 I realize with SELinux, one could achieve the goal,
 but as a stopgap,
 can capabilities be used to get there?

Certainly, as above.

 Thanks,
 Bill
 
 -- 
 Bill O'Donnell
 SGI

Have a look in /etc/irix.cap on a Trix box
some time. I suspect there might be one in
your facility.



Casey Schaufler
[EMAIL PROTECTED]
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Implement file posix capabilities

2006-12-01 Thread KaiGai Kohei

Oops, it's my stupid bug.


Ah, this actually makes sense.  The setfcaps usage() statement does

for (i=0; _cap_names[i]; i++) {
printf...

so it expects _cap_names to end with a terminating NULL, but that
doesn't seem to be the case in cap_names.h in libcap.

KaiGai, perhaps setfcaps should do something like

diff setfcaps.c.orig setfcaps.c
25c25
< for (i=0; _cap_names[i]; i++)
---

for (i=0; i<__CAP_BITS; i++)


I fixed the matter as follows:

[EMAIL PROTECTED] libcap-1.10.kg]$ env LANG=C svn diff -r2:3
Index: libcap/_makenames.c
===
--- libcap/_makenames.c (revision 2)
+++ libcap/_makenames.c (revision 3)
@@ -45,6 +45,7 @@
   "#define __CAP_BITS   %d\n"
   "\n"
   "#ifdef LIBCAP_PLEASE_INCLUDE_ARRAY\n"
+  "  int const _cap_names_num = __CAP_BITS;\n"
   "  char const *_cap_names[__CAP_BITS] = {\n", maxcaps);

 for (i=0; i
 #include 

+extern int const _cap_names_num;
 extern char const *_cap_names[];

 static void usage() {
@@ -21,8 +22,8 @@
 int i;

 fputs(message, stderr);
-for (i=0; _cap_names[i]; i++)
-   fprintf(stderr, "%s%s", i%4==0 ? "\n\t" : ", ", _cap_names[i]);
+for (i=0; i < _cap_names_num; i++)
+fprintf(stderr, "%s%s", i%4==0 ? "\n\t" : ", ", _cap_names[i]);
 fputc('\n', stderr);
 exit(0);
 }
[EMAIL PROTECTED] libcap-1.10.kg]$

Because '__CAP_BITS' is decided at compiling time, I think it's not
appropriate to indicate the length of _cap_names[] which is linked
at run time.
Therefore, I add a new integer variable _cap_names_num to represent
the length of _cap_names at run time.

You can download it from http://www.kaigai.gr.jp/index.php?FrontPage#b556e50d

Thanks,
--
KaiGai Kohei <[EMAIL PROTECTED]>
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Implement file posix capabilities

2006-12-01 Thread Bill O'Donnell
On Thu, Nov 30, 2006 at 04:57:07PM -0600, Serge E. Hallyn wrote:
| Quoting Bill O'Donnell ([EMAIL PROTECTED]):
| > The memory fault when setfcaps is run as noted in #4 below also occurs
| > on RHEL5 IA64 (2.6.18 kernel-2.6.18-1.2747.el5 with Serge's capability 
patch,
| > and Kaigai's userspace tools installed).
| > 
| > On Wed, Nov 29, 2006 at 02:40:13PM -0600, Bill O'Donnell wrote:
| > | Once again, running into problems when trying this patch on SLES-10 IA64,
| > | (Linux certify 2.6.18 #2 SMP PREEMPT Wed Nov 29 13:11:28 CST 2006 ia64)
| > |
| > | 1) replaced the ancient /lib/libcap.so.1.92 with less ancient 
libcap.so.1.10
| > |
| > | 2) successfully applied Serge's patch to SLES 2.6.18 sources and rebooted
| > |
| > | 3) installed Kaigai's userspace tools... no problems evident
| > |
| > | 4) ran setfcaps to see capabilities... (note Memory fault):
| > |
| > | certify:~/libcap-1.10 # setfcaps
| > | usage: setfcaps   ...
| > | cap_chown, cap_dac_override, cap_dac_read_search, cap_fowner
| > |   cap_fsetid, cap_kill, cap_setgid, cap_setuid
| > |   cap_setpcap, cap_linux_immutable,
| > |   cap_net_bind_service, cap_net_broadcast
| > | cap_net_admin, cap_net_raw, cap_ipc_lock, cap_ipc_owner
| > |   cap_sys_module, cap_sys_rawio, cap_sys_chroot, cap_sys_ptrace
| > |   cap_sys_pacct, cap_sys_admin, cap_sys_boot, cap_sys_nice
| > |   cap_sys_resource, cap_sys_time,
| > |   cap_sys_tty_config, cap_mknod
| > | cap_lease, cap_audit_write, cap_audit_controlMemory fault
| 
| Ah, this actually makes sense.  The setfcaps usage() statement does
| 
|   for (i=0; _cap_names[i]; i++) {
|   printf...
| 
| so it expects _cap_names to end with a terminating NULL, but that
| doesn't seem to be the case in cap_names.h in libcap.
| 
| KaiGai, perhaps setfcaps should do something like
| 
| diff setfcaps.c.orig setfcaps.c
| 25c25
| < for (i=0; _cap_names[i]; i++)
| ---
| > for (i=0; i<__CAP_BITS; i++)

I brute-force hardcoded the limit on this for loop (i< 31), and rebuilt
Kaigai's tools, and retested (again, on this RHEL5 IA64 target.  It all
works now.  I ran through Chris Friedhoff's "test protocol", and it
went swimmingly (http://www.friedhoff.org/fscaps.html).

Then I went back to my SLES-10 IA64 target, and repeated the fixup for
Kaigai's tools.  It now works, providing I changeout the antique 
libcap.so.92 for newer libcap.so.10 (why the version number is lower is 
beyond me).

So, for my limited IA64 test target set, the following are true, 
providing Serge's capabilities kernel patch is applied, and Kaigai's 
userspace tools are utilized (obviously with the brute-force hack 
to setfcaps.c):

1) RHEL5 - libcap.so.10 is "stock":  
   caps patch and hacked u-space tools PASS the tests.

2) SLES10 - libcap.so.92 is "stock": 
   caps patch and hacked u-space tools FAIL the tests.

3) SLES10 - "stock" libcap.so.92 replaced with newer libcap.so.10: 
   caps patch and hacked u-space tools PASS the tests.


The question that remains unanswered: why is SLES using such an old
libcap, and are they likely to replace it with the more accepted
version (libcap.so.10) soon?

Thanks,
-Bill

-- 
Bill O'Donnell
SGI
[EMAIL PROTECTED]
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Implement file posix capabilities

2006-12-01 Thread Bill O'Donnell
On Thu, Nov 30, 2006 at 04:57:07PM -0600, Serge E. Hallyn wrote:
| Quoting Bill O'Donnell ([EMAIL PROTECTED]):
|  The memory fault when setfcaps is run as noted in #4 below also occurs
|  on RHEL5 IA64 (2.6.18 kernel-2.6.18-1.2747.el5 with Serge's capability 
patch,
|  and Kaigai's userspace tools installed).
|  
|  On Wed, Nov 29, 2006 at 02:40:13PM -0600, Bill O'Donnell wrote:
|  | Once again, running into problems when trying this patch on SLES-10 IA64,
|  | (Linux certify 2.6.18 #2 SMP PREEMPT Wed Nov 29 13:11:28 CST 2006 ia64)
|  |
|  | 1) replaced the ancient /lib/libcap.so.1.92 with less ancient 
libcap.so.1.10
|  |
|  | 2) successfully applied Serge's patch to SLES 2.6.18 sources and rebooted
|  |
|  | 3) installed Kaigai's userspace tools... no problems evident
|  |
|  | 4) ran setfcaps to see capabilities... (note Memory fault):
|  |
|  | certify:~/libcap-1.10 # setfcaps
|  | usage: setfcaps capabilities file ...
|  | cap_chown, cap_dac_override, cap_dac_read_search, cap_fowner
|  |   cap_fsetid, cap_kill, cap_setgid, cap_setuid
|  |   cap_setpcap, cap_linux_immutable,
|  |   cap_net_bind_service, cap_net_broadcast
|  | cap_net_admin, cap_net_raw, cap_ipc_lock, cap_ipc_owner
|  |   cap_sys_module, cap_sys_rawio, cap_sys_chroot, cap_sys_ptrace
|  |   cap_sys_pacct, cap_sys_admin, cap_sys_boot, cap_sys_nice
|  |   cap_sys_resource, cap_sys_time,
|  |   cap_sys_tty_config, cap_mknod
|  | cap_lease, cap_audit_write, cap_audit_controlMemory fault
| 
| Ah, this actually makes sense.  The setfcaps usage() statement does
| 
|   for (i=0; _cap_names[i]; i++) {
|   printf...
| 
| so it expects _cap_names to end with a terminating NULL, but that
| doesn't seem to be the case in cap_names.h in libcap.
| 
| KaiGai, perhaps setfcaps should do something like
| 
| diff setfcaps.c.orig setfcaps.c
| 25c25
|  for (i=0; _cap_names[i]; i++)
| ---
|  for (i=0; i__CAP_BITS; i++)

I brute-force hardcoded the limit on this for loop (i 31), and rebuilt
Kaigai's tools, and retested (again, on this RHEL5 IA64 target.  It all
works now.  I ran through Chris Friedhoff's test protocol, and it
went swimmingly (http://www.friedhoff.org/fscaps.html).

Then I went back to my SLES-10 IA64 target, and repeated the fixup for
Kaigai's tools.  It now works, providing I changeout the antique 
libcap.so.92 for newer libcap.so.10 (why the version number is lower is 
beyond me).

So, for my limited IA64 test target set, the following are true, 
providing Serge's capabilities kernel patch is applied, and Kaigai's 
userspace tools are utilized (obviously with the brute-force hack 
to setfcaps.c):

1) RHEL5 - libcap.so.10 is stock:  
   caps patch and hacked u-space tools PASS the tests.

2) SLES10 - libcap.so.92 is stock: 
   caps patch and hacked u-space tools FAIL the tests.

3) SLES10 - stock libcap.so.92 replaced with newer libcap.so.10: 
   caps patch and hacked u-space tools PASS the tests.


The question that remains unanswered: why is SLES using such an old
libcap, and are they likely to replace it with the more accepted
version (libcap.so.10) soon?

Thanks,
-Bill

-- 
Bill O'Donnell
SGI
[EMAIL PROTECTED]
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Implement file posix capabilities

2006-12-01 Thread KaiGai Kohei

Oops, it's my stupid bug.


Ah, this actually makes sense.  The setfcaps usage() statement does

for (i=0; _cap_names[i]; i++) {
printf...

so it expects _cap_names to end with a terminating NULL, but that
doesn't seem to be the case in cap_names.h in libcap.

KaiGai, perhaps setfcaps should do something like

diff setfcaps.c.orig setfcaps.c
25c25
 for (i=0; _cap_names[i]; i++)
---

for (i=0; i__CAP_BITS; i++)


I fixed the matter as follows:

[EMAIL PROTECTED] libcap-1.10.kg]$ env LANG=C svn diff -r2:3
Index: libcap/_makenames.c
===
--- libcap/_makenames.c (revision 2)
+++ libcap/_makenames.c (revision 3)
@@ -45,6 +45,7 @@
   #define __CAP_BITS   %d\n
   \n
   #ifdef LIBCAP_PLEASE_INCLUDE_ARRAY\n
+int const _cap_names_num = __CAP_BITS;\n
 char const *_cap_names[__CAP_BITS] = {\n, maxcaps);

 for (i=0; imaxcaps; ++i) {
Index: libcap/include/sys/capability.h
===
--- libcap/include/sys/capability.h (revision 2)
+++ libcap/include/sys/capability.h (revision 3)
@@ -113,6 +113,7 @@
 extern int capgetp(pid_t pid, cap_t cap_d);
 extern int capsetp(pid_t pid, cap_t cap_d);
 extern char const *_cap_names[];
+extern int const _cap_names_num;

 #endif /* !defined(_POSIX_SOURCE) */

Index: progs/setfcaps.c
===
--- progs/setfcaps.c(revision 2)
+++ progs/setfcaps.c(revision 3)
@@ -14,6 +14,7 @@
 #include errno.h
 #include sys/capability.h

+extern int const _cap_names_num;
 extern char const *_cap_names[];

 static void usage() {
@@ -21,8 +22,8 @@
 int i;

 fputs(message, stderr);
-for (i=0; _cap_names[i]; i++)
-   fprintf(stderr, %s%s, i%4==0 ? \n\t : , , _cap_names[i]);
+for (i=0; i  _cap_names_num; i++)
+fprintf(stderr, %s%s, i%4==0 ? \n\t : , , _cap_names[i]);
 fputc('\n', stderr);
 exit(0);
 }
[EMAIL PROTECTED] libcap-1.10.kg]$

Because '__CAP_BITS' is decided at compiling time, I think it's not
appropriate to indicate the length of _cap_names[] which is linked
at run time.
Therefore, I add a new integer variable _cap_names_num to represent
the length of _cap_names at run time.

You can download it from http://www.kaigai.gr.jp/index.php?FrontPage#b556e50d

Thanks,
--
KaiGai Kohei [EMAIL PROTECTED]
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Implement file posix capabilities

2006-11-30 Thread Serge E. Hallyn
Quoting Bill O'Donnell ([EMAIL PROTECTED]):
> The memory fault when setfcaps is run as noted in #4 below also occurs
> on RHEL5 IA64 (2.6.18 kernel-2.6.18-1.2747.el5 with Serge's capability patch,
> and Kaigai's userspace tools installed).
> 
> On Wed, Nov 29, 2006 at 02:40:13PM -0600, Bill O'Donnell wrote:
> | Once again, running into problems when trying this patch on SLES-10 IA64,
> | (Linux certify 2.6.18 #2 SMP PREEMPT Wed Nov 29 13:11:28 CST 2006 ia64)
> |
> | 1) replaced the ancient /lib/libcap.so.1.92 with less ancient libcap.so.1.10
> |
> | 2) successfully applied Serge's patch to SLES 2.6.18 sources and rebooted
> |
> | 3) installed Kaigai's userspace tools... no problems evident
> |
> | 4) ran setfcaps to see capabilities... (note Memory fault):
> |
> | certify:~/libcap-1.10 # setfcaps
> | usage: setfcaps   ...
> | cap_chown, cap_dac_override, cap_dac_read_search, cap_fowner
> | cap_fsetid, cap_kill, cap_setgid, cap_setuid
> | cap_setpcap, cap_linux_immutable,
> | cap_net_bind_service, cap_net_broadcast
> | cap_net_admin, cap_net_raw, cap_ipc_lock, cap_ipc_owner
> | cap_sys_module, cap_sys_rawio, cap_sys_chroot, cap_sys_ptrace
> | cap_sys_pacct, cap_sys_admin, cap_sys_boot, cap_sys_nice
> | cap_sys_resource, cap_sys_time,
> | cap_sys_tty_config, cap_mknod
> | cap_lease, cap_audit_write, cap_audit_controlMemory fault

Ah, this actually makes sense.  The setfcaps usage() statement does

for (i=0; _cap_names[i]; i++) {
printf...

so it expects _cap_names to end with a terminating NULL, but that
doesn't seem to be the case in cap_names.h in libcap.

KaiGai, perhaps setfcaps should do something like

diff setfcaps.c.orig setfcaps.c
25c25
< for (i=0; _cap_names[i]; i++)
---
> for (i=0; i<__CAP_BITS; i++)

thanks,
-serge
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Implement file posix capabilities

2006-11-30 Thread Bill O'Donnell
The memory fault when setfcaps is run as noted in #4 below also occurs 
on RHEL5 IA64 (2.6.18 kernel-2.6.18-1.2747.el5 with Serge's capability patch,
and Kaigai's userspace tools installed).

On Wed, Nov 29, 2006 at 02:40:13PM -0600, Bill O'Donnell wrote:
| Once again, running into problems when trying this patch on SLES-10 IA64,
| (Linux certify 2.6.18 #2 SMP PREEMPT Wed Nov 29 13:11:28 CST 2006 ia64)
| 
| 1) replaced the ancient /lib/libcap.so.1.92 with less ancient libcap.so.1.10
| 
| 2) successfully applied Serge's patch to SLES 2.6.18 sources and rebooted
| 
| 3) installed Kaigai's userspace tools... no problems evident
| 
| 4) ran setfcaps to see capabilities... (note Memory fault):
| 
| certify:~/libcap-1.10 # setfcaps
| usage: setfcaps   ...
| cap_chown, cap_dac_override, cap_dac_read_search, cap_fowner
|   cap_fsetid, cap_kill, cap_setgid, cap_setuid
|   cap_setpcap, cap_linux_immutable,
|   cap_net_bind_service, cap_net_broadcast
| cap_net_admin, cap_net_raw, cap_ipc_lock, cap_ipc_owner
|   cap_sys_module, cap_sys_rawio, cap_sys_chroot, cap_sys_ptrace
|   cap_sys_pacct, cap_sys_admin, cap_sys_boot, cap_sys_nice
|   cap_sys_resource, cap_sys_time,
|   cap_sys_tty_config, cap_mknod
| cap_lease, cap_audit_write, cap_audit_controlMemory fault
| 
| 5) straced previous command:
snip

-Bill

-- 
Bill O'Donnell
SGI
[EMAIL PROTECTED]
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Implement file posix capabilities

2006-11-30 Thread Bill O'Donnell
The memory fault when setfcaps is run as noted in #4 below also occurs 
on RHEL5 IA64 (2.6.18 kernel-2.6.18-1.2747.el5 with Serge's capability patch,
and Kaigai's userspace tools installed).

On Wed, Nov 29, 2006 at 02:40:13PM -0600, Bill O'Donnell wrote:
| Once again, running into problems when trying this patch on SLES-10 IA64,
| (Linux certify 2.6.18 #2 SMP PREEMPT Wed Nov 29 13:11:28 CST 2006 ia64)
| 
| 1) replaced the ancient /lib/libcap.so.1.92 with less ancient libcap.so.1.10
| 
| 2) successfully applied Serge's patch to SLES 2.6.18 sources and rebooted
| 
| 3) installed Kaigai's userspace tools... no problems evident
| 
| 4) ran setfcaps to see capabilities... (note Memory fault):
| 
| certify:~/libcap-1.10 # setfcaps
| usage: setfcaps capabilities file ...
| cap_chown, cap_dac_override, cap_dac_read_search, cap_fowner
|   cap_fsetid, cap_kill, cap_setgid, cap_setuid
|   cap_setpcap, cap_linux_immutable,
|   cap_net_bind_service, cap_net_broadcast
| cap_net_admin, cap_net_raw, cap_ipc_lock, cap_ipc_owner
|   cap_sys_module, cap_sys_rawio, cap_sys_chroot, cap_sys_ptrace
|   cap_sys_pacct, cap_sys_admin, cap_sys_boot, cap_sys_nice
|   cap_sys_resource, cap_sys_time,
|   cap_sys_tty_config, cap_mknod
| cap_lease, cap_audit_write, cap_audit_controlMemory fault
| 
| 5) straced previous command:
snip

-Bill

-- 
Bill O'Donnell
SGI
[EMAIL PROTECTED]
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Implement file posix capabilities

2006-11-30 Thread Serge E. Hallyn
Quoting Bill O'Donnell ([EMAIL PROTECTED]):
 The memory fault when setfcaps is run as noted in #4 below also occurs
 on RHEL5 IA64 (2.6.18 kernel-2.6.18-1.2747.el5 with Serge's capability patch,
 and Kaigai's userspace tools installed).
 
 On Wed, Nov 29, 2006 at 02:40:13PM -0600, Bill O'Donnell wrote:
 | Once again, running into problems when trying this patch on SLES-10 IA64,
 | (Linux certify 2.6.18 #2 SMP PREEMPT Wed Nov 29 13:11:28 CST 2006 ia64)
 |
 | 1) replaced the ancient /lib/libcap.so.1.92 with less ancient libcap.so.1.10
 |
 | 2) successfully applied Serge's patch to SLES 2.6.18 sources and rebooted
 |
 | 3) installed Kaigai's userspace tools... no problems evident
 |
 | 4) ran setfcaps to see capabilities... (note Memory fault):
 |
 | certify:~/libcap-1.10 # setfcaps
 | usage: setfcaps capabilities file ...
 | cap_chown, cap_dac_override, cap_dac_read_search, cap_fowner
 | cap_fsetid, cap_kill, cap_setgid, cap_setuid
 | cap_setpcap, cap_linux_immutable,
 | cap_net_bind_service, cap_net_broadcast
 | cap_net_admin, cap_net_raw, cap_ipc_lock, cap_ipc_owner
 | cap_sys_module, cap_sys_rawio, cap_sys_chroot, cap_sys_ptrace
 | cap_sys_pacct, cap_sys_admin, cap_sys_boot, cap_sys_nice
 | cap_sys_resource, cap_sys_time,
 | cap_sys_tty_config, cap_mknod
 | cap_lease, cap_audit_write, cap_audit_controlMemory fault

Ah, this actually makes sense.  The setfcaps usage() statement does

for (i=0; _cap_names[i]; i++) {
printf...

so it expects _cap_names to end with a terminating NULL, but that
doesn't seem to be the case in cap_names.h in libcap.

KaiGai, perhaps setfcaps should do something like

diff setfcaps.c.orig setfcaps.c
25c25
 for (i=0; _cap_names[i]; i++)
---
 for (i=0; i__CAP_BITS; i++)

thanks,
-serge
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Implement file posix capabilities

2006-11-29 Thread Bill O'Donnell
Once again, running into problems when trying this patch on SLES-10 IA64,
(Linux certify 2.6.18 #2 SMP PREEMPT Wed Nov 29 13:11:28 CST 2006 ia64)

1) replaced the ancient /lib/libcap.so.1.92 with less ancient libcap.so.1.10

2) successfully applied Serge's patch to SLES 2.6.18 sources and rebooted

3) installed Kaigai's userspace tools... no problems evident

4) ran setfcaps to see capabilities... (note Memory fault):

certify:~/libcap-1.10 # setfcaps
usage: setfcaps   ...
cap_chown, cap_dac_override, cap_dac_read_search, cap_fowner
cap_fsetid, cap_kill, cap_setgid, cap_setuid
cap_setpcap, cap_linux_immutable,
cap_net_bind_service, cap_net_broadcast
cap_net_admin, cap_net_raw, cap_ipc_lock, cap_ipc_owner
cap_sys_module, cap_sys_rawio, cap_sys_chroot, cap_sys_ptrace
cap_sys_pacct, cap_sys_admin, cap_sys_boot, cap_sys_nice
cap_sys_resource, cap_sys_time,
cap_sys_tty_config, cap_mknod
cap_lease, cap_audit_write, cap_audit_controlMemory fault

5) straced previous command:

[EMAIL PROTECTED]:/> strace -o /tmp/straceout4 setfcaps
[EMAIL PROTECTED]:/> cat  /tmp/straceout4
execve("/sbin/setfcaps", ["setfcaps"], [/* 65 vars */]) = 0
brk(0)  = 0x60004000
uname({sys="Linux", node="certify", ...}) = 0
access("/etc/ld.so.preload", R_OK)  = -1 ENOENT (No such file or
directory)
open("/etc/ld.so.cache", O_RDONLY)  = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=111415, ...}) = 0
mmap(NULL, 111415, PROT_READ, MAP_PRIVATE, 3, 0) = 0x2004c000
close(3)= 0
open("/lib/libcap.so.1", O_RDONLY)  = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0002\0\1\0\0\0\340\25"..., 832) =
832
fstat(3, {st_mode=S_IFREG|0755, st_size=22672, ...}) = 0
mmap(NULL, 85800, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) =
0x20068000
madvise(0x20068000, 85800, MADV_SEQUENTIAL|0x1) = 0
mprotect(0x2007, 49152, PROT_NONE) = 0
mmap(0x2007c000, 16384, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x4000) = 0x2007c000
close(3)= 0
open("/lib/libc.so.6.1", O_RDONLY)  = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0002\0\1\0\0\0\3609\2"..., 832) =
832
fstat(3, {st_mode=S_IFREG|0755, st_size=2590313, ...}) = 0
mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x2008
mmap(NULL, 2416624, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) =
0x20084000
madvise(0x20084000, 2416624, MADV_SEQUENTIAL|0x1) = 0
mprotect(0x202bc000, 49152, PROT_NONE) = 0
mmap(0x202c8000, 32768, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x234000) = 0x202c8000
mmap(0x202d, 8176, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x202d
close(3)= 0
mmap(NULL, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x202d4000
mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x202dc000
munmap(0x2004c000, 111415)  = 0
write(2, "usage: setfcaps  <"..., 41) = 41
write(2, "\n\tcap_chown", 11)   = 11
write(2, ", cap_dac_override", 18)  = 18
write(2, ", cap_dac_read_search", 21)   = 21
write(2, ", cap_fowner", 12)= 12
write(2, "\n\tcap_fsetid", 12)  = 12
write(2, ", cap_kill", 10)  = 10
write(2, ", cap_setgid", 12)= 12
write(2, ", cap_setuid", 12)= 12
write(2, "\n\tcap_setpcap", 13) = 13
write(2, ", cap_linux_immutable", 21)   = 21
write(2, ", cap_net_bind_service", 22)  = 22
write(2, ", cap_net_broadcast", 19) = 19
write(2, "\n\tcap_net_admin", 15)   = 15
write(2, ", cap_net_raw", 13)   = 13
write(2, ", cap_ipc_lock", 14)  = 14
write(2, ", cap_ipc_owner", 15) = 15
write(2, "\n\tcap_sys_module", 16)  = 16
write(2, ", cap_sys_rawio", 15) = 15
write(2, ", cap_sys_chroot", 16)= 16
write(2, ", cap_sys_ptrace", 16)= 16
write(2, "\n\tcap_sys_pacct", 15)   = 15
write(2, ", cap_sys_admin", 15) = 15
write(2, ", cap_sys_boot", 14)  = 14
write(2, ", cap_sys_nice", 14)  = 14
write(2, "\n\tcap_sys_resource", 18)= 18
write(2, ", cap_sys_time", 14)  = 14
write(2, ", cap_sys_tty_config", 20)= 20
write(2, ", cap_mknod", 11) = 11
write(2, "\n\tcap_lease", 11)   = 11
write(2, ", cap_audit_write", 17)   = 17
write(2, ", cap_audit_control", 19) = 19
--- SIGSEGV (Segmentation fault) @ 2015ed20 () ---
+++ killed by SIGSEGV +++
[EMAIL PROTECTED]:/> 

6) probably can't go much beyond (5), as problems likely relate to that
segfault.  Nevertheless, I tried to modify capabities for 
modprobe, yielding the all too familiar error... 

[EMAIL PROTECTED]:/> modprobe fuse major-0   

Re: [PATCH] Implement file posix capabilities

2006-11-29 Thread Chris Friedhoff
I use this patch with 2.6.18.3.
patching: ok
configuring: ok
compiling: ok
installing: ok
running: ok
tested with httpd, smbd, nmbd, named, cupsd, ping, traceroute,
modprobe, traceroute, ntpdate, xinit, killall, eject, dhcpd, route,
qemu: ok
I use this patch as documented: http://www.friedhoff.org/fscaps.html

I also tested the patched kernel with "CONFIG_SECURITY_FS_CAPABILITIES
is not set" and xinit kills X perfectly, when the GUI is stopped.

Any other tests that might be helpful?

The webpage is updated.

Chris


On Mon, 27 Nov 2006 11:07:40 -0600
"Serge E. Hallyn" <[EMAIL PROTECTED]> wrote:

> From: Serge E. Hallyn <[EMAIL PROTECTED]>
> Subject: [PATCH 1/1] Implement file posix capabilities
> 
> Implement file posix capabilities.  This allows programs to be given a
> subset of root's powers regardless of who runs them, without having to use
> setuid and giving the binary all of root's powers.
> 
> This version works with Kaigai Kohei's userspace tools, found at
> http://www.kaigai.gr.jp/index.php.  For more information on how to use this
> patch, Chris Friedhoff has posted a nice page at
> http://www.friedhoff.org/fscaps.html.
> 
> Changelog:
>   Nov 27:
>   Incorporate fixes from Andrew Morton
>   (security-introduce-file-caps-tweaks and
>   security-introduce-file-caps-warning-fix)
>   Fix Kconfig dependency.
>   Fix change signaling behavior when file caps are not compiled in.

- snip -


Chris Friedhoff
[EMAIL PROTECTED]
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Implement file posix capabilities

2006-11-29 Thread Chris Friedhoff
I use this patch with 2.6.18.3.
patching: ok
configuring: ok
compiling: ok
installing: ok
running: ok
tested with httpd, smbd, nmbd, named, cupsd, ping, traceroute,
modprobe, traceroute, ntpdate, xinit, killall, eject, dhcpd, route,
qemu: ok
I use this patch as documented: http://www.friedhoff.org/fscaps.html

I also tested the patched kernel with CONFIG_SECURITY_FS_CAPABILITIES
is not set and xinit kills X perfectly, when the GUI is stopped.

Any other tests that might be helpful?

The webpage is updated.

Chris


On Mon, 27 Nov 2006 11:07:40 -0600
Serge E. Hallyn [EMAIL PROTECTED] wrote:

 From: Serge E. Hallyn [EMAIL PROTECTED]
 Subject: [PATCH 1/1] Implement file posix capabilities
 
 Implement file posix capabilities.  This allows programs to be given a
 subset of root's powers regardless of who runs them, without having to use
 setuid and giving the binary all of root's powers.
 
 This version works with Kaigai Kohei's userspace tools, found at
 http://www.kaigai.gr.jp/index.php.  For more information on how to use this
 patch, Chris Friedhoff has posted a nice page at
 http://www.friedhoff.org/fscaps.html.
 
 Changelog:
   Nov 27:
   Incorporate fixes from Andrew Morton
   (security-introduce-file-caps-tweaks and
   security-introduce-file-caps-warning-fix)
   Fix Kconfig dependency.
   Fix change signaling behavior when file caps are not compiled in.

- snip -


Chris Friedhoff
[EMAIL PROTECTED]
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Implement file posix capabilities

2006-11-29 Thread Bill O'Donnell
Once again, running into problems when trying this patch on SLES-10 IA64,
(Linux certify 2.6.18 #2 SMP PREEMPT Wed Nov 29 13:11:28 CST 2006 ia64)

1) replaced the ancient /lib/libcap.so.1.92 with less ancient libcap.so.1.10

2) successfully applied Serge's patch to SLES 2.6.18 sources and rebooted

3) installed Kaigai's userspace tools... no problems evident

4) ran setfcaps to see capabilities... (note Memory fault):

certify:~/libcap-1.10 # setfcaps
usage: setfcaps capabilities file ...
cap_chown, cap_dac_override, cap_dac_read_search, cap_fowner
cap_fsetid, cap_kill, cap_setgid, cap_setuid
cap_setpcap, cap_linux_immutable,
cap_net_bind_service, cap_net_broadcast
cap_net_admin, cap_net_raw, cap_ipc_lock, cap_ipc_owner
cap_sys_module, cap_sys_rawio, cap_sys_chroot, cap_sys_ptrace
cap_sys_pacct, cap_sys_admin, cap_sys_boot, cap_sys_nice
cap_sys_resource, cap_sys_time,
cap_sys_tty_config, cap_mknod
cap_lease, cap_audit_write, cap_audit_controlMemory fault

5) straced previous command:

[EMAIL PROTECTED]:/ strace -o /tmp/straceout4 setfcaps
[EMAIL PROTECTED]:/ cat  /tmp/straceout4
execve(/sbin/setfcaps, [setfcaps], [/* 65 vars */]) = 0
brk(0)  = 0x60004000
uname({sys=Linux, node=certify, ...}) = 0
access(/etc/ld.so.preload, R_OK)  = -1 ENOENT (No such file or
directory)
open(/etc/ld.so.cache, O_RDONLY)  = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=111415, ...}) = 0
mmap(NULL, 111415, PROT_READ, MAP_PRIVATE, 3, 0) = 0x2004c000
close(3)= 0
open(/lib/libcap.so.1, O_RDONLY)  = 3
read(3, \177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0002\0\1\0\0\0\340\25..., 832) =
832
fstat(3, {st_mode=S_IFREG|0755, st_size=22672, ...}) = 0
mmap(NULL, 85800, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) =
0x20068000
madvise(0x20068000, 85800, MADV_SEQUENTIAL|0x1) = 0
mprotect(0x2007, 49152, PROT_NONE) = 0
mmap(0x2007c000, 16384, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x4000) = 0x2007c000
close(3)= 0
open(/lib/libc.so.6.1, O_RDONLY)  = 3
read(3, \177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0002\0\1\0\0\0\3609\2..., 832) =
832
fstat(3, {st_mode=S_IFREG|0755, st_size=2590313, ...}) = 0
mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x2008
mmap(NULL, 2416624, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) =
0x20084000
madvise(0x20084000, 2416624, MADV_SEQUENTIAL|0x1) = 0
mprotect(0x202bc000, 49152, PROT_NONE) = 0
mmap(0x202c8000, 32768, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x234000) = 0x202c8000
mmap(0x202d, 8176, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x202d
close(3)= 0
mmap(NULL, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x202d4000
mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x202dc000
munmap(0x2004c000, 111415)  = 0
write(2, usage: setfcaps capabilities ..., 41) = 41
write(2, \n\tcap_chown, 11)   = 11
write(2, , cap_dac_override, 18)  = 18
write(2, , cap_dac_read_search, 21)   = 21
write(2, , cap_fowner, 12)= 12
write(2, \n\tcap_fsetid, 12)  = 12
write(2, , cap_kill, 10)  = 10
write(2, , cap_setgid, 12)= 12
write(2, , cap_setuid, 12)= 12
write(2, \n\tcap_setpcap, 13) = 13
write(2, , cap_linux_immutable, 21)   = 21
write(2, , cap_net_bind_service, 22)  = 22
write(2, , cap_net_broadcast, 19) = 19
write(2, \n\tcap_net_admin, 15)   = 15
write(2, , cap_net_raw, 13)   = 13
write(2, , cap_ipc_lock, 14)  = 14
write(2, , cap_ipc_owner, 15) = 15
write(2, \n\tcap_sys_module, 16)  = 16
write(2, , cap_sys_rawio, 15) = 15
write(2, , cap_sys_chroot, 16)= 16
write(2, , cap_sys_ptrace, 16)= 16
write(2, \n\tcap_sys_pacct, 15)   = 15
write(2, , cap_sys_admin, 15) = 15
write(2, , cap_sys_boot, 14)  = 14
write(2, , cap_sys_nice, 14)  = 14
write(2, \n\tcap_sys_resource, 18)= 18
write(2, , cap_sys_time, 14)  = 14
write(2, , cap_sys_tty_config, 20)= 20
write(2, , cap_mknod, 11) = 11
write(2, \n\tcap_lease, 11)   = 11
write(2, , cap_audit_write, 17)   = 17
write(2, , cap_audit_control, 19) = 19
--- SIGSEGV (Segmentation fault) @ 2015ed20 () ---
+++ killed by SIGSEGV +++
[EMAIL PROTECTED]:/ 

6) probably can't go much beyond (5), as problems likely relate to that
segfault.  Nevertheless, I tried to modify capabities for 
modprobe, yielding the all too familiar error... 

[EMAIL PROTECTED]:/ modprobe fuse major-0
FATAL: Error inserting fuse 

[PATCH] Implement file posix capabilities

2006-11-27 Thread Serge E. Hallyn
From: Serge E. Hallyn <[EMAIL PROTECTED]>
Subject: [PATCH 1/1] Implement file posix capabilities

Implement file posix capabilities.  This allows programs to be given a
subset of root's powers regardless of who runs them, without having to use
setuid and giving the binary all of root's powers.

This version works with Kaigai Kohei's userspace tools, found at
http://www.kaigai.gr.jp/index.php.  For more information on how to use this
patch, Chris Friedhoff has posted a nice page at
http://www.friedhoff.org/fscaps.html.

Changelog:
Nov 27:
Incorporate fixes from Andrew Morton
(security-introduce-file-caps-tweaks and
security-introduce-file-caps-warning-fix)
Fix Kconfig dependency.
Fix change signaling behavior when file caps are not compiled in.

Nov 13:
Integrate comments from Alexey: Remove CONFIG_ ifdef from
capability.h, and use %zd for printing a size_t.

Nov 13:
Fix endianness warnings by sparse as suggested by Alexey
Dobriyan.

Nov 09:
Address warnings of unused variables at cap_bprm_set_security
when file capabilities are disabled, and simultaneously clean
up the code a little, by pulling the new code into a helper
function.

Nov 08:
For pointers to required userspace tools and how to use
them, see http://www.friedhoff.org/fscaps.html.

Nov 07:
Fix the calculation of the highest bit checked in
check_cap_sanity().

Nov 07:
Allow file caps to be enabled without CONFIG_SECURITY, since
capabilities are the default.
Hook cap_task_setscheduler when !CONFIG_SECURITY.
Move capable(TASK_KILL) to end of cap_task_kill to reduce
audit messages.

Nov 05:
Add secondary calls in selinux/hooks.c to task_setioprio and
task_setscheduler so that selinux and capabilities with file
cap support can be stacked.

Sep 05:
As Seth Arnold points out, uid checks are out of place
for capability code.

Sep 01:
Define task_setscheduler, task_setioprio, cap_task_kill, and
task_setnice to make sure a user cannot affect a process in which
they called a program with some fscaps.

One remaining question is the note under task_setscheduler: are we
ok with CAP_SYS_NICE being sufficient to confine a process to a
cpuset?

It is a semantic change, as without fsccaps, attach_task doesn't
allow CAP_SYS_NICE to override the uid equivalence check.  But since
it uses security_task_setscheduler, which elsewhere is used where
CAP_SYS_NICE can be used to override the uid equivalence check,
fixing it might be tough.

 task_setscheduler
 note: this also controls cpuset:attach_task.  Are we ok with
 CAP_SYS_NICE being used to confine to a cpuset?
 task_setioprio
 task_setnice
 sys_setpriority uses this (through set_one_prio) for another
 process.  Need same checks as setrlimit

Aug 21:
Updated secureexec implementation to reflect the fact that
euid and uid might be the same and nonzero, but the process
might still have elevated caps.

Aug 15:
Handle endianness of xattrs.
Enforce capability version match between kernel and disk.
Enforce that no bits beyond the known max capability are
set, else return -EPERM.
With this extra processing, it may be worth reconsidering
doing all the work at bprm_set_security rather than
d_instantiate.

Aug 10:
Always call getxattr at bprm_set_security, rather than
caching it at d_instantiate.

Signed-off-by: Serge E. Hallyn <[EMAIL PROTECTED]>
---
 include/linux/capability.h |   20 +
 include/linux/security.h   |   12 ++-
 security/Kconfig   |   10 ++
 security/capability.c  |4 +
 security/commoncap.c   |  186 ++--
 security/selinux/hooks.c   |   12 +++
 6 files changed, 233 insertions(+), 11 deletions(-)

diff --git a/include/linux/capability.h b/include/linux/capability.h
index 6548b35..2776886 100644
--- a/include/linux/capability.h
+++ b/include/linux/capability.h
@@ -40,11 +40,29 @@ typedef struct __user_cap_data_struct {
 __u32 inheritable;
 } __user *cap_user_data_t;
   
+
+
+#define XATTR_CAPS_SUFFIX "capability"
+#define XATTR_NAME_CAPS XATTR_SECURITY_PREFIX XATTR_CAPS_SUFFIX
+struct vfs_cap_data_disk {
+   __le32 version;
+   __le32 effective;
+   __le32 permitted;
+   __le32 inheritable;
+};
+
 #ifdef __KERNEL__
 
 #include 
 #include 
 
+struct vfs_cap_data {
+   __u32 version;
+   __u32 effective;
+   __u32 permitted;
+   __u32 inheritable;
+};
+
 /* #define STRICT_CAP_T_TYPECHECKS */
 
 #ifdef 

[PATCH] Implement file posix capabilities

2006-11-27 Thread Serge E. Hallyn
From: Serge E. Hallyn [EMAIL PROTECTED]
Subject: [PATCH 1/1] Implement file posix capabilities

Implement file posix capabilities.  This allows programs to be given a
subset of root's powers regardless of who runs them, without having to use
setuid and giving the binary all of root's powers.

This version works with Kaigai Kohei's userspace tools, found at
http://www.kaigai.gr.jp/index.php.  For more information on how to use this
patch, Chris Friedhoff has posted a nice page at
http://www.friedhoff.org/fscaps.html.

Changelog:
Nov 27:
Incorporate fixes from Andrew Morton
(security-introduce-file-caps-tweaks and
security-introduce-file-caps-warning-fix)
Fix Kconfig dependency.
Fix change signaling behavior when file caps are not compiled in.

Nov 13:
Integrate comments from Alexey: Remove CONFIG_ ifdef from
capability.h, and use %zd for printing a size_t.

Nov 13:
Fix endianness warnings by sparse as suggested by Alexey
Dobriyan.

Nov 09:
Address warnings of unused variables at cap_bprm_set_security
when file capabilities are disabled, and simultaneously clean
up the code a little, by pulling the new code into a helper
function.

Nov 08:
For pointers to required userspace tools and how to use
them, see http://www.friedhoff.org/fscaps.html.

Nov 07:
Fix the calculation of the highest bit checked in
check_cap_sanity().

Nov 07:
Allow file caps to be enabled without CONFIG_SECURITY, since
capabilities are the default.
Hook cap_task_setscheduler when !CONFIG_SECURITY.
Move capable(TASK_KILL) to end of cap_task_kill to reduce
audit messages.

Nov 05:
Add secondary calls in selinux/hooks.c to task_setioprio and
task_setscheduler so that selinux and capabilities with file
cap support can be stacked.

Sep 05:
As Seth Arnold points out, uid checks are out of place
for capability code.

Sep 01:
Define task_setscheduler, task_setioprio, cap_task_kill, and
task_setnice to make sure a user cannot affect a process in which
they called a program with some fscaps.

One remaining question is the note under task_setscheduler: are we
ok with CAP_SYS_NICE being sufficient to confine a process to a
cpuset?

It is a semantic change, as without fsccaps, attach_task doesn't
allow CAP_SYS_NICE to override the uid equivalence check.  But since
it uses security_task_setscheduler, which elsewhere is used where
CAP_SYS_NICE can be used to override the uid equivalence check,
fixing it might be tough.

 task_setscheduler
 note: this also controls cpuset:attach_task.  Are we ok with
 CAP_SYS_NICE being used to confine to a cpuset?
 task_setioprio
 task_setnice
 sys_setpriority uses this (through set_one_prio) for another
 process.  Need same checks as setrlimit

Aug 21:
Updated secureexec implementation to reflect the fact that
euid and uid might be the same and nonzero, but the process
might still have elevated caps.

Aug 15:
Handle endianness of xattrs.
Enforce capability version match between kernel and disk.
Enforce that no bits beyond the known max capability are
set, else return -EPERM.
With this extra processing, it may be worth reconsidering
doing all the work at bprm_set_security rather than
d_instantiate.

Aug 10:
Always call getxattr at bprm_set_security, rather than
caching it at d_instantiate.

Signed-off-by: Serge E. Hallyn [EMAIL PROTECTED]
---
 include/linux/capability.h |   20 +
 include/linux/security.h   |   12 ++-
 security/Kconfig   |   10 ++
 security/capability.c  |4 +
 security/commoncap.c   |  186 ++--
 security/selinux/hooks.c   |   12 +++
 6 files changed, 233 insertions(+), 11 deletions(-)

diff --git a/include/linux/capability.h b/include/linux/capability.h
index 6548b35..2776886 100644
--- a/include/linux/capability.h
+++ b/include/linux/capability.h
@@ -40,11 +40,29 @@ typedef struct __user_cap_data_struct {
 __u32 inheritable;
 } __user *cap_user_data_t;
   
+
+
+#define XATTR_CAPS_SUFFIX capability
+#define XATTR_NAME_CAPS XATTR_SECURITY_PREFIX XATTR_CAPS_SUFFIX
+struct vfs_cap_data_disk {
+   __le32 version;
+   __le32 effective;
+   __le32 permitted;
+   __le32 inheritable;
+};
+
 #ifdef __KERNEL__
 
 #include linux/spinlock.h
 #include asm/current.h
 
+struct vfs_cap_data {
+   __u32 version;
+   __u32 effective;
+   __u32 permitted;
+   __u32 inheritable;
+};
+
 /* #define STRICT_CAP_T_TYPECHECKS */