]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ipv4: Fix fib_nlmsg_size() for RTA_VIA nexthops
authorZihan Xi <zihanx@nebusec.ai>
Thu, 30 Jul 2026 12:59:26 +0000 (12:59 +0000)
committerJakub Kicinski <kuba@kernel.org>
Tue, 4 Aug 2026 01:29:50 +0000 (18:29 -0700)
commit4ff9548d84945d2cbf9e4c207288063a200ea397
tree4c2dbc386793b7326a1c7bca24d948b307265b5b
parent5d9686af2976741bbd79b150d1c9e60b81e7f12e
ipv4: Fix fib_nlmsg_size() for RTA_VIA nexthops

fib_nlmsg_size() still estimates nexthop space as if every gateway is
encoded as an IPv4 RTA_GATEWAY attribute. IPv4 routes can also carry an
IPv6 gateway, which fib_nexthop_info() dumps as RTA_VIA.

As a result, route notifications can allocate an skb that is too small.
fib_dump_info() then fails with -EMSGSIZE and rtmsg_fib() hits the
WARN_ON() that marks such failures as a fib_nlmsg_size() bug. With
panic_on_warn set, this becomes a kernel panic.

Mirror the actual nexthop dump layout in fib_nlmsg_size(): account for
IPv6 nexthop gateways dumped as RTA_VIA, for the no-header rtnexthop
layout used inside RTA_MULTIPATH, and for RTA_FLOW only when it is
actually present.

Fixes: d15662682db2 ("ipv4: Allow ipv6 gateway with ipv4 routes")
Cc: stable@vger.kernel.org
Reported-by: Vega <vega@nebusec.ai>
Signed-off-by: Zihan Xi <zihanx@nebusec.ai>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/6f53fa797fcaeb26966432ed7ae9bb87c4961f37.1785411220.git.zihanx@nebusec.ai
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/ipv4/fib_semantics.c