Compare commits
No commits in common. 'c8' and 'c9' have entirely different histories.
@ -1,2 +1,2 @@
|
|||||||
SOURCES/ifenslave.tar.gz
|
SOURCES/ifenslave.tar.gz
|
||||||
SOURCES/iputils-s20180629.tar.gz
|
SOURCES/iputils-20210202.tar.gz
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
1e2652cb1d1e29a8ebed1209131924a6eb864daf SOURCES/ifenslave.tar.gz
|
1e2652cb1d1e29a8ebed1209131924a6eb864daf SOURCES/ifenslave.tar.gz
|
||||||
353df20691bf027ad35fcaaf6894b122c39d8f2d SOURCES/iputils-s20180629.tar.gz
|
4e552cd0478388e1551853020b60efda18592028 SOURCES/iputils-20210202.tar.gz
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
--- iputils-s20160308/Makefile 2016-03-08 13:58:56.000000000 +0100
|
|
||||||
+++ iputils-s20160308-new/Makefile 2016-03-09 10:09:02.295409179 +0100
|
|
||||||
@@ -36,7 +36,7 @@ WITHOUT_IFADDRS=no
|
|
||||||
ARPING_DEFAULT_DEVICE=
|
|
||||||
|
|
||||||
# nettle library for ipv6 ping [yes|no|static]
|
|
||||||
-USE_NETTLE=yes
|
|
||||||
+USE_NETTLE=no
|
|
||||||
# libgcrypt library for ipv6 ping [no|yes|static]
|
|
||||||
USE_GCRYPT=no
|
|
||||||
# Crypto library for ping6 [shared|static|no]
|
|
||||||
@@ -53,7 +53,7 @@ ENABLE_RDISC_SERVER=no
|
|
||||||
# What a pity, all new gccs are buggy and -Werror does not work. Sigh.
|
|
||||||
# CFLAGS+=-fno-strict-aliasing -Wstrict-prototypes -Wall -Werror -g
|
|
||||||
CFLAGS?=-O3 -g
|
|
||||||
-CFLAGS+=-fno-strict-aliasing -Wstrict-prototypes -Wall
|
|
||||||
+CFLAGS+=$(RPM_OPT_FLAGS) -fno-strict-aliasing -Wstrict-prototypes -Wall
|
|
||||||
CPPFLAGS+=-D_GNU_SOURCE
|
|
||||||
LDLIB=
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
|||||||
--- a/ping.c 2018-06-29 20:00:46.000000000 +0200
|
|
||||||
+++ b/ping.c 2019-07-10 09:50:06.653039073 +0200
|
|
||||||
@@ -589,8 +589,10 @@ int ping4_run(int argc, char **argv, str
|
|
||||||
strncpy(hnamebuf, ai->ai_canonname, sizeof hnamebuf - 1);
|
|
||||||
hostname = hnamebuf;
|
|
||||||
|
|
||||||
- if (result)
|
|
||||||
+ if (result) {
|
|
||||||
freeaddrinfo(result);
|
|
||||||
+ ai = NULL;
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
if (argc > 1)
|
|
||||||
route[nroute++] = whereto.sin_addr.s_addr;
|
|
@ -1,25 +0,0 @@
|
|||||||
From 445826446c32035b3c8e8a7780c4e4b885f0f98f Mon Sep 17 00:00:00 2001
|
|
||||||
From: Jan Macku <jamacku@redhat.com>
|
|
||||||
Date: Mon, 7 Dec 2020 15:08:14 +0100
|
|
||||||
Subject: [PATCH] ping: Fix incorrect statistics
|
|
||||||
|
|
||||||
---
|
|
||||||
ping_common.c | 2 +-
|
|
||||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/ping_common.c b/ping_common.c
|
|
||||||
index 040bf23..02cb5e1 100644
|
|
||||||
--- a/ping_common.c
|
|
||||||
+++ b/ping_common.c
|
|
||||||
@@ -934,7 +934,7 @@ void finish(void)
|
|
||||||
printf(", %g%% packet loss",
|
|
||||||
(float) ((((long long)(ntransmitted - nreceived)) * 100.0) /
|
|
||||||
ntransmitted));
|
|
||||||
- printf(", time %ldms", (1000*tv.tv_sec+tv.tv_usec+500)/1000);
|
|
||||||
+ printf(", time %ldms", 1000*tv.tv_sec+(tv.tv_usec+500)/1000);
|
|
||||||
}
|
|
||||||
putchar('\n');
|
|
||||||
|
|
||||||
--
|
|
||||||
2.28.0
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
|||||||
From e0baf20067a75f093d690bd51a6db3f5afabca77 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Petr Vorel <pvorel@suse.cz>
|
|
||||||
Date: Tue, 17 Jul 2018 17:56:10 +0200
|
|
||||||
Subject: [PATCH] tracepath: Fix copying input IPv6 address
|
|
||||||
|
|
||||||
Commit e669c86 broke copying input IPv6 address.
|
|
||||||
tracepath recover from it, but it's slower.
|
|
||||||
|
|
||||||
Previously was address too short:
|
|
||||||
|
|
||||||
strace ./tracepath -6 fe80::8895:e2af:e96e:fd8f
|
|
||||||
sendto(3, "\1\0\0\0\0\0\0\0\307\36N[\0\0\0\0w_\f\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 127952, 0, {sa_family=AF_INET6, sin6_port=htons(44444), inet_pton(AF_INET6, "fe80::", &sin6_addr), sin6_flowinfo=htonl(0), sin6_scope_id=0}, 28) = -1 EMSGSIZE (Message too long)
|
|
||||||
|
|
||||||
After fix is correct:
|
|
||||||
|
|
||||||
sendto(3, "\1\0\0\0\0\0\0\0\300\36N[\0\0\0\0'B\3\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 127952, 0, {sa_family=AF_INET6, sin6_port=htons(44444), inet_pton(AF_INET6, "fe80::8895:e2af:e96e:fd8f", &sin6_addr), sin6_flowinfo=htonl(0), sin6_scope_id=0}, 28) = -1 EMSGSIZE (Message too long)
|
|
||||||
|
|
||||||
Bug found by LTP test.
|
|
||||||
|
|
||||||
Fixes: e669c86 tracepath: fix heap-buffer-overflow [asan]
|
|
||||||
Fixes: #137
|
|
||||||
---
|
|
||||||
tracepath.c | 2 +-
|
|
||||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/tracepath.c b/tracepath.c
|
|
||||||
index 53bda16f..539a7a11 100644
|
|
||||||
--- a/tracepath.c
|
|
||||||
+++ b/tracepath.c
|
|
||||||
@@ -475,7 +475,7 @@ int main(int argc, char **argv)
|
|
||||||
fd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
|
|
||||||
if (fd < 0)
|
|
||||||
continue;
|
|
||||||
- memcpy(&target, ai->ai_addr, sizeof(*ai->ai_addr));
|
|
||||||
+ memcpy(&target, ai->ai_addr, ai->ai_addrlen);
|
|
||||||
targetlen = ai->ai_addrlen;
|
|
||||||
break;
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
From 18f9a84e0e702841d6cc4d5f593de4fbd1348e83 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Sami Kerola <kerolasa@iki.fi>
|
|
||||||
Date: Sat, 28 Dec 2019 17:16:27 +0000
|
|
||||||
Subject: [PATCH] ninfod: change variable name to avoid colliding with function
|
|
||||||
name
|
|
||||||
|
|
||||||
The sys/capability.h header has 'extern int cap_setuid(uid_t uid);'
|
|
||||||
function prototype.
|
|
||||||
|
|
||||||
Addresses: https://github.com/iputils/iputils/issues/246
|
|
||||||
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
|
|
||||||
---
|
|
||||||
ninfod/ninfod.c | 8 ++++----
|
|
||||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/ninfod/ninfod.c b/ninfod/ninfod.c
|
|
||||||
index 26112d0d..95583de4 100644
|
|
||||||
--- a/ninfod/ninfod.c
|
|
||||||
+++ b/ninfod/ninfod.c
|
|
||||||
@@ -455,7 +455,7 @@ static void do_daemonize(void)
|
|
||||||
/* --------- */
|
|
||||||
#ifdef HAVE_LIBCAP
|
|
||||||
static const cap_value_t cap_net_raw = CAP_NET_RAW;
|
|
||||||
-static const cap_value_t cap_setuid = CAP_SETUID;
|
|
||||||
+static const cap_value_t cap_setuserid = CAP_SETUID;
|
|
||||||
static cap_flag_value_t cap_ok;
|
|
||||||
#else
|
|
||||||
static uid_t euid;
|
|
||||||
@@ -487,7 +487,7 @@ static void limit_capabilities(void)
|
|
||||||
|
|
||||||
cap_get_flag(cap_cur_p, CAP_SETUID, CAP_PERMITTED, &cap_ok);
|
|
||||||
if (cap_ok != CAP_CLEAR)
|
|
||||||
- cap_set_flag(cap_p, CAP_PERMITTED, 1, &cap_setuid, CAP_SET);
|
|
||||||
+ cap_set_flag(cap_p, CAP_PERMITTED, 1, &cap_setuserid, CAP_SET);
|
|
||||||
|
|
||||||
if (cap_set_proc(cap_p) < 0) {
|
|
||||||
DEBUG(LOG_ERR, "cap_set_proc: %s\n", strerror(errno));
|
|
||||||
@@ -520,8 +520,8 @@ static void drop_capabilities(void)
|
|
||||||
|
|
||||||
/* setuid / setuid */
|
|
||||||
if (cap_ok != CAP_CLEAR) {
|
|
||||||
- cap_set_flag(cap_p, CAP_PERMITTED, 1, &cap_setuid, CAP_SET);
|
|
||||||
- cap_set_flag(cap_p, CAP_EFFECTIVE, 1, &cap_setuid, CAP_SET);
|
|
||||||
+ cap_set_flag(cap_p, CAP_PERMITTED, 1, &cap_setuserid, CAP_SET);
|
|
||||||
+ cap_set_flag(cap_p, CAP_EFFECTIVE, 1, &cap_setuserid, CAP_SET);
|
|
||||||
|
|
||||||
if (cap_set_proc(cap_p) < 0) {
|
|
||||||
DEBUG(LOG_ERR, "cap_set_proc: %s\n", strerror(errno));
|
|
@ -1,113 +0,0 @@
|
|||||||
From dc4f836759887a6edf141aa55adbdb9bc63f5e69 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Jan Macku <jamacku@redhat.com>
|
|
||||||
Date: Tue, 22 Mar 2022 12:59:21 +0100
|
|
||||||
Subject: [PATCH] ping: Fix unwanted bell on unreachable address
|
|
||||||
|
|
||||||
Commit 4471ac629cf2603f4b8b45e042e072c992ce25a5 caused regression for IPv6
|
|
||||||
that ping -a IP6_ADDR beeps also on wrong address (i.e. when "Address
|
|
||||||
unreachable"):
|
|
||||||
|
|
||||||
$ ping -a -c1 fd00:1:1:1::15
|
|
||||||
PING fd00:1:1:1::15(fd00:1:1:1::15) 56 data bytes
|
|
||||||
From fd00:1:1:1::2 icmp_seq=1 Destination unreachable: Address unreachable
|
|
||||||
|
|
||||||
--- fd00:1:1:1::15 ping statistics ---
|
|
||||||
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0m
|
|
||||||
|
|
||||||
It should only bell when ping returns correctly.
|
|
||||||
|
|
||||||
Another (fixed) regression was that ping after exit printed error "pipe N",
|
|
||||||
where N is number of counts. Error was result of code from ping_common.c:
|
|
||||||
printf("%spipe %d", comma, pipesize);
|
|
||||||
|
|
||||||
4471ac6 was wrong that code for sock->working_recverr == 1 should stay,
|
|
||||||
sock->working_recverr should be removed.
|
|
||||||
|
|
||||||
Thus changes:
|
|
||||||
* ping.c: put back "stronger filter" for raw socket but (unlike before
|
|
||||||
4471ac6) exit with 2 if setsockopt(ICMP_FILTER) fails
|
|
||||||
* ping6_common.c: put back setsockopt(IPV6_RECVERR), but (unlike before
|
|
||||||
4471ac6) exit with 2 if it fails
|
|
||||||
* ping6_common.c: remove ICMP6_FILTER_SETPASS calls. These caused error "pipe N".
|
|
||||||
* ping6_common.c: return 0 after acknowledge() in ping6_parse_reply
|
|
||||||
|
|
||||||
Fixes: 4471ac6 ("ping: Remove workaround for bug in IP_RECVERR on raw sockets")
|
|
||||||
Fixes: https://github.com/iputils/iputils/issues/182
|
|
||||||
Reported-by: Luiz Angelo Daros de Luca <luizluca@tre-sc.jus.br>
|
|
||||||
Signed-off-by: Petr Vorel <pvorel@suse.cz>
|
|
||||||
Reviewed-by: Sami Kerola <kerolasa@iki.fi>
|
|
||||||
|
|
||||||
---
|
|
||||||
Patch has been adjusted to be applicable to RHEL8 codebase
|
|
||||||
|
|
||||||
Resolves: #2057570
|
|
||||||
---
|
|
||||||
ping.c | 11 +++++++++++
|
|
||||||
ping6_common.c | 15 +++------------
|
|
||||||
2 files changed, 14 insertions(+), 12 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/ping.c b/ping.c
|
|
||||||
index d9a3f5d..c870390 100644
|
|
||||||
--- a/ping.c
|
|
||||||
+++ b/ping.c
|
|
||||||
@@ -949,6 +949,17 @@ int ping4_receive_error_msg(socket_st *sock)
|
|
||||||
|
|
||||||
acknowledge(ntohs(icmph.un.echo.sequence));
|
|
||||||
|
|
||||||
+ if (sock->socktype == SOCK_RAW)
|
|
||||||
+ {
|
|
||||||
+ struct icmp_filter filt;
|
|
||||||
+
|
|
||||||
+ filt.data = ~((1 << ICMP_SOURCE_QUENCH) |
|
|
||||||
+ (1 << ICMP_REDIRECT) |
|
|
||||||
+ (1 << ICMP_ECHOREPLY));
|
|
||||||
+ if (setsockopt(sock->fd, SOL_RAW, ICMP_FILTER, (const void *)&filt,
|
|
||||||
+ sizeof(filt)) == -1)
|
|
||||||
+ error(2, errno, "setsockopt(ICMP_FILTER)");
|
|
||||||
+ }
|
|
||||||
net_errors++;
|
|
||||||
nerrors++;
|
|
||||||
if (options & F_QUIET)
|
|
||||||
diff --git a/ping6_common.c b/ping6_common.c
|
|
||||||
index 5991c2a..1181341 100644
|
|
||||||
--- a/ping6_common.c
|
|
||||||
+++ b/ping6_common.c
|
|
||||||
@@ -879,6 +879,8 @@ int ping6_run(int argc, char **argv, struct addrinfo *ai, struct socket_st *sock
|
|
||||||
}
|
|
||||||
|
|
||||||
hold = 1;
|
|
||||||
+ if (setsockopt(sock->fd, IPPROTO_IPV6, IPV6_RECVERR, (const void *)&hold, sizeof hold))
|
|
||||||
+ error(2, errno, "IPV6_RECVERR");
|
|
||||||
|
|
||||||
/* Estimate memory eaten by single packet. It is rough estimate.
|
|
||||||
* Actually, for small datalen's it depends on kernel side a lot. */
|
|
||||||
@@ -906,11 +908,6 @@ int ping6_run(int argc, char **argv, struct addrinfo *ai, struct socket_st *sock
|
|
||||||
|
|
||||||
ICMP6_FILTER_SETBLOCKALL(&filter);
|
|
||||||
|
|
||||||
- ICMP6_FILTER_SETPASS(ICMP6_DST_UNREACH, &filter);
|
|
||||||
- ICMP6_FILTER_SETPASS(ICMP6_PACKET_TOO_BIG, &filter);
|
|
||||||
- ICMP6_FILTER_SETPASS(ICMP6_TIME_EXCEEDED, &filter);
|
|
||||||
- ICMP6_FILTER_SETPASS(ICMP6_PARAM_PROB, &filter);
|
|
||||||
-
|
|
||||||
if (niquery_is_enabled())
|
|
||||||
ICMP6_FILTER_SETPASS(ICMPV6_NI_REPLY, &filter);
|
|
||||||
else
|
|
||||||
@@ -1437,13 +1434,7 @@ ping6_parse_reply(socket_st *sock, struct msghdr *msg, int cc, void *addr, struc
|
|
||||||
!is_ours(sock, icmph1->icmp6_id))
|
|
||||||
return 1;
|
|
||||||
acknowledge(ntohs(icmph1->icmp6_seq));
|
|
||||||
- nerrors++;
|
|
||||||
- if (options & F_FLOOD) {
|
|
||||||
- write_stdout("\bE", 2);
|
|
||||||
- return 0;
|
|
||||||
- }
|
|
||||||
- print_timestamp();
|
|
||||||
- printf("From %s: icmp_seq=%u ", pr_addr(from, sizeof *from), ntohs(icmph1->icmp6_seq));
|
|
||||||
+ return 0;
|
|
||||||
} else {
|
|
||||||
/* We've got something other than an ECHOREPLY */
|
|
||||||
if (!(options & F_VERBOSE) || uid)
|
|
||||||
--
|
|
||||||
2.35.1
|
|
||||||
|
|
@ -0,0 +1,51 @@
|
|||||||
|
From 79d713eab6181e219bf932b404706f6f59ff2539 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Byron Stanoszek <gandalf@winds.org>
|
||||||
|
Date: Thu, 16 Sep 2021 23:38:54 +0200
|
||||||
|
Subject: [PATCH] ping: Remove 'unsupported IPv6' warning on disabled IPv6
|
||||||
|
|
||||||
|
Regression was introduced in d141cb6 as introduced condition
|
||||||
|
|
||||||
|
if ((errno == EAFNOSUPPORT && socktype == AF_INET6) || options & F_VERBOSE || requisite)
|
||||||
|
|
||||||
|
was wrong, it should have been:
|
||||||
|
|
||||||
|
if ((errno == EAFNOSUPPORT && family == AF_INET6 && requisite) || options & F_VERBOSE)
|
||||||
|
|
||||||
|
but bug was hidden as `family == AF_INET6' was always false until
|
||||||
|
otherwise correct fix 904cdb6 ("ping: AF_INET6 is address family not
|
||||||
|
socket type [lgtm scan]") propagated the error.
|
||||||
|
|
||||||
|
Tested on kernel booted with ipv6.disable=1 (disabling via sysctl, i.e.
|
||||||
|
sysctl -w net.ipv6.conf.all.disable_ipv6=1; sysctl -w net.ipv6.conf.default.disable_ipv6=1
|
||||||
|
does not trigger the issue as it exit with "socket: Address family not
|
||||||
|
supported by protocol" - errno EADDRNOTAVAIL).
|
||||||
|
|
||||||
|
Fixes: d141cb6 ("ping: work with older kernels that don't support ping sockets")
|
||||||
|
Closes: https://github.com/iputils/iputils/issues/293
|
||||||
|
Closes: https://github.com/iputils/iputils/pull/370
|
||||||
|
|
||||||
|
Reported-by: lekto <lekto@o2.pl>
|
||||||
|
Reviewed-by: Andrew Clayton <andrew@digital-domain.net>
|
||||||
|
Reviewed-by: Petr Vorel <pvorel@suse.cz>
|
||||||
|
Signed-off-by: Byron Stanoszek <gandalf@winds.org>
|
||||||
|
[ pvorel: create commit from Byron's patch on the issue, do analysis and wrote commit message ]
|
||||||
|
Signed-off-by: Petr Vorel <pvorel@suse.cz>
|
||||||
|
---
|
||||||
|
ping/ping.c | 4 ++--
|
||||||
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/ping/ping.c b/ping/ping.c
|
||||||
|
index 6fcb44f2..0655bf4a 100644
|
||||||
|
--- a/ping/ping.c
|
||||||
|
+++ b/ping/ping.c
|
||||||
|
@@ -150,8 +150,8 @@ static void create_socket(struct ping_rts *rts, socket_st *sock, int family,
|
||||||
|
/* Report error related to disabled IPv6 only when IPv6 also failed or in
|
||||||
|
* verbose mode. Report other errors always.
|
||||||
|
*/
|
||||||
|
- if ((errno == EAFNOSUPPORT && family == AF_INET6) ||
|
||||||
|
- rts->opt_verbose || requisite)
|
||||||
|
+ if ((errno == EAFNOSUPPORT && family == AF_INET6 && requisite) ||
|
||||||
|
+ rts->opt_verbose)
|
||||||
|
error(0, errno, "socket");
|
||||||
|
if (requisite)
|
||||||
|
exit(2);
|
@ -0,0 +1,95 @@
|
|||||||
|
From 36580e1d539b4bb7c187d4cf9ccc63afad9edbb1 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Lahav Schlesinger <lschlesinger@drivenets.com>
|
||||||
|
Date: Wed, 30 Jun 2021 13:06:13 +0300
|
||||||
|
Subject: [PATCH 1/2] ping: Fix ping6 binding to VRF and address
|
||||||
|
|
||||||
|
Since Linux kernel commit 1893ff20275b ("net/ipv6: Add l3mdev check to
|
||||||
|
ipv6_chk_addr_and_flags") from v4.17-rc1 ping fails when trying to
|
||||||
|
create IPv6 SOCK_RAW socket (e.g. if net.ipv4.ping_group_range = 1 0)
|
||||||
|
and passing both -I <vrf_interface> and -I <local_ipv6_addr>.
|
||||||
|
It works for IPv4 SOCK_RAW socket.
|
||||||
|
|
||||||
|
# ip netns add tmp_ns
|
||||||
|
# ip -n tmp_ns link add vrf_1 type vrf table 10001
|
||||||
|
# ip -n tmp_ns link add lo10 type dummy
|
||||||
|
# ip -n tmp_ns link set lo10 master vrf_1
|
||||||
|
# ip -n tmp_ns link set vrf_1 up
|
||||||
|
# ip -n tmp_ns link set lo10 up
|
||||||
|
# ip -n tmp_ns link set lo up
|
||||||
|
# ip -n tmp_ns addr add 1:2::3:4/128 dev lo10
|
||||||
|
# ip -n tmp_ns addr add 1.2.3.4/32 dev lo10
|
||||||
|
|
||||||
|
# ip netns exec tmp_ns ping -6 1:2::3:4 -I vrf_1 -I 1:2::3:4 -c 1 # IPv6 broken
|
||||||
|
ping: bind icmp socket: Cannot assign requested address
|
||||||
|
|
||||||
|
# ping 1.2.3.4 -I vrf_1 -I 1.2.3.4 -c 1 # IPv4 working
|
||||||
|
PING 1.2.3.4 (1.2.3.4) from 1.2.3.4 vrf_1: 56(84) bytes of data.
|
||||||
|
64 bytes from 1.2.3.4: icmp_seq=1 ttl=64 time=0.090 ms
|
||||||
|
|
||||||
|
--- 1.2.3.4 ping statistics ---
|
||||||
|
1 packets transmitted, 1 received, 0% packet loss, time 0ms
|
||||||
|
rtt min/avg/max/mdev = 0.090/0.090/0.090/0.000 ms
|
||||||
|
|
||||||
|
ping fails because it doesn't actually bind to the VRF interface, while
|
||||||
|
after 1893ff20275b, binding to an IPv6 address searches only on the same
|
||||||
|
l3mdev as the device the function receives. If the socket wasn't
|
||||||
|
SO_BINDTODEVICE-ed, then the kernel will only search for devices that
|
||||||
|
are not ensalved to an l3mdev device (= in the default VRF), which will
|
||||||
|
cause the bind() to fail.
|
||||||
|
|
||||||
|
Only SOCK_RAW socket is affected. SOCK_DGRAM is not affected because
|
||||||
|
Linux kernel doesn't check the device the socket was SO_BINDTODEVICE-ed
|
||||||
|
to, but only the device from addr->sin6_scope_id (which if none is
|
||||||
|
passed, it will again only search devices in the default VRF).
|
||||||
|
|
||||||
|
NOTE: creating network namespace to reproduce the issue is needed just
|
||||||
|
on systems with net.ipv4.ping_group_range = 0 2147483647 (e.g. current
|
||||||
|
Fedora, openSUSE, Ubuntu), which causes to use SOCK_DGRAM socket.
|
||||||
|
Alternatively to force SOCK_RAW to it'd be enough just to properly set
|
||||||
|
net.ipv4.ping_group_range:
|
||||||
|
|
||||||
|
# echo "1 0" > /proc/sys/net/ipv4/ping_group_range
|
||||||
|
|
||||||
|
Closes: https://github.com/iputils/iputils/pull/344
|
||||||
|
|
||||||
|
Reviewed-by: Petr Vorel <pvorel@suse.cz>
|
||||||
|
Signed-off-by: Lahav Schlesinger <lschlesinger@drivenets.com>
|
||||||
|
[ pvorel: adjusted commit message ]
|
||||||
|
Signed-off-by: Petr Vorel <pvorel@suse.cz>
|
||||||
|
(cherry picked from commit 7c65999f98bc4a1984594b7fad1af0eaf0b9d34b)
|
||||||
|
---
|
||||||
|
ping/ping6_common.c | 11 +++++++++++
|
||||||
|
1 file changed, 11 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/ping/ping6_common.c b/ping/ping6_common.c
|
||||||
|
index 4712928..98b5adb 100644
|
||||||
|
--- a/ping/ping6_common.c
|
||||||
|
+++ b/ping/ping6_common.c
|
||||||
|
@@ -223,6 +223,8 @@ int ping6_run(struct ping_rts *rts, int argc, char **argv, struct addrinfo *ai,
|
||||||
|
if (rts->device) {
|
||||||
|
struct cmsghdr *cmsg;
|
||||||
|
struct in6_pktinfo *ipi;
|
||||||
|
+ int rc;
|
||||||
|
+ int errno_save;
|
||||||
|
|
||||||
|
cmsg = (struct cmsghdr *)(rts->cmsgbuf + rts->cmsglen);
|
||||||
|
rts->cmsglen += CMSG_SPACE(sizeof(*ipi));
|
||||||
|
@@ -233,6 +235,15 @@ int ping6_run(struct ping_rts *rts, int argc, char **argv, struct addrinfo *ai,
|
||||||
|
ipi = (struct in6_pktinfo *)CMSG_DATA(cmsg);
|
||||||
|
memset(ipi, 0, sizeof(*ipi));
|
||||||
|
ipi->ipi6_ifindex = if_name2index(rts->device);
|
||||||
|
+
|
||||||
|
+ enable_capability_raw();
|
||||||
|
+ rc = setsockopt(sock->fd, SOL_SOCKET, SO_BINDTODEVICE,
|
||||||
|
+ rts->device, strlen(rts->device) + 1);
|
||||||
|
+ errno_save = errno;
|
||||||
|
+ disable_capability_raw();
|
||||||
|
+
|
||||||
|
+ if (rc == -1)
|
||||||
|
+ error(2, errno_save, "SO_BINDTODEVICE %s", rts->device);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IN6_IS_ADDR_MULTICAST(&rts->whereto6.sin6_addr)) {
|
||||||
|
--
|
||||||
|
2.46.0
|
||||||
|
|
@ -0,0 +1,54 @@
|
|||||||
|
From a2d2428c5fa6bf370486f509b18862c5c7b8b47e Mon Sep 17 00:00:00 2001
|
||||||
|
From: Petr Vorel <pvorel@suse.cz>
|
||||||
|
Date: Tue, 9 Nov 2021 02:39:56 +0100
|
||||||
|
Subject: [PATCH 2/2] ping6: Avoid binding to non-VRF
|
||||||
|
|
||||||
|
This fixes permission issue when specifying just address (without VRF)
|
||||||
|
unless having CAP_NET_ADMIN (i.e. root) permission:
|
||||||
|
|
||||||
|
$ ./builddir/ping/ping -c1 -I lo ::1
|
||||||
|
./builddir/ping/ping: SO_BINDTODEVICE lo: Operation not permitted
|
||||||
|
|
||||||
|
because setsockopt() SO_BINDTODEVICE (similar to bind()) can be only done on
|
||||||
|
opt_strictsource.
|
||||||
|
|
||||||
|
Fixes: 7c65999 ("ping: Fix ping6 binding to VRF and address")
|
||||||
|
|
||||||
|
Signed-off-by: Petr Vorel <pvorel@suse.cz>
|
||||||
|
(cherry picked from commit f52b582248f1f870e870a9973621805d969906b4)
|
||||||
|
---
|
||||||
|
ping/ping6_common.c | 18 ++++++++++--------
|
||||||
|
1 file changed, 10 insertions(+), 8 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/ping/ping6_common.c b/ping/ping6_common.c
|
||||||
|
index 98b5adb..a784be0 100644
|
||||||
|
--- a/ping/ping6_common.c
|
||||||
|
+++ b/ping/ping6_common.c
|
||||||
|
@@ -236,14 +236,16 @@ int ping6_run(struct ping_rts *rts, int argc, char **argv, struct addrinfo *ai,
|
||||||
|
memset(ipi, 0, sizeof(*ipi));
|
||||||
|
ipi->ipi6_ifindex = if_name2index(rts->device);
|
||||||
|
|
||||||
|
- enable_capability_raw();
|
||||||
|
- rc = setsockopt(sock->fd, SOL_SOCKET, SO_BINDTODEVICE,
|
||||||
|
- rts->device, strlen(rts->device) + 1);
|
||||||
|
- errno_save = errno;
|
||||||
|
- disable_capability_raw();
|
||||||
|
-
|
||||||
|
- if (rc == -1)
|
||||||
|
- error(2, errno_save, "SO_BINDTODEVICE %s", rts->device);
|
||||||
|
+ if (rts->opt_strictsource) {
|
||||||
|
+ enable_capability_raw();
|
||||||
|
+ rc = setsockopt(sock->fd, SOL_SOCKET, SO_BINDTODEVICE,
|
||||||
|
+ rts->device, strlen(rts->device) + 1);
|
||||||
|
+ errno_save = errno;
|
||||||
|
+ disable_capability_raw();
|
||||||
|
+
|
||||||
|
+ if (rc == -1)
|
||||||
|
+ error(2, errno_save, "SO_BINDTODEVICE %s", rts->device);
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IN6_IS_ADDR_MULTICAST(&rts->whereto6.sin6_addr)) {
|
||||||
|
--
|
||||||
|
2.46.0
|
||||||
|
|
@ -0,0 +1,88 @@
|
|||||||
|
From a38091c8eb0c515441080806975856ee09d2edc7 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jan Macku <jamacku@redhat.com>
|
||||||
|
Date: Tue, 23 Mar 2021 08:10:10 +0100
|
||||||
|
Subject: [PATCH] ifenslave: fix CWE-170: Improper Null Termination
|
||||||
|
|
||||||
|
---
|
||||||
|
ifenslave.c | 24 ++++++++++++++++--------
|
||||||
|
1 file changed, 16 insertions(+), 8 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/ifenslave.c b/ifenslave.c
|
||||||
|
index ddd82ec..1efe4f1 100644
|
||||||
|
--- a/ifenslave.c
|
||||||
|
+++ b/ifenslave.c
|
||||||
|
@@ -509,21 +509,24 @@ static int if_getconfig(char *ifname)
|
||||||
|
struct sockaddr dstaddr, broadaddr, netmask;
|
||||||
|
unsigned char *hwaddr;
|
||||||
|
|
||||||
|
- strcpy(ifr.ifr_name, ifname);
|
||||||
|
+ memset(&ifr, 0, sizeof(ifr));
|
||||||
|
+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1);
|
||||||
|
if (ioctl(skfd, SIOCGIFFLAGS, &ifr) < 0)
|
||||||
|
return -1;
|
||||||
|
mif_flags = ifr.ifr_flags;
|
||||||
|
printf("The result of SIOCGIFFLAGS on %s is %x.\n",
|
||||||
|
ifname, ifr.ifr_flags);
|
||||||
|
|
||||||
|
- strcpy(ifr.ifr_name, ifname);
|
||||||
|
+ memset(&ifr, 0, sizeof(ifr));
|
||||||
|
+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1);
|
||||||
|
if (ioctl(skfd, SIOCGIFADDR, &ifr) < 0)
|
||||||
|
return -1;
|
||||||
|
printf("The result of SIOCGIFADDR is %2.2x.%2.2x.%2.2x.%2.2x.\n",
|
||||||
|
ifr.ifr_addr.sa_data[2], ifr.ifr_addr.sa_data[3],
|
||||||
|
ifr.ifr_addr.sa_data[4], ifr.ifr_addr.sa_data[5]);
|
||||||
|
|
||||||
|
- strcpy(ifr.ifr_name, ifname);
|
||||||
|
+ memset(&ifr, 0, sizeof(ifr));
|
||||||
|
+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1);
|
||||||
|
if (ioctl(skfd, SIOCGIFHWADDR, &ifr) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
@@ -534,33 +537,38 @@ static int if_getconfig(char *ifname)
|
||||||
|
ifr.ifr_hwaddr.sa_family, hwaddr[0], hwaddr[1],
|
||||||
|
hwaddr[2], hwaddr[3], hwaddr[4], hwaddr[5]);
|
||||||
|
|
||||||
|
- strcpy(ifr.ifr_name, ifname);
|
||||||
|
+ memset(&ifr, 0, sizeof(ifr));
|
||||||
|
+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1);
|
||||||
|
if (ioctl(skfd, SIOCGIFMETRIC, &ifr) < 0) {
|
||||||
|
metric = 0;
|
||||||
|
} else
|
||||||
|
metric = ifr.ifr_metric;
|
||||||
|
printf("The result of SIOCGIFMETRIC is %d\n", metric);
|
||||||
|
|
||||||
|
- strcpy(ifr.ifr_name, ifname);
|
||||||
|
+ memset(&ifr, 0, sizeof(ifr));
|
||||||
|
+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1);
|
||||||
|
if (ioctl(skfd, SIOCGIFMTU, &ifr) < 0)
|
||||||
|
mtu = 0;
|
||||||
|
else
|
||||||
|
mtu = ifr.ifr_mtu;
|
||||||
|
printf("The result of SIOCGIFMTU is %d\n", mtu);
|
||||||
|
|
||||||
|
- strcpy(ifr.ifr_name, ifname);
|
||||||
|
+ memset(&ifr, 0, sizeof(ifr));
|
||||||
|
+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1);
|
||||||
|
if (ioctl(skfd, SIOCGIFDSTADDR, &ifr) < 0) {
|
||||||
|
memset(&dstaddr, 0, sizeof(struct sockaddr));
|
||||||
|
} else
|
||||||
|
dstaddr = ifr.ifr_dstaddr;
|
||||||
|
|
||||||
|
- strcpy(ifr.ifr_name, ifname);
|
||||||
|
+ memset(&ifr, 0, sizeof(ifr));
|
||||||
|
+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1);
|
||||||
|
if (ioctl(skfd, SIOCGIFBRDADDR, &ifr) < 0) {
|
||||||
|
memset(&broadaddr, 0, sizeof(struct sockaddr));
|
||||||
|
} else
|
||||||
|
broadaddr = ifr.ifr_broadaddr;
|
||||||
|
|
||||||
|
- strcpy(ifr.ifr_name, ifname);
|
||||||
|
+ memset(&ifr, 0, sizeof(ifr));
|
||||||
|
+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1);
|
||||||
|
if (ioctl(skfd, SIOCGIFNETMASK, &ifr) < 0) {
|
||||||
|
memset(&netmask, 0, sizeof(struct sockaddr));
|
||||||
|
} else
|
||||||
|
--
|
||||||
|
2.29.2
|
||||||
|
|
@ -0,0 +1,154 @@
|
|||||||
|
From bea19fd9a86dd2c601681ff2ef4a9c1afab1e34d Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jan Macku <jamacku@redhat.com>
|
||||||
|
Date: Tue, 8 Jun 2021 15:41:58 +0200
|
||||||
|
Subject: [PATCH] ifenslave: fix CWE-170: Improper Null Termination
|
||||||
|
|
||||||
|
Resolves: #1938746
|
||||||
|
---
|
||||||
|
ifenslave.c | 43 +++++++++++++++++++++++++++----------------
|
||||||
|
1 file changed, 27 insertions(+), 16 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/ifenslave.c b/ifenslave.c
|
||||||
|
index 1efe4f1..59bce4c 100644
|
||||||
|
--- a/ifenslave.c
|
||||||
|
+++ b/ifenslave.c
|
||||||
|
@@ -619,7 +619,7 @@ static int get_drv_info(char *master_ifname)
|
||||||
|
char *endptr;
|
||||||
|
|
||||||
|
memset(&ifr, 0, sizeof(ifr));
|
||||||
|
- strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ);
|
||||||
|
+ strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ - 1);
|
||||||
|
ifr.ifr_data = (caddr_t)&info;
|
||||||
|
|
||||||
|
info.cmd = ETHTOOL_GDRVINFO;
|
||||||
|
@@ -664,8 +664,9 @@ static int change_active(char *master_ifname, char *slave_ifname)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
- strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ);
|
||||||
|
- strncpy(ifr.ifr_slave, slave_ifname, IFNAMSIZ);
|
||||||
|
+ memset(&ifr, 0, sizeof(ifr));
|
||||||
|
+ strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ - 1);
|
||||||
|
+ strncpy(ifr.ifr_slave, slave_ifname, IFNAMSIZ - 1);
|
||||||
|
if ((ioctl(skfd, SIOCBONDCHANGEACTIVE, &ifr) < 0) &&
|
||||||
|
(ioctl(skfd, BOND_CHANGE_ACTIVE_OLD, &ifr) < 0)) {
|
||||||
|
saved_errno = errno;
|
||||||
|
@@ -806,8 +807,9 @@ static int enslave(char *master_ifname, char *slave_ifname)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Do the real thing */
|
||||||
|
- strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ);
|
||||||
|
- strncpy(ifr.ifr_slave, slave_ifname, IFNAMSIZ);
|
||||||
|
+ memset(&ifr, 0, sizeof(ifr));
|
||||||
|
+ strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ - 1);
|
||||||
|
+ strncpy(ifr.ifr_slave, slave_ifname, IFNAMSIZ - 1);
|
||||||
|
if ((ioctl(skfd, SIOCBONDENSLAVE, &ifr) < 0) &&
|
||||||
|
(ioctl(skfd, BOND_ENSLAVE_OLD, &ifr) < 0)) {
|
||||||
|
saved_errno = errno;
|
||||||
|
@@ -847,8 +849,9 @@ static int release(char *master_ifname, char *slave_ifname)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
- strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ);
|
||||||
|
- strncpy(ifr.ifr_slave, slave_ifname, IFNAMSIZ);
|
||||||
|
+ memset(&ifr, 0, sizeof(ifr));
|
||||||
|
+ strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ - 1);
|
||||||
|
+ strncpy(ifr.ifr_slave, slave_ifname, IFNAMSIZ - 1);
|
||||||
|
if ((ioctl(skfd, SIOCBONDRELEASE, &ifr) < 0) &&
|
||||||
|
(ioctl(skfd, BOND_RELEASE_OLD, &ifr) < 0)) {
|
||||||
|
saved_errno = errno;
|
||||||
|
@@ -880,7 +883,8 @@ static int get_if_settings(char *ifname, struct dev_ifr ifra[])
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
|
for (i = 0; ifra[i].req_ifr; i++) {
|
||||||
|
- strncpy(ifra[i].req_ifr->ifr_name, ifname, IFNAMSIZ);
|
||||||
|
+ strncpy(ifra[i].req_ifr->ifr_name, ifname, IFNAMSIZ - 1);
|
||||||
|
+ ifra[i].req_ifr->ifr_name[IFNAMSIZ - 1] = '\0';
|
||||||
|
res = ioctl(skfd, ifra[i].req_type, ifra[i].req_ifr);
|
||||||
|
if (res < 0) {
|
||||||
|
saved_errno = errno;
|
||||||
|
@@ -899,7 +903,8 @@ static int get_slave_flags(char *slave_ifname)
|
||||||
|
{
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
|
- strncpy(slave_flags.ifr_name, slave_ifname, IFNAMSIZ);
|
||||||
|
+ strncpy(slave_flags.ifr_name, slave_ifname, IFNAMSIZ - 1);
|
||||||
|
+ slave_flags.ifr_name[IFNAMSIZ - 1] = '\0';
|
||||||
|
res = ioctl(skfd, SIOCGIFFLAGS, &slave_flags);
|
||||||
|
if (res < 0) {
|
||||||
|
saved_errno = errno;
|
||||||
|
@@ -919,7 +924,8 @@ static int set_master_hwaddr(char *master_ifname, struct sockaddr *hwaddr)
|
||||||
|
struct ifreq ifr;
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
|
- strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ);
|
||||||
|
+ memset(&ifr, 0, sizeof(ifr));
|
||||||
|
+ strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ - 1);
|
||||||
|
memcpy(&(ifr.ifr_hwaddr), hwaddr, sizeof(struct sockaddr));
|
||||||
|
res = ioctl(skfd, SIOCSIFHWADDR, &ifr);
|
||||||
|
if (res < 0) {
|
||||||
|
@@ -943,7 +949,8 @@ static int set_slave_hwaddr(char *slave_ifname, struct sockaddr *hwaddr)
|
||||||
|
struct ifreq ifr;
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
|
- strncpy(ifr.ifr_name, slave_ifname, IFNAMSIZ);
|
||||||
|
+ memset(&ifr, 0, sizeof(ifr));
|
||||||
|
+ strncpy(ifr.ifr_name, slave_ifname, IFNAMSIZ - 1);
|
||||||
|
memcpy(&(ifr.ifr_hwaddr), hwaddr, sizeof(struct sockaddr));
|
||||||
|
res = ioctl(skfd, SIOCSIFHWADDR, &ifr);
|
||||||
|
if (res < 0) {
|
||||||
|
@@ -980,8 +987,9 @@ static int set_slave_mtu(char *slave_ifname, int mtu)
|
||||||
|
struct ifreq ifr;
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
|
+ memset(&ifr, 0, sizeof(ifr));
|
||||||
|
ifr.ifr_mtu = mtu;
|
||||||
|
- strncpy(ifr.ifr_name, slave_ifname, IFNAMSIZ);
|
||||||
|
+ strncpy(ifr.ifr_name, slave_ifname, IFNAMSIZ - 1);
|
||||||
|
|
||||||
|
res = ioctl(skfd, SIOCSIFMTU, &ifr);
|
||||||
|
if (res < 0) {
|
||||||
|
@@ -1000,8 +1008,9 @@ static int set_if_flags(char *ifname, short flags)
|
||||||
|
struct ifreq ifr;
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
|
+ memset(&ifr, 0, sizeof(ifr));
|
||||||
|
ifr.ifr_flags = flags;
|
||||||
|
- strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
|
||||||
|
+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1);
|
||||||
|
|
||||||
|
res = ioctl(skfd, SIOCSIFFLAGS, &ifr);
|
||||||
|
if (res < 0) {
|
||||||
|
@@ -1030,7 +1039,8 @@ static int clear_if_addr(char *ifname)
|
||||||
|
struct ifreq ifr;
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
|
- strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
|
||||||
|
+ memset(&ifr, 0, sizeof(ifr));
|
||||||
|
+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1);
|
||||||
|
ifr.ifr_addr.sa_family = AF_INET;
|
||||||
|
memset(ifr.ifr_addr.sa_data, 0, sizeof(ifr.ifr_addr.sa_data));
|
||||||
|
|
||||||
|
@@ -1065,8 +1075,9 @@ static int set_if_addr(char *master_ifname, char *slave_ifname)
|
||||||
|
{NULL, NULL, 0, 0},
|
||||||
|
};
|
||||||
|
|
||||||
|
+ memset(&ifr, 0, sizeof(ifr));
|
||||||
|
for (i = 0; ifra[i].req_name; i++) {
|
||||||
|
- strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ);
|
||||||
|
+ strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ - 1);
|
||||||
|
res = ioctl(skfd, ifra[i].g_ioctl, &ifr);
|
||||||
|
if (res < 0) {
|
||||||
|
int saved_errno = errno;
|
||||||
|
@@ -1080,7 +1091,7 @@ static int set_if_addr(char *master_ifname, char *slave_ifname)
|
||||||
|
sizeof(ifr.ifr_addr.sa_data));
|
||||||
|
}
|
||||||
|
|
||||||
|
- strncpy(ifr.ifr_name, slave_ifname, IFNAMSIZ);
|
||||||
|
+ strncpy(ifr.ifr_name, slave_ifname, IFNAMSIZ - 1);
|
||||||
|
res = ioctl(skfd, ifra[i].s_ioctl, &ifr);
|
||||||
|
if (res < 0) {
|
||||||
|
int saved_errno = errno;
|
||||||
|
--
|
||||||
|
2.31.1
|
||||||
|
|
Loading…
Reference in new issue