From: sashiko-bot@kernel.org
To: "Oliver Hartkopp" <socketcan@hartkopp.net>, linux-can@vger.kernel.org
Cc: "Marc Kleine-Budde" <mkl@pengutronix.de>,
"Vincent Mailhol" <mailhol@kernel.org>,
"Oleksij Rempel" <o.rempel@pengutronix.de>
Subject: Re: [PATCH 1/3] can: bcm: copy the CAN frames outside of lock_sock()
Date: Sat, 07 Nov 2026 13:15:32 +0000 [thread overview]
Message-ID: <sashiko-outbox-202903@kernel.org> (raw)
In-Reply-To: <20261107-can-bcmlock-memcg-v1-1-482d9f5be1fd@hartkopp.net>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] can: bcm: indefinite rtnl_lock stall in bcm_notify() [1]
--
commit 21cad73125ec2cd172e1d3266d5282c5a3ca76be
Author: Oliver Hartkopp <socketcan@hartkopp.net>
can: bcm: copy the CAN frames outside of lock_sock()
This commit copies CAN frames from user space into a kernel buffer before
acquiring lock_sock() in bcm_sendmsg(), preventing a stalled user-space copy
from blocking bcm_notify() under RTNL.
> diff --git a/net/can/bcm.c b/net/can/bcm.c
> index 7bd2aa39777af..9c39f7363ca59 100644
> --- a/net/can/bcm.c
> +++ b/net/can/bcm.c
[ ... ]
> @@ -1663,6 +1668,47 @@ static int bcm_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
> if ((size - MHSIZ) % cfsiz)
> return -EINVAL;
>
> + /* Copy the CAN frames from user space before lock_sock(), so a
> + * stalled copy can not block bcm_notify() waiting for lock_sock()
> + * under RTNL. Only the frames the opcode handler reads are copied.
> + * The handlers keep their checks and read the frames from fmsg.
> + */
[Severity: High]
This problem wasn't introduced by this patch, but can bcm_notify() still
block RTNL indefinitely in remove_proc_entry() [1]?
When a bound CAN device is unregistered, bcm_notify() is called under
rtnl_lock and tears down the socket's /proc/net/can-bcm/<inode> entry:
net/can/bcm.c:bcm_notify() {
...
case NETDEV_UNREGISTER:
lock_sock(sk);
...
if (bo->bound && bo->ifindex == dev->ifindex) {
#if IS_ENABLED(CONFIG_PROC_FS)
if (sock_net(sk)->can.bcmproc_dir && bo->bcm_proc_read) {
remove_proc_entry(bo->procname, sock_net(sk)->can.bcmproc_dir);
bo->bcm_proc_read = NULL;
}
#endif
...
}
Because that procfs entry is world-readable and remove_proc_entry() waits
for active readers (pde_users) to finish, a local user who stalls a read()
on /proc/net/can-bcm/<inode> (for example via userfaultfd or FUSE) causes
remove_proc_entry() to block forever while holding rtnl_lock and lock_sock().
[1] https://sashiko.dev/#/bug/linux-23a32da5-4d8e-457b-9e84-376ce500a113
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261107-can-bcmlock-memcg-v1-0-482d9f5be1fd@hartkopp.net?part=1
next prev parent reply other threads:[~2026-11-07 13:15 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-07 13:06 [PATCH 0/3] can: bcm: avoid RTNL stalls and enable memcg accounting Oliver Hartkopp
2026-11-07 13:06 ` [PATCH 1/3] can: bcm: copy the CAN frames outside of lock_sock() Oliver Hartkopp
2026-11-07 13:15 ` sashiko-bot [this message]
2026-11-07 13:29 ` Oliver Hartkopp
2026-11-09 2:18 ` netdev-bot+sashiko
2026-11-09 7:56 ` Oliver Hartkopp
2026-11-07 13:06 ` [PATCH 2/3] can: bcm: do not remove the procfs entry in bcm_notify() Oliver Hartkopp
2026-11-09 2:18 ` netdev-bot+sashiko
2026-11-09 8:00 ` Oliver Hartkopp
2026-11-07 13:06 ` [PATCH 3/3] can: enable memcg accounting for user triggered allocations Oliver Hartkopp
2026-11-07 13:14 ` sashiko-bot
2026-11-07 13:35 ` Oliver Hartkopp
2026-11-08 8:23 ` Oleksij Rempel
2026-11-08 8:21 ` Oleksij Rempel
2026-11-08 8:25 ` Oleksij Rempel
2026-11-09 2:18 ` netdev-bot+sashiko
2026-11-09 8:09 ` Oliver Hartkopp
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=sashiko-outbox-202903@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=mailhol@kernel.org \
--cc=mkl@pengutronix.de \
--cc=o.rempel@pengutronix.de \
--cc=sashiko-reviews@lists.linux.dev \
--cc=socketcan@hartkopp.net \
/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.