ipmr, ip6mr: queue netlink route queries out of band
Subsystems (3)
Eric Dumazet
maintainerPATCH 1/1 ipmr, ip6mr: queue netlink route queries out of band
ipmr_get_route() and ip6mr_get_route() queue synthetic skbs on the unresolved MFC entry to answer RTM_GETROUTE requests once the route is resolved. These skbs carry a fake IP header with version 0, and ipmr_cache_resolve(), ipmr_destroy_unres(), ip6mr_cache_resolve() and ip6mr_destroy_unres() rely on this in-band tag to tell them apart from regular packets queued by the input and output paths.
The IP version is only validated once, in ip_rcv_core() and ip6_rcv_core(). A netfilter hook running later, for instance an nftables payload statement in a PREROUTING chain owned by an unprivileged user namespace, can rewrite the first header byte to zero. The SRv6 End.DX6 action also passes the decapsulated packet to ip6_mr_input() without checking that the inner header version is 6. If no MFC entry exists, the packet is queued and later handled as a netlink request: its payload is treated as an nlmsghdr and written to, mr_fill_mroute() may call skb_put() on a nonlinear skb (hitting SKB_LINEAR_ASSERT()), and the skb is unicast to a netlink portid taken from stale IPCB/IP6CB bytes in skb->cb[].
ipmr_cache_report() also relies on the same tag since commit 94a6736bb5ab ("ipmr: only copy pktinfo to cache reports").
Stop trusting packet contents: queue route queries on a dedicated nl_queries list in the unresolved MFC entry, and pass an explicit nl_query flag from the callers.
The per-entry limit of four queued skbs now applies to both lists combined, as before. The synthetic header keeps version 0, since it is copied into the NOCACHE report delivered to the mroute socket.
--- include/linux/mroute_base.h | 2 + net/ipv4/ipmr.c | 104 +++++++++++++++++++----------------- net/ipv6/ip6mr.c | 76 +++++++++++++------------- 3 files changed, 94 insertions(+), 88 deletions(-)
include/linux/mroute_base.h +2 -0
@@ -119,6 +119,7 @@ enum {* @mfc_flags: entry flags * @expires: unresolved entry expire time * @unresolved: unresolved cached skbs +* @nl_queries: queued RTM_GETROUTE requests waiting for resolution * @last_assert: time of last assert * @minvif: minimum VIF id * @maxvif: maximum VIF id
@@ -141,6 +142,7 @@ struct mr_mfc {struct {unsigned long expires;struct sk_buff_head unresolved; +struct sk_buff_head nl_queries; } unres;struct {unsigned long last_assert;
net/ipv4/ipmr.c +54 -50
208 lines not on this page · raw message
net/ipv6/ip6mr.c +38 -38
135 lines not on this page · raw message
Signature · 1 line
2.53.0
[email protected]
AI reviewThis is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
Hi!
This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical (e.g. found by code inspection). If it was triggered please include the symptoms, like the stack trace or error messages.
Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. If the series needs another revision for other reasons, please include the information in the commit messages then.
The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
Quoted 7 lines · Eric Dumazet
ipmr_get_route()andip6mr_get_route()queue synthetic skbs on the unresolved MFC entry to answerRTM_GETROUTErequests once the route is resolved. These skbs carry a fake IP header with version 0, andipmr_cache_resolve(),ipmr_destroy_unres(),ip6mr_cache_resolve()andip6mr_destroy_unres()rely on this in-band tag to tell them apart from regular packets queued by the input and output paths.
Quoted 11 lines
The IP version is only validated once, in
ip_rcv_core()andip6_rcv_core(). A netfilter hook running later, for instance an nftables payload statement in a PREROUTING chain owned by an unprivileged user namespace, can rewrite the first header byte to zero. The SRv6 End.DX6 action also passes the decapsulated packet toip6_mr_input()without checking that the inner header version is 6. If no MFC entry exists, the packet is queued and later handled as a netlink request: its payload is treated as an nlmsghdr and written to,mr_fill_mroute()may callskb_put()on a nonlinear skb (hittingSKB_LINEAR_ASSERT()), and the skb is unicast to a netlink portid taken from stale IPCB/IP6CB bytes in skb->cb[].
FWIW, unprivileged users cannot mangle the IP version using nftables since commit 968cc2c96390 ("netfilter: disable payload mangling in userns") in v7.1.
Quoted 8 lines
ipmr_cache_report()also relies on the same tag since commit94a6736bb5ab("ipmr: only copy pktinfo to cache reports").Stop trusting packet contents: queue route queries on a dedicated
nl_querieslist in the unresolved MFC entry, and pass an explicitnl_queryflag from the callers.
Quoted 8 lines
The per-entry limit of four queued skbs now applies to both lists combined, as before. The synthetic header keeps version 0, since it is copied into the NOCACHE report delivered to the mroute socket.
Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")Fixes 7bc570c8b4f7 ("[IPV6] MROUTE: Support multicast forwarding.")Reported-by Katherine Leaver <[email protected]>Signed-off-by Eric Dumazet <[email protected]>
Thanks for taking care of that!
Paolo Abeni
maintainerQuoted 45 lines · Eric Dumazet
ipmr_get_route()andip6mr_get_route()queue synthetic skbs on the unresolved MFC entry to answerRTM_GETROUTErequests once the route is resolved. These skbs carry a fake IP header with version 0, andipmr_cache_resolve(),ipmr_destroy_unres(),ip6mr_cache_resolve()andip6mr_destroy_unres()rely on this in-band tag to tell them apart from regular packets queued by the input and output paths.The IP version is only validated once, in
ip_rcv_core()andip6_rcv_core(). A netfilter hook running later, for instance an nftables payload statement in a PREROUTING chain owned by an unprivileged user namespace, can rewrite the first header byte to zero. The SRv6 End.DX6 action also passes the decapsulated packet toip6_mr_input()without checking that the inner header version is 6. If no MFC entry exists, the packet is queued and later handled as a netlink request: its payload is treated as an nlmsghdr and written to,mr_fill_mroute()may callskb_put()on a nonlinear skb (hittingSKB_LINEAR_ASSERT()), and the skb is unicast to a netlink portid taken from stale IPCB/IP6CB bytes in skb->cb[].
ipmr_cache_report()also relies on the same tag since commit94a6736bb5ab("ipmr: only copy pktinfo to cache reports").Stop trusting packet contents: queue route queries on a dedicated
nl_querieslist in the unresolved MFC entry, and pass an explicitnl_queryflag from the callers.The per-entry limit of four queued skbs now applies to both lists combined, as before. The synthetic header keeps version 0, since it is copied into the NOCACHE report delivered to the mroute socket.
Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")Fixes 7bc570c8b4f7 ("[IPV6] MROUTE: Support multicast forwarding.")Reported-by Katherine Leaver <[email protected]>Signed-off-by Eric Dumazet <[email protected]>--- include/linux/mroute_base.h | 2 + net/ipv4/ipmr.c | 104 +++++++++++++++++++----------------- net/ipv6/ip6mr.c | 76 +++++++++++++------------- 3 files changed, 94 insertions(+), 88 deletions(-)include/linux/mroute_base.h +0
-0
include/linux/mroute_base.h enum { · line 122
Quoted 4 lines
include/linux/mroute_base.h +1
-0@@ -119,6 +119,7 @@ enum {* @mfc_flags: entry flags * @expires: unresolved entry expire time * @unresolved: unresolved cached skbs +* @nl_queries: queued RTM_GETROUTE requests waiting for resolution
FTR: the above causes kdoc warning, but fixing it would be so ugly:
* @mfc_un.unres.nl_queries: ...
I really think we are better of this way.
/P
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:
Quoted 8 lines · On Fri, 30 Oct 2026 10:23:03 +0100 you wrote:
ipmr_get_route()andip6mr_get_route()queue synthetic skbs on the unresolved MFC entry to answerRTM_GETROUTErequests once the route is resolved. These skbs carry a fake IP header with version 0, andipmr_cache_resolve(),ipmr_destroy_unres(),ip6mr_cache_resolve()andip6mr_destroy_unres()rely on this in-band tag to tell them apart from regular packets queued by the input and output paths.[...]
Here is the summary with links:
- [net] ipmr, ip6mr: queue netlink route queries out of band
https://git.kernel.org/netdev/net/c/787268686c64
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html