Netdev List
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: netdev@vger.kernel.org
Cc: dsahern@kernel.org, Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH net v3 0/3] rtnetlink: fix truncation of dump entry
Date: Tue, 17 Nov 2026 14:13:41 -0800	[thread overview]
Message-ID: <20261117221538.184948-1-stephen@networkplumber.org> (raw)

While going through an OSS Scanner dump report for iproute2, I found a
bug in the netlink route dump.

If the first entry of a route dump is too big for the dump skb, the dump
ends with NLMSG_DONE and status 0. That route, and everything after it,
is quietly dropped: "ip route show table 100" prints nothing and exits 0.
It takes something well outside normal use to get there, such as a 500
way multipath route.

Two separate paths get it wrong, so there are two fixes.

Patch 1 covers the generic RTNL_FLAG_DUMP_SPLIT_NLM_DONE path in
rtnl_dumpit(), which drops -EMSGSIZE and returns skb->len. On an empty
skb that is 0. This is the IPv4 FIB case.

Patch 2 covers inet6_dump_fib(), which doesn't use -EMSGSIZE at all; it
suspends the walker and returns a positive value. That one goes back
further, to when IPv6 multipath routes started being dumped as a single
RTA_MULTIPATH message. It has to come after patch 1, since it relies on
rtnl_dumpit() no longer swallowing the error.

Patch 3 adds a selftest: IPv4 and IPv6 multipath routes wide enough to
miss the first dump skb of a fresh socket. The dump has to either return
the route or fail with -EMSGSIZE.

v3 - move to net-next and resolve conflicts
     incorporate Sashiko suggestions
v2 - drop Assisted-by
   - correct commit message about "ip route get"

Stephen Hemminger (3):
  rtnetlink: return EMSGSIZE when first dump entry does not fit
  ipv6: return EMSGSIZE when first route in dump does not fit
  selftests: net: netlink-dumps: test dump of route larger than skb

 net/core/rtnetlink.c                        |   5 +-
 net/ipv6/ip6_fib.c                          |   6 +
 tools/testing/selftests/net/config          |   3 +
 tools/testing/selftests/net/netlink-dumps.c | 297 +++++++++++++++++++++++++++-
 4 files changed, 306 insertions(+), 5 deletions(-)

-- 
2.53.0

Stephen Hemminger (3):
  rtnetlink: return EMSGSIZE when first dump entry does not fit
  ipv6: return EMSGSIZE when first route in dump does not fit
  selftests: net: netlink-dumps: test dump of route larger than skb

 net/core/rtnetlink.c                        |   5 +-
 net/ipv6/ip6_fib.c                          |   4 +
 tools/testing/selftests/net/config          |   3 +
 tools/testing/selftests/net/netlink-dumps.c | 297 +++++++++++++++++++-
 4 files changed, 304 insertions(+), 5 deletions(-)

-- 
2.53.0


             reply	other threads:[~2026-11-17 22:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 22:13 Stephen Hemminger [this message]
2026-11-17 22:13 ` [PATCH net-next v3 1/3] rtnetlink: return EMSGSIZE when first dump entry does not fit Stephen Hemminger
2026-11-17 22:13 ` [PATCH net-next v3 2/3] ipv6: return EMSGSIZE when first route in dump " Stephen Hemminger
2026-11-17 22:13 ` [PATCH net-next v3 3/3] selftests: net: netlink-dumps: test dump of route larger than skb Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261117221538.184948-1-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dsahern@kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox