Netdev List
 help / color / mirror / Atom feed
From: Ido Schimmel <idosch@nvidia.com>
To: luoqing <l1138897701@163.com>
Cc: dsahern@kernel.org, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] net/ipv4: fix NULL pointer deref in nh_valid_get_del_req()
Date: Mon, 27 Jul 2026 10:22:15 +0300	[thread overview]
Message-ID: <20260727072215.GA458701@shredder> (raw)
In-Reply-To: <20260727022619.198914-1-l1138897701@163.com>

On Mon, Jul 27, 2026 at 10:26:19AM +0800, luoqing wrote:
> From: Qing Luo <luoqing@kylinos.cn>
> 
> rtm_del_nexthop() and nh_valid_get_bucket_req() declare their nlattr
> tb arrays sized to ARRAY_SIZE(rtm_nh_policy_del) and
> ARRAY_SIZE(rtm_nh_policy_get_bucket) respectively.  Both policies lack
> an entry for NHA_OP_FLAGS, so the tb arrays are smaller than what
> nh_valid_get_del_req() accesses via tb[NHA_OP_FLAGS].

But nh_valid_get_del_req() only accesses tb[NHA_OP_FLAGS] when
'op_flags' is not NULL and both rtm_del_nexthop() and
nh_valid_get_bucket_req() pass NULL, so I don't see how this bug can
happen?

> 
> This causes an out-of-bounds stack read.  The garbage pointer value
> read from beyond the tb array is then dereferenced in nla_get_u32(),
> triggering a NULL pointer dereference panic.
> 
> The bug was introduced when commit 8682b7dd4f6c ("nexthop: Fix

This hash doesn't exist and it differs from the one below.

> out-of-bounds access during attribute validation") shrank the tb
> arrays from NHA_MAX+1 to ARRAY_SIZE(policy), but the policies were
> not updated to include NHA_OP_FLAGS even though nh_valid_get_del_req()
> already accessed that attribute.
> 
> Add [NHA_OP_FLAGS] entries to rtm_nh_policy_del and
> rtm_nh_policy_get_bucket so the tb arrays are large enough.
> 
> [  647.535111] BUG: kernel NULL pointer dereference, address: 000000000000000a
> [  647.542066] #PF: supervisor read access in kernel mode
> [  647.547197] #PF: error_code(0x0000) - not-present page
> [  647.559218] CPU: 0 PID: 42929 Comm: ip Not tainted 6.6.144 #1

6.6.144 doesn't even support NHA_OP_FLAGS and doesn't have
rtm_nh_policy_del. Can you reproduce the bug with net.git?

> [  647.579548] RIP: 0010:nh_valid_get_del_req+0x38/0xc0
> [  647.998839] Kernel panic - not syncing: Fatal exception
> 
> Fixes: d8a21070b6e1 ("nexthop: Fix out-of-bounds access during attribute validation")
> Signed-off-by: Qing Luo <luoqing@kylinos.cn>

      reply	other threads:[~2026-07-27  7:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-27  2:26 [PATCH net] net/ipv4: fix NULL pointer deref in nh_valid_get_del_req() luoqing
2026-07-27  7:22 ` Ido Schimmel [this message]

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=20260727072215.GA458701@shredder \
    --to=idosch@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=l1138897701@163.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /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