From: sashiko-bot@kernel.org
To: "Khawar Ahemad" <ahemadkhawar123@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next] xsk: Fix circular locking dependency in xsk_bind
Date: Tue, 25 Aug 2026 15:37:18 +0000 [thread overview]
Message-ID: <20260825153718.E26161F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260825152152.86092-1-ahemadkhawar123@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The patch introduces a direct ABBA lock inversion between `xs->mutex` and `netdev_lock_ops(dev)` while failing to fix the original lockdep cycle.
--
--- Patch [1]: [PATCH bpf-next] xsk: Fix circular locking dependency in xsk_bind ---
commit d56fb43288cd7168ec871fc7dae61dd873e064c7
Author: Khawar Ahemad <ahemadkhawar123@gmail.com>
xsk: Fix circular locking dependency in xsk_bind
This commit attempts to fix a lockdep splat in xsk_bind() by acquiring
netdev_lock_ops(dev) before xs->mutex. It aims to align with the global lock
hierarchy.
Link: https://syzkaller.appspot.com/bug?extid=aa48b5fe7bfda62d1682
> diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
> index 7855ee09c4b64..d2fbbeb7b6d77 100644
> --- a/net/xdp/xsk.c
> +++ b/net/xdp/xsk.c
> @@ -1612,19 +1612,18 @@ static int xsk_bind(struct socket *sock, struct sockaddr_unsized *addr, int addr
> return -EINVAL;
>
> rtnl_lock();
> - mutex_lock(&xs->mutex);
> - if (xs->state != XSK_READY) {
> - err = -EBUSY;
> - goto out_release;
> - }
> -
> dev = dev_get_by_index(sock_net(sk), sxdp->sxdp_ifindex);
> if (!dev) {
> err = -ENODEV;
> - goto out_release;
> + goto out_rtnl_unlock;
> }
>
> netdev_lock_ops(dev);
> + mutex_lock(&xs->mutex);
[Severity: High]
Does this change introduce a direct ABBA lock inversion between xs->mutex and
netdev_lock_ops(dev)?
While xsk_bind() now acquires netdev_lock_ops(dev) before xs->mutex,
xsk_notifier() still acquires xs->mutex before calling xp_clear_dev():
net/xdp/xsk.c:xsk_notifier() {
...
mutex_lock(&xs->mutex);
if (xs->dev == dev) {
...
xp_clear_dev(xs->pool);
}
mutex_unlock(&xs->mutex);
...
}
And xp_clear_dev() unconditionally acquires netdev_lock_ops(netdev):
net/xdp/xsk_buff_pool.c:xp_clear_dev() {
...
netdev_lock_ops(netdev);
xp_disable_drv_zc(pool);
xsk_clear_pool_at_qid(pool->netdev, pool->queue_id);
...
}
Could this lead to a deadlock when xsk_bind() races with xsk_notifier()?
Since xsk_notifier() still acquires xs->mutex before netdev_lock_ops(), does
this mean the original lockdep cycle reported in the commit message is not
actually broken?
> + if (xs->state != XSK_READY) {
> + err = -EBUSY;
> + goto out_unlock;
> + }
>
> if (!xs->rx && !xs->tx) {
> err = -EINVAL;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260825152152.86092-1-ahemadkhawar123@gmail.com?part=1
next prev parent reply other threads:[~2026-08-25 15:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 15:21 [PATCH bpf-next] xsk: Fix circular locking dependency in xsk_bind Khawar Ahemad
2026-08-25 15:37 ` sashiko-bot [this message]
2026-08-25 15:39 ` Daniel Borkmann
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=20260825153718.E26161F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=ahemadkhawar123@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.