Re: [PATCH 1/1] security: introduce fs caps

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


Hi, Serge.

Serge E. Hallyn wrote:
Quoting Bill O'Donnell ([email protected]):
8102  execve("/sbin/setfcaps", ["setfcaps", "cap_net_raw=ep", "/bin/ping"], [/* 67 vars */]) = 0
    - snip -
8102  capget(0x19980330, 0, {0, 0, 0})  = -1 EINVAL (Invalid argument)

I don't see why this capget is returning -EINVAL.  In fact I don't see
why it happens at all - cap_inode_setxattr would check
capable(CAP_SYS_ADMIN), but setxattr hasn't been called yet.  Looking at
both libcap and setfcaps.c, I don't see where the capget comes from.

As for the -EINVAL, kernel/capability.c:sys_capget() returns -EINVAL if
the _LINUX_CAPABILITY_VERSION is wrong - you have 0x19980330 which is
correct - if pid < 0 - but you send in 0 - or if security_capget
returns -EINVAL, which cap_capget (and dummy_capget) don't do.

Kaigai, do you have any ideas?

Bill said that he uses SLES10/ia64, so the version of libcap is different
from Fedora Core's one. 'libcap-1.92-499.4.src.rpm' is bandled.

Then, I found a strange code in libcap-1.92-499.4.src.rpm.

The setfcaps calls cap_from_text() which is defined in libcap to parse
the command line argument. It has the following function call chains:

  -> cap_init()
    -> _libcap_establish_api()

---- the definition of _libcap_establish_api() ----
void _libcap_establish_api(void)
    struct __user_cap_header_struct ch;
    struct __user_cap_data_struct cs;

    if (_libcap_kernel_version) { <-- _libcap_kernel_version is 0 initially.
        _cap_debug("already identified kernal api 0x%.8x",

    memset(&ch, 0, sizeof(ch));
    memset(&cs, 0, sizeof(cs));

    (void) capget(&ch, &cs);  <-- (?)

    switch (ch.version) {

    case 0x19980330:
        _libcap_kernel_version = 0x19980330;
        _libcap_kernel_features = CAP_FEATURE_PROC;

    case 0x19990414:
        _libcap_kernel_version = 0x19990414;
        _libcap_kernel_features = CAP_FEATURE_PROC|CAP_FEATURE_FILE;

        _libcap_kernel_version = 0x00000000;
        _libcap_kernel_features = 0x00000000;

    _cap_debug("version: %x, features: %x\n",
               _libcap_kernel_version, _libcap_kernel_features);

capget() is called from _libcap_establish_api() with full-zeroed
__user_cap_header_struct object at first time.
The result of this, sys_capget() in kernel will return -EINVAL.
(Why did strace say the first argument is 0x19980330?)

Probably, Bill didn't update

But I can't recommend Bill to update libcap immediately.
As Hawk Xu said, it may cause a serious problem on the distro
except Fedora Core 6. :(

I have to recommend to use 'fscaps-1.0-kg.i386.rpm' now.
It includes the implementation of interaction between application and xattr.
(Of couse, it's one of the features which should be provided by libcap.)

Open Source Software Promotion Center, NEC
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
Please read the FAQ at

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux