sysctl: Enable ping(8) inside rootless Podman containers#13141
sysctl: Enable ping(8) inside rootless Podman containers#13141poettering merged 1 commit intosystemd:masterfrom debarshiray:wip/rishi/enable-ping-group-range
Conversation
|
I am confused about the size of a group identifier on Linux these days. Wikipedia seems to suggest 32 bits, but on Fedora 29, an upper value of 4294967295 kept getting rejected. Should it be detected at build-time instead of being hard coded? |
|
hmm, i really don't understand the implications of this I must say, and the fact this uses 2^16-1 instead of 2^32-1 (i.e. the maximum of gid_t) appears quite strange to me... Binding this to group range membership sounds quite surprising to me I must say |
|
(note that I am not against this, I just want to understand this first) |
|
The beauty of this is you can remove file capabilities from Ping. If we had a default user set for all real users on Linux then we could make this a little more secure, say any user added by useradd went in the user group, then you could just setup the range by default to be for the user group. Bottom line, is I believe users of a linux system expect to be able to ping without requiring root, and running ping in a container requires this access versus the file capabilities. I have no idea what defaults Ubuntu has for this. |
|
@debarshiray I think this should be marked as a change request for Fedora to allow |
Like I mentioned earlier, I had expected 2^32-1 to work, but it gets rejected on both Fedoras 30 and 29 even though |
|
@teknoraver what are the security implications of enabling |
|
so 2^31-1 seems to work, 2^31 does not. |
|
hmm, this limit comes from #define GID_T_MAX (((gid_t)~0U) >> 1)which appears to be simply wrong... somebody should file a bug... that said, maybe this is not too bad for us, given that the upper uids are currently defined as "HIC SVNT LEONES" anyway in systemd: |
I wrote https://fedoraproject.org/wiki/Changes/EnableSysctlPingGroupRange |
the ICMP address family had a lot of security issues in the past, mostly because it has very few users. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/net/ipv4/ping.c#n461 /*
* Is this a supported type of ICMP message?
*/
static inline int ping_supported(int family, int type, int code)
{
return (family == AF_INET && type == ICMP_ECHO && code == 0) ||
(family == AF_INET6 && type == ICMPV6_ECHO_REQUEST && code == 0);
}A partial list of past exploitable bug is: $ git log --grep='^Fixes: c319b4d76b9e' --oneline |
Thanks for digging into it, @poettering I have now bumped the upper limit to 2147483647 (= 2^31 - 1). |
|
@debarshiray also needs an announcement in NEWS I figure... @teknoraver I am not too interested in historical issues with it, more what the current state is, and whether there are negative security implications today if we just turn this on. |
No contraindications other than not being much tested and used. |
|
Well, if we make the change here upstream in systemd it will get some testing I am sure. @debarshiray can you add a NEWS entry for this change, please? looks ok to merge then. |
There's this comment above that I am not qualified to judge it, but I thought I'd just mention it here. :) |
Added a blurb to NEWS. I wasn't sure of the right order. I stuck it at the top since it starts with E, so it's very roughly alphabetical. |
This makes ping(8) work without CAP_NET_ADMIN and CAP_NET_RAW because those aren't effective inside rootless Podman containers. It's quite useful when using OSTree based operating systems like Fedora Silverblue, where development environments are often set up using rootless Podman containers with helpers like Toolbox [1]. Not having a basic network utility like ping(8) work inside the development environment can be inconvenient. See: https://lwn.net/Articles/422330/ http://man7.org/linux/man-pages/man7/icmp.7.html containers/podman#1550 The upper limit of the range of group identifiers is set to 2147483647, which is 2^31-1. Values greater than that get rejected by the kernel because of this definition in linux/include/net/ping.h: #define GID_T_MAX (((gid_t)~0U) >> 1) That's not so bad because values between 2^31 and 2^32-1 are reserved on systemd-based systems anyway [2]. [1] https://github.com/debarshiray/toolbox [2] https://systemd.io/UIDS-GIDS.html#summary
|
|
|
The PR was reverted in #13187. We keep discussing what to do about user namespaces (where it's not always possible to write |
|
I posted #13191 now, to revert the revert, and make it work everywhere correctly now |
+ Network | Grant all users "ping" access without the need for sudo, setuid, CAP_NET_RAW or CAP_NET_ADMIN. Further infos and discussion about this: - https://fedoraproject.org/wiki/Changes/EnableSysctlPingGroupRange - systemd/systemd#13141 - #1012
From systemd 243 release note[1]: This release enables unprivileged programs (i.e. requiring neither setuid nor file capabilities) to send ICMP Echo (i.e. ping) requests by turning on the "net.ipv4.ping_group_range" sysctl of the Linux kernel for the whole UNIX group range, i.e. all processes. So this wrapper is not needed any more. See also [2] and [3]. This patch also removes: - apparmor profiles in NixOS for ping itself and the wrapped one - other references for the wrapped ping [1]: https://github.com/systemd/systemd/blob/8e2d9d40b33bc8e8f5d3479fb075d3fab32a4184/NEWS#L6457-L6464 [2]: systemd/systemd#13141 [3]: https://fedoraproject.org/wiki/Changes/EnableSysctlPingGroupRange
From systemd 243 release note[1]: This release enables unprivileged programs (i.e. requiring neither setuid nor file capabilities) to send ICMP Echo (i.e. ping) requests by turning on the "net.ipv4.ping_group_range" sysctl of the Linux kernel for the whole UNIX group range, i.e. all processes. So this wrapper is not needed any more. See also [2] and [3]. This patch also removes: - apparmor profiles in NixOS for ping itself and the wrapped one - other references for the wrapped ping [1]: https://github.com/systemd/systemd/blob/8e2d9d40b33bc8e8f5d3479fb075d3fab32a4184/NEWS#L6457-L6464 [2]: systemd/systemd#13141 [3]: https://fedoraproject.org/wiki/Changes/EnableSysctlPingGroupRange
This makes ping(8) work without CAP_NET_ADMIN and CAP_NET_RAW because
those aren't effective inside rootless Podman containers.
It's quite useful when using OSTree based operating systems like Fedora
Silverblue, where development environments are often set up using
rootless Podman containers with helpers like Toolbox [1]. Not having
a basic network utility like ping(8) work inside the development
environment can be inconvenient.
See:
https://lwn.net/Articles/422330/
http://man7.org/linux/man-pages/man7/icmp.7.html
containers/podman#1550
[1] https://github.com/debarshiray/toolbox