Package: fping
Version: 5.1-1
Severity: important
Tags: patch upstream fixed-upstream
Control: fixed -1 5.5-2

Dear Maintainer,

When fping 5.1 can't open a raw ICMP socket, it falls back to an unprivileged
ICMP datagram socket (SOCK_DGRAM, permitted by net.ipv4.ping_group_range). In
that mode it reports every target as unreachable, including 127.0.0.1 and ::1,
although the echo replies are delivered.

On SOCK_DGRAM ICMP sockets the kernel rewrites the echo identifier to the
socket's local port. fping 5.1 only reads that identifier back (getsockname())
when a source address is given with -S, so without -S every reply fails the
"id != ident4" check and is discarded. This is upstream issue #248, fixed in
5.2 by a two-line change:

  https://github.com/schweikert/fping/issues/248
  
https://github.com/schweikert/fping/commit/e975a4339b24716fb57bed234b0a1176f2bf3451

The packaged binary gets cap_net_raw+ep in postinst, so a plain host install
isn't affected. It shows up wherever the file capability doesn't take effect:
containers with no-new-privileges (for example the Zabbix server/proxy images,
where every ICMP check then reports 100% loss), rootless or user-namespaced
runtimes, and copies of the binary run by a normal user.

To reproduce, as a normal user with ping_group_range covering your gid:

  $ cp /usr/bin/fping /tmp/fping-nocap
  $ /tmp/fping-nocap 127.0.0.1
  127.0.0.1 is unreachable
  $ /tmp/fping-nocap -6 ::1
  ::1 is unreachable

Tested in debian:bookworm, debian:trixie and debian:sid containers (arm64,
kernel 6.15):

  bookworm 12.15, fping 5.1-1       127.0.0.1 / ::1 unreachable
  trixie   13.8,  fping 5.1-1+b1    127.0.0.1 / ::1 unreachable
  sid,            fping 5.5-2       127.0.0.1 / ::1 alive

I rebuilt 5.1-1 with the attached patch for bookworm (5.1-1+deb12u1) and trixie
(5.1-1+deb13u1). Unprivileged IPv4 and IPv6 pings, multiple targets with -c,
and the no-new-privileges container case all work. Raw-socket mode (root), -S,
and reporting an unreachable host (192.0.2.1, exit 1) behave as before.

The patch is the upstream commit, using the 5.2 form of the IPv6 line
(socktype6). The original commit compared socktype4 there, which upstream
corrected before 5.2. Would you consider it for the next trixie (and bookworm)
point release?

The same 5.1 package is in Ubuntu 24.04-26.10; an SRU is requested there:
https://bugs.launchpad.net/ubuntu/+source/fping/+bug/2178378

Thanks for maintaining fping!

Attachment: fix-unprivileged-ping.patch
Description: Binary data

Reply via email to