sst-linux/net
Ido Schimmel 7a850dd2de ipv4: Fix incorrect TOS in fibmatch route get reply
[ Upstream commit f036e68212c11e5a7edbb59b5e25299341829485 ]

The TOS value that is returned to user space in the route get reply is
the one with which the lookup was performed ('fl4->flowi4_tos'). This is
fine when the matched route is configured with a TOS as it would not
match if its TOS value did not match the one with which the lookup was
performed.

However, matching on TOS is only performed when the route's TOS is not
zero. It is therefore possible to have the kernel incorrectly return a
non-zero TOS:

 # ip link add name dummy1 up type dummy
 # ip address add 192.0.2.1/24 dev dummy1
 # ip route get fibmatch 192.0.2.2 tos 0xfc
 192.0.2.0/24 tos 0x1c dev dummy1 proto kernel scope link src 192.0.2.1

Fix by instead returning the DSCP field from the FIB result structure
which was populated during the route lookup.

Output after the patch:

 # ip link add name dummy1 up type dummy
 # ip address add 192.0.2.1/24 dev dummy1
 # ip route get fibmatch 192.0.2.2 tos 0xfc
 192.0.2.0/24 dev dummy1 proto kernel scope link src 192.0.2.1

Extend the existing selftests to not only verify that the correct route
is returned, but that it is also returned with correct "tos" value (or
without it).

Fixes: b61798130f ("net: ipv4: RTM_GETROUTE: return matched fib result when requested")
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Reviewed-by: Guillaume Nault <gnault@redhat.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-08-03 08:49:24 +02:00
..
6lowpan
9p net/9p: fix uninit-value in p9_client_rpc() 2024-06-16 13:41:38 +02:00
802
8021q
appletalk
atm
ax25 ax25: Replace kfree() in ax25_dev_free() with ax25_dev_put() 2024-06-21 14:35:32 +02:00
batman-adv batman-adv: Don't accept TT entries for out-of-spec VIDs 2024-07-05 09:31:58 +02:00
bluetooth Bluetooth: L2CAP: Fix deadlock 2024-07-25 09:49:20 +02:00
bpf bpf: Set run context for rawtp test_run callback 2024-06-21 14:35:33 +02:00
bpfilter
bridge net: bridge: mst: Check vlan state for egress decision 2024-08-03 08:49:09 +02:00
caif
can net: can: j1939: enhanced error handling for tightly received RTS messages in xtp_rx_rts_session_new 2024-07-05 09:31:56 +02:00
ceph libceph: fix race between delayed_work() and ceph_monc_stop() 2024-07-18 13:18:41 +02:00
core net: flow_dissector: use DEBUG_NET_WARN_ON_ONCE 2024-08-03 08:49:24 +02:00
dcb
dccp Fix race for duplicate reqsk on identical SYN 2024-07-05 09:31:46 +02:00
devlink
dns_resolver
dsa
ethernet
ethtool ethtool: netlink: do not return SQI value if link is down 2024-07-18 13:18:35 +02:00
hsr hsr: Simplify code for announcing HSR nodes timer setup 2024-05-17 11:56:13 +02:00
ieee802154
ife
ipv4 ipv4: Fix incorrect TOS in fibmatch route get reply 2024-08-03 08:49:24 +02:00
ipv6 tcp: fix races in tcp_v[46]_err() 2024-08-03 08:49:04 +02:00
iucv net/iucv: Avoid explicit cpumask var allocation on stack 2024-07-05 09:31:49 +02:00
kcm
key
l2tp
l3mdev
lapb
llc
mac80211 wifi: mac80211: disable softirqs for queued frame handling 2024-07-25 09:49:20 +02:00
mac802154 net: mac802154: Fix racy device stats updates by DEV_STATS_INC() and DEV_STATS_ADD() 2024-07-25 09:49:17 +02:00
mctp
mpls
mptcp mptcp: pm: update add_addr counters after connect 2024-06-21 14:35:59 +02:00
ncsi net/ncsi: Fix the multi thread manner of NCSI driver 2024-06-21 14:35:33 +02:00
netfilter netfilter: nf_set_pipapo: fix initial map fill 2024-08-03 08:49:24 +02:00
netlabel
netlink
netrom netrom: Fix a memory leak in nr_heartbeat_expiry() 2024-06-27 13:46:18 +02:00
nfc nfc: nci: Fix handling of zero-length payload packets in nci_rx_work() 2024-06-12 11:03:53 +02:00
nsh
openvswitch openvswitch: Set the skbuff pkt_type for proper pmtud support. 2024-06-12 11:03:51 +02:00
packet af_packet: avoid a false positive warning in packet_setsockopt() 2024-06-27 13:46:15 +02:00
phonet
psample
qrtr net: qrtr: ns: Fix module refcnt 2024-06-12 11:03:32 +02:00
rds
rfkill
rose
rxrpc
sched net/sched: Fix UAF when resolving a clash 2024-07-18 13:18:35 +02:00
sctp sctp: prefer struct_size over open coded arithmetic 2024-07-11 12:47:07 +02:00
smc net/smc: set rmb's SG_MAX_SINGLE_ALLOC limitation only when CONFIG_ARCH_NO_SG_CHAIN is defined 2024-08-03 08:49:04 +02:00
strparser
sunrpc SUNRPC: avoid soft lockup when transmitting UDP to reachable server. 2024-08-03 08:49:15 +02:00
switchdev
tipc tipc: force a dst refcount before doing decryption 2024-06-27 13:46:19 +02:00
tls tls: fix missing memory barrier in tls_init 2024-06-12 11:03:53 +02:00
unix af_unix: Read with MSG_PEEK loops if the first unread byte is OOB 2024-06-21 14:35:53 +02:00
vmw_vsock
wireless wifi: cfg80211: handle 2x996 RU allocation in cfg80211_calculate_bitrate_he() 2024-08-03 08:49:06 +02:00
x25
xdp
xfrm net: fix __dst_negative_advice() race 2024-06-16 13:41:40 +02:00
compat.c
devres.c
Kconfig
Kconfig.debug
Makefile
socket.c
sysctl_net.c