-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rootless ICMP ping #147
Comments
Those docs seem to be confusing UDP and ICMP. |
Maybe the doc is wrong, maybe it says "udp" as IPPROTO_ICMP socket is created with SOCK_DGRAM as a second argument (like UDP socket using |
The docs are definitely wrong, the only reference to ICMP is for privileged sockets which means root. I think we need more clarity here, and knowing which kernels support this. |
AFAIK, it's mainlined since v2.6.39. I have not figured out earliest MacOSX version supporting |
So introduced just under 6 years ago, that's relatively new as kernel features go. |
The docs match test code at https://github.com/golang/net/blob/master/icmp/ping_test.go#L61 |
The docs indicate you need privileged access to use this feature: "For privileged raw ICMP endpoints, network must be "ip4" or "ip6" followed by a colon and an ICMP protocol number or name." |
The part of the doc that is relevant to the ticket is located a couple of paragraphs above:
It also needs some privileges, running process should be in the group within Please, take a look at icmp/ping_test.go and icmp/listen_posix.go before repeating that docs confuse UDP and ICMP. |
This line as written confuses ICMP and UDP, and the following example only mentions UDP. My interpretation is that this is probably a typo and that ICMP should be UDP.
If I need to read source code to see what the docs actually mean, then the docs are confusing and/or wrong.
That's not of too much use then. A feature that only works on newer kernels and requires additional setup doesn't win over SUID or NET_ADMIN which work ~everywhere. |
We should document both the setcap The only major distribution with a kernel older than 2.6.39 is RHEL6. RHEL7 has been out since 2014. |
This would also require code changes, this is a different API. |
Right, but we could handle that with fallback detection. |
Centos 6.9 was released last month, is supported until 2020 and comes with 2.6.32. We have users on older systems (including at least one that can't even run Go out of the box as their kernel is so old). I'm wary of adding features that require tweaking sysctls to work, and don't work for everyone as that's a non-trivial amount of cognitive overhead. Users will want this to just work out of the box, and I suspect this will also be Fun with containers. We already have two documented ways to make this work on Linux, why should we add a third that doesn't work for everyone? |
Users already have to tweak |
@brian-brazil So, after reading the docs, and the source, I think I understand your confusion. There are two modes of operation unprivileged, and privileged for ICMP ListenPacket. The The docs aren't wrong, they're just a little confusing since they aren't verbose about what the connection type strings stand for. Either way, that's just a distraction from the real issue. We should attempt to use unprivileged ListenPacket and fall back to privileged automatically. |
+1 |
FWIW, I was able to finally get non-root ICMP pings working with blackbox-exporter. The key was setting net.ipv4.ping_group_range as part of the pod security context. No other combinations of adding NET_RAW, groups, custom containers that had setcap cap_net_raw+ep on the binary worked (except for running as root). net.ipv4.ping_group_range is namespaced so that changing it as part of the pod won't affect other parts of the system. My testing was done with blackbox exporter 0.19.0, CentOS 7, kernel 3.10.0-1160.31.1.el7.x86_64, and Kubernetes 1.21.2.
|
Working values.yaml below (plus an ingress). Appreciate it's long but it should work in 2024...
|
Looks like it doesn't work in 2024, |
x/net/icmp supports root-less operation for ICMP pings on Linux and MacOSX, but blackbox_exporter requires elevated privileges for that.
Are there any non-obvious blockers for using rootless ping sockets? I've looked at the code and I've not noticed any.
The text was updated successfully, but these errors were encountered: