From: Jakub Kicinski <kuba@kernel.org>
To: Taehee Yoo <ap420073@gmail.com>
Cc: davem@davemloft.net, pabeni@redhat.com, edumazet@google.com,
andrew+netdev@lunn.ch, horms@kernel.org, almasrymina@google.com,
sdf@fomichev.me, netdev@vger.kernel.org, asml.silence@gmail.com,
dw@davidwei.uk, skhawaja@google.com, willemb@google.com,
jdamato@fastly.com
Subject: Re: [PATCH net v2] net: devmem: fix kernel panic when socket close after module unload
Date: Tue, 6 May 2025 19:55:26 -0700 [thread overview]
Message-ID: <20250506195526.2ab7c15b@kernel.org> (raw)
In-Reply-To: <20250506140858.2660441-1-ap420073@gmail.com>
On Tue, 6 May 2025 14:08:58 +0000 Taehee Yoo wrote:
> + mutex_lock(&binding->priv->lock);
> xa_for_each(&binding->bound_rxqs, xa_idx, bound_rxq) {
> if (bound_rxq == rxq) {
> xa_erase(&binding->bound_rxqs, xa_idx);
> + if (xa_empty(&binding->bound_rxqs))
> + binding->dev = NULL;
> break;
> }
> }
> + mutex_unlock(&binding->priv->lock);
Why do we need to lock the socket around the while loop?
binding->bound_rxqs have its own lock, and add/del are also
protected by the netdev instance lock. The only thing we
must lock is the write to binding->dev I think ?
Would it be cleaner to move that write and locking to a helper
which would live in netdev-genl.c?
Similarly could we move:
if (binding->list.next)
list_del(&binding->list);
from net_devmem_unbind_dmabuf() to its callers?
The asymmetry of list_add() being directly in netdev_nl_bind_rx_doit()
not net_devmem_bind_dmabuf(), and list_del() being in
net_devmem_unbind_dmabuf() always confuses me.
>+ mutex_lock(&priv->lock);
>+ binding = net_devmem_bind_dmabuf(netdev, dmabuf_fd, priv, info->extack);
We shouldn't have to lock the net_devmem_bind_dmabuf(), we have the
instance lock so the device can't go away, and we haven't listed
the binding on the socket, yet. Locking around list_add() should
be enough?
next prev parent reply other threads:[~2025-05-07 2:55 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-06 14:08 [PATCH net v2] net: devmem: fix kernel panic when socket close after module unload Taehee Yoo
2025-05-06 17:41 ` Stanislav Fomichev
2025-05-07 2:42 ` Jakub Kicinski
2025-05-07 4:22 ` Taehee Yoo
2025-05-06 22:07 ` Jakub Kicinski
2025-05-07 4:24 ` Taehee Yoo
2025-05-07 2:55 ` Jakub Kicinski [this message]
2025-05-07 4:55 ` Taehee Yoo
2025-05-07 13:23 ` Jakub Kicinski
2025-05-07 15:54 ` Taehee Yoo
2025-05-07 13:08 ` kernel test robot
2025-05-07 18:28 ` Mina Almasry
2025-05-08 9:59 ` Taehee Yoo
2025-05-08 20:45 ` Mina Almasry
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=20250506195526.2ab7c15b@kernel.org \
--to=kuba@kernel.org \
--cc=almasrymina@google.com \
--cc=andrew+netdev@lunn.ch \
--cc=ap420073@gmail.com \
--cc=asml.silence@gmail.com \
--cc=davem@davemloft.net \
--cc=dw@davidwei.uk \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jdamato@fastly.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf@fomichev.me \
--cc=skhawaja@google.com \
--cc=willemb@google.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;
as well as URLs for NNTP newsgroup(s).