mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox.net>
To: Khawar Ahemad <ahemadkhawar123@gmail.com>,
	bpf@vger.kernel.org, netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, magnus.karlsson@intel.com,
	maciej.fijalkowski@intel.com, sdf@fomichev.me, ast@kernel.org,
	kuba@kernel.org, pabeni@redhat.com,
	syzbot+aa48b5fe7bfda62d1682@syzkaller.appspotmail.com
Subject: Re: [PATCH bpf-next] xsk: Fix circular locking dependency in xsk_bind
Date: Tue, 25 Aug 2026 17:39:28 +0200	[thread overview]
Message-ID: <46035122-87f6-449f-aa71-a8e9e99dc006@iogearbox.net> (raw)
In-Reply-To: <20260825152152.86092-1-ahemadkhawar123@gmail.com>

On 8/25/26 5:21 PM, Khawar Ahemad wrote:
> syzbot reported a circular locking dependency involving &net->xdp.lock,
> &xs->mutex, and netdev_lock_ops():
> 
> -> #3 (&net->xdp.lock):
>         xsk_notifier
>         unregister_netdevice_many_notify
>         rtnl_dellink
> 
> -> #2 (&port->pnodes_lock / netdev_lock):
>         ipvlan_device_event / bond / netdev_change_features
> 
> -> #1 (netdev_lock_ops):
>         xsk_bind (holds xs->mutex, takes netdev_lock_ops(dev))
> 
> -> #0 (&xs->mutex):
>         xsk_diag_dump (holds net->xdp.lock, takes xs->mutex)
> 
> In xsk_bind(), xs->mutex was acquired before dev_get_by_index() and
> netdev_lock_ops(dev). However, in netdev notifier callbacks like
> xsk_notifier(), netdev_lock_ops(dev) is held by the netdev core while
> taking net->xdp.lock and then xs->mutex, creating an ABBA lock
> inversion between xs->mutex and netdev_lock_ops(dev).
> 
> Fix this by looking up the target net_device and acquiring
> netdev_lock_ops(dev) before acquiring xs->mutex in xsk_bind(). This
> aligns xsk_bind() with the global lock hierarchy:
> rtnl_lock -> netdev_lock_ops(dev) -> net->xdp.lock -> xs->mutex.
> 
> Fixes: 978939c08db1 ("xsk: use netdev_lock_ops in xsk_bind")
> Reported-by: syzbot+aa48b5fe7bfda62d1682@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=aa48b5fe7bfda62d1682
> Signed-off-by: Khawar Ahemad <ahemadkhawar123@gmail.com>

This creates a deadlock with the change in the following:

  - xsk_bind() takes dev->lock -> xs->mutex
  - xsk_notifier() -> xp_clear_dev() takes xs->mutex -> dev->lock

... also Fixes tag does not exist.

  reply	other threads:[~2026-08-25 15:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-25 15:21 Khawar Ahemad
2026-08-25 15:39 ` Daniel Borkmann [this message]
2026-08-25 15:42 ` Khawar Ahemad
2026-08-25 16:21 ` bot+bpf-ci
2026-08-25 20:07 ` [syzbot ci] " syzbot ci

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=46035122-87f6-449f-aa71-a8e9e99dc006@iogearbox.net \
    --to=daniel@iogearbox.net \
    --cc=ahemadkhawar123@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maciej.fijalkowski@intel.com \
    --cc=magnus.karlsson@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    --cc=syzbot+aa48b5fe7bfda62d1682@syzkaller.appspotmail.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

all inboxes | Powered by JetHome®