Linux CAN drivers development
 help / color / mirror / Atom feed
* [PATCH v6 0/8] can: avoid RTNL stalls and fix CAN_ISOTP and netlink issues
@ 2026-11-17 16:35 Oliver Hartkopp
  2026-11-17 16:35 ` [PATCH v6 1/8] can: bcm: copy the CAN frames outside of lock_sock() Oliver Hartkopp
                   ` (7 more replies)
  0 siblings, 8 replies; 15+ messages in thread
From: Oliver Hartkopp @ 2026-11-17 16:35 UTC (permalink / raw)
  To: linux-can
  Cc: Marc Kleine-Budde, Oleksij Rempel, Vincent Mailhol, Zhu Ling,
	Oliver Hartkopp, Sashiko

Hi Marc,

this series replaces the following patches of your pull request
"pull-request: can 2026-11-15", which has not been merged into net yet:

- the five patches of "can: avoid RTNL stalls in CAN_RAW, CAN_ISOTP and
  CAN_BCM" (v5), which are unchanged in this series (patches 1 to 5)
- "can: netlink: fix static FD-NON-ISO mode validation" by Zhu Ling,
  which is replaced by an updated version (patch 8)

The other netlink patches by Zhu Ling ("fix IFLA_CAN_BITRATE_MAX
attribute sizing" and "fix CAN XL PWM attribute sizing") and your gs_usb
patch are not touched. Both netlink patches apply unchanged on top of
patch 8. Could you please update your pull request accordingly?

Patches 1 and 2 avoid RTNL stalls in CAN_BCM: the CAN frames are copied
outside of lock_sock() and the procfs entry of a socket is only removed
in bcm_release().

Patches 3 to 5 replace lock_sock() with a private mutex in CAN_RAW,
CAN_ISOTP and CAN_BCM, so that the generic SOL_SOCKET options, which
access user space under the socket lock, can not block the netdev
notifiers under RTNL anymore.

Patches 6 and 7 fix pre-existing CAN_ISOTP issues that came up in the
Sashiko review of patch 4. Patch 6 makes sure that the rx timeout is
always running in ISOTP_WAIT_DATA state, so the rx state can not get
stuck after the CAN device has been removed. Patch 7 rejects socket
options while a transfer is still active, like isotp_bind() already
does. Patch 6 is needed before patch 7, as otherwise a stuck rx state
would also block setsockopt().

Patch 8 is Zhu Ling's fix for the static FD-NON-ISO mode validation,
updated after the Sashiko review of the pull request: instead of
restoring the static control modes after the update, a request that
switches off a static control mode is rejected with a dedicated error
message, and the commit message describes the full impact.

The series has been tested on a kernel with PROVE_LOCKING and KASAN with
the CAN locking test suite, including new tests for patches 6 and 7,
which fail without these patches and pass with them.

The memcg accounting patch and the follow-up patches for
raw_getsockopt() and isotp_getsockopt() will be sent for can-next.
CAN_J1939 still takes lock_sock() under RTNL in its netdev notifier and
will be addressed separately.

---
Changes in v6:
- new patches 6 and 7: CAN_ISOTP rx timeout and socket option fixes for
  pre-existing issues found in the Sashiko review of patch 4
- new patch 8: updated version of Zhu Ling's "can: netlink: fix static
  FD-NON-ISO mode validation" from the pull request, after the Sashiko
  review of that patch
- Link to v5: https://patch.msgid.link/20261113-can-bcmlock-memcg-v5-0-634c0e04bc72@hartkopp.net

Changes in v5:
- removed patch 6 "can: enable memcg accounting for user triggered
  allocations" from this series, it will be sent for can-next
- patches 3 and 4: the comment for conf_lock names setsockopt, as most
  options are read without the mutex in getsockopt() like before. The
  commit messages point to the follow-up patches (Sashiko review)
- Link to v4: https://patch.msgid.link/20261111-can-bcmlock-memcg-v4-0-5428607a608f@hartkopp.net

Changes in v4:
- new patches 3 to 5: replace lock_sock() with a private mutex in
  CAN_RAW, CAN_ISOTP and CAN_BCM, so that the generic SOL_SOCKET options
  can not block the netdev notifiers under RTNL anymore
- patch 6 (was patch 3): charge the isotp RX buffer to the memory
  cgroup of the socket with set_active_memcg() (Sashiko review)
- Link to v3: https://patch.msgid.link/20261109-can-bcmlock-memcg-v3-0-2d798ca30578@hartkopp.net

Changes in v3:
- patch 2: read bo->bound and bo->ifindex with READ_ONCE() for NETDEV_DOWN
  and shortened the bcm_notify() comment (Sashiko review)
- Link to v2: https://patch.msgid.link/20261108-can-bcmlock-memcg-v2-0-19fafdfc9d12@hartkopp.net

Changes in v2:
- patch 1: fixed the description of the stack buffer and described the
  remaining generic SOL_SOCKET paths (Sashiko review)
- patch 2: read and write bo->ifindex with READ_ONCE()/WRITE_ONCE() for
  the lockless access in bcm_proc_show() (Sashiko review)
- patch 3: keep the GFP_USER | __GFP_NOWARN flags of memdup_sockptr()
  for the filters and describe the local j1939 ECUs (Sashiko review)
- Link to v1: https://patch.msgid.link/20261107-can-bcmlock-memcg-v1-0-482d9f5be1fd@hartkopp.net

---
Oliver Hartkopp (7):
      can: bcm: copy the CAN frames outside of lock_sock()
      can: bcm: do not remove the procfs entry in bcm_notify()
      can: raw: use a private mutex instead of lock_sock()
      can: isotp: use a private mutex instead of lock_sock()
      can: bcm: use a private mutex instead of lock_sock()
      can: isotp: always start the rx timeout in ISOTP_WAIT_DATA state
      can: isotp: reject socket options while a transfer is active

Zhu Ling (1):
      can: netlink: fix static FD-NON-ISO mode validation

 drivers/net/can/dev/netlink.c |  10 +++-
 net/can/bcm.c                 | 114 ++++++++++++++++++++++++++++++------------
 net/can/isotp.c               |  50 +++++++++++-------
 net/can/raw.c                 |  41 ++++++++-------
 4 files changed, 145 insertions(+), 70 deletions(-)
---
base-commit: 30c71476d842b094651bd7712f6c8ee8716147d0
change-id: 20261107-can-bcmlock-memcg-2d8ae7361838

Best regards,
--  
Oliver Hartkopp <socketcan@hartkopp.net>


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2026-11-19  6:59 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-17 16:35 [PATCH v6 0/8] can: avoid RTNL stalls and fix CAN_ISOTP and netlink issues Oliver Hartkopp
2026-11-17 16:35 ` [PATCH v6 1/8] can: bcm: copy the CAN frames outside of lock_sock() Oliver Hartkopp
2026-11-17 16:35 ` [PATCH v6 2/8] can: bcm: do not remove the procfs entry in bcm_notify() Oliver Hartkopp
2026-11-19  6:59   ` netdev-bot+sashiko
2026-11-17 16:35 ` [PATCH v6 3/8] can: raw: use a private mutex instead of lock_sock() Oliver Hartkopp
2026-11-19  6:59   ` netdev-bot+sashiko
2026-11-17 16:35 ` [PATCH v6 4/8] can: isotp: " Oliver Hartkopp
2026-11-17 16:35 ` [PATCH v6 5/8] can: bcm: " Oliver Hartkopp
2026-11-17 16:35 ` [PATCH v6 6/8] can: isotp: always start the rx timeout in ISOTP_WAIT_DATA state Oliver Hartkopp
2026-11-19  6:59   ` netdev-bot+sashiko
2026-11-17 16:35 ` [PATCH v6 7/8] can: isotp: reject socket options while a transfer is active Oliver Hartkopp
2026-11-17 17:17   ` sashiko-bot
2026-11-17 18:58     ` Oliver Hartkopp
2026-11-19  6:59   ` netdev-bot+sashiko
2026-11-17 16:35 ` [PATCH v6 8/8] can: netlink: fix static FD-NON-ISO mode validation Oliver Hartkopp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox