From: "Michael Kerrisk (man-pages)" <mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Krzysztof Adamski <k@japko.eu>
Cc: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] execve.2: EPERM from filesystem capabilities.
Date: Thu, 10 Mar 2016 01:33:07 +0100 [thread overview]
Message-ID: <56E0C0C3.6040808@gmail.com> (raw)
In-Reply-To: <20160309201501.GE25658-xLeyfSbClftGit24Ens98Q@public.gmane.org>
Hello Krzysztof
On 03/09/2016 09:15 PM, Krzysztof Adamski wrote:
> On Wed, Mar 09, 2016 at 01:49:41AM +0100, Michael Kerrisk (man-pages) wrote:
>> Hello Krzysztof
>>
>> Sorry for the delayed follow up.
>>
>> On 10/12/2015 09:45 PM, Krzysztof Adamski wrote:
>>> An EPERM error can be returned when using filesystem capabilities and
>>> capabilities to be added are not in permitted set.
>>>
>>> This error return values was introduced by this patch:
>>> 5459c16 security: protect legacy applications from executing with
>>> insufficient privilege
>>
>> Can you explain in more detail the scenario where EPERM can be produced.
>> I can't see/produce it. Also, the code in the commit that you mention,
>> which was part of Linux 2.6.27, was thoroughly changed in Linux 2.6.29.
>
> Hi Michael,
> If you're interested in details, I explained it quite extensively here:
> http://k.japko.eu/systemd-nspawn-ping-debug.html
>
> The summary is that I used nspawn from systemd which drops some
> capabilites (CAP_NET_ADMIN is amoung them) when spawning a container.
> Now, since I used Fedora in container, my ping binary had filesystem
> capabilites set:
>
> # getcap /bin/ping
> /bin/ping = cap_net_admin,cap_net_raw+ep
>
> So when executing this application, kernel tried to give me
> CAP_NET_ADMIN capabilities but they where not on permitted set so I've
> got EPERM.
>
> It was found in kernel 4.1 back then and I just retested this on kernel
> 4.3. Unfortunately I don't have time now to verify this for the latest
> kernel but I would be surprised if this feature was removed.
>
> Would you like me to extend/change the description in the patch somehow?
Okay -- I got it at last. I think the explanation requires quite
some detail. I added this to execve(2):
EPERM A "capability-dumb" applications would not obtain the
full set of permitted capabilities granted by the exe‐
cutable file. See capabilities(7).
And this to capabilities(7):
Safety checking for capability-dumb binaries
A capability-dumb binary is a legacy application that has been
marked to have file capabilities, but has not been converted to
use the libcap(3) API to manipulate its capabilities. (In
other words, this is a traditional set-user-ID-root program
that has been switched to use file capabilities, but whose code
has not been modified to understand capabilities.) For such
applications, the effective capability bit is set on the file,
so that the file permitted capabilities are automatically
enabled in the process effective set when executing the file.
The kernel recognizes a file which has the effective capability
bit set as capability-dumb for the purpose of the check
described here.
When executing a capability-dumb binary, the kernel checks if
the process obtained all permitted capabilities that were spec‐
ified in the file permitted set, after the capability transfor‐
mations described above have been performed. (The typical rea‐
son why this might not occur is that the capability bounding
set masked out some of the capabilities in the file permitted
set.) If the process did not obtain the full set of file per‐
mitted capabilities, then execve(2) fails with the error EPERM.
This prevents possible security risks that could arise when a
capability-dumb application is executed with less privilege
that it needs. Note that, by definition, the application could
not itself recognize this problem, since it does not employ the
libcap(3) API.
Let me know if you see anything amiss.
Thanks,
Michael
--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2016-03-10 0:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-12 19:45 [PATCH] execve.2: EPERM from filesystem capabilities Krzysztof Adamski
[not found] ` <20151012194506.GA6346-xLeyfSbClftGit24Ens98Q@public.gmane.org>
2016-03-09 0:49 ` Michael Kerrisk (man-pages)
[not found] ` <56DF7325.9030702-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-03-09 20:15 ` Krzysztof Adamski
[not found] ` <20160309201501.GE25658-xLeyfSbClftGit24Ens98Q@public.gmane.org>
2016-03-10 0:33 ` Michael Kerrisk (man-pages) [this message]
[not found] ` <56E0C0C3.6040808-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-03-10 15:06 ` Krzysztof Adamski
[not found] ` <20160310150633.GG25658-xLeyfSbClftGit24Ens98Q@public.gmane.org>
2016-03-10 17:07 ` Michael Kerrisk (man-pages)
2016-04-05 3:25 ` Mike Frysinger
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=56E0C0C3.6040808@gmail.com \
--to=mtk.manpages-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=k@japko.eu \
--cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/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;
as well as URLs for NNTP newsgroup(s).