The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: David Ahern <dsahern@gmail.com>
To: Weiming Shi <bestswngs@gmail.com>,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, horms@kernel.org
Cc: kuniyu@google.com, gnault@redhat.com, xmei5@asu.edu,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] mpls: fix NULL deref in mpls_valid_fib_dump_req() on CONFIG_INET=n
Date: Sat, 11 Jul 2026 10:56:42 -0600	[thread overview]
Message-ID: <5cf2d4ee-376f-4baa-baf1-fd7bf7500251@gmail.com> (raw)
In-Reply-To: <20260711114958.1009619-3-bestswngs@gmail.com>

On 7/11/26 5:50 AM, Weiming Shi wrote:
> On CONFIG_INET=n builds, mpls_valid_fib_dump_req() walks the parsed
> attribute table itself instead of calling ip_valid_fib_dump_req(). The
> RTA_OIF arm passes tb[RTA_OIF] to nla_get_u32() without checking it is
> present, so an RTM_GETROUTE dump for AF_MPLS with strict checking and no
> RTA_OIF hits a NULL dereference.
> 
> RTM_GETROUTE is RTNL_KIND_GET, which rtnetlink_rcv_msg() permits without
> CAP_NET_ADMIN, so an unprivileged user can trigger it.
> 
>   Oops: general protection fault, probably for non-canonical address
>         0xdffffc0000000000: 0000 [#1] SMP KASAN NOPTI
>   KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]
>   RIP: 0010:mpls_valid_fib_dump_req (net/mpls/af_mpls.c:2189)
>   Call Trace:
>    mpls_dump_routes (net/mpls/af_mpls.c:2236)
>    netlink_dump (net/netlink/af_netlink.c:2331)
>    __netlink_dump_start (net/netlink/af_netlink.c:2446)
>    rtnetlink_rcv_msg (net/core/rtnetlink.c:7033)
>    netlink_rcv_skb (net/netlink/af_netlink.c:2556)
>    netlink_unicast (net/netlink/af_netlink.c:1345)
>    netlink_sendmsg (net/netlink/af_netlink.c:1900)
>    __sock_sendmsg (net/socket.c:790)
>    ____sys_sendmsg (net/socket.c:2684)
>    ___sys_sendmsg (net/socket.c:2738)
>    __sys_sendmsg (net/socket.c:2770)
>    do_syscall_64 (arch/x86/entry/syscall_64.c:94)
>    entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121)
> 
> Skip unset attributes, as ip_valid_fib_dump_req() does.
> 
> Fixes: 196cfebf8972 ("net/mpls: Handle kernel side filtering of route dumps")
> Assisted-by: Claude:claude-opus-4-8
> Reported-by: Xiang Mei <xmei5@asu.edu>
> Signed-off-by: Weiming Shi <bestswngs@gmail.com>
> ---
>  net/mpls/af_mpls.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
> index ca504d9626cf..318cb7e2ac5f 100644
> --- a/net/mpls/af_mpls.c
> +++ b/net/mpls/af_mpls.c
> @@ -2186,6 +2186,9 @@ static int mpls_valid_fib_dump_req(struct net *net, const struct nlmsghdr *nlh,
>  		int ifindex;
>  
>  		if (i == RTA_OIF) {
> +			if (!tb[i])
> +				continue;
> +
>  			ifindex = nla_get_u32(tb[i]);
>  			filter->dev = dev_get_by_index_rcu(net, ifindex);
>  			if (!filter->dev)

Reviewed-by: David Ahern <dsahern@kernel.org>


  reply	other threads:[~2026-07-11 16:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-11 11:50 [PATCH net] mpls: fix NULL deref in mpls_valid_fib_dump_req() on CONFIG_INET=n Weiming Shi
2026-07-11 16:56 ` David Ahern [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-07-12 22:09 Xiang Mei

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=5cf2d4ee-376f-4baa-baf1-fd7bf7500251@gmail.com \
    --to=dsahern@gmail.com \
    --cc=bestswngs@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gnault@redhat.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=xmei5@asu.edu \
    /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