netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 net 0/3] Introduce refcount_t for reference counting of rose_neigh
@ 2025-08-23  8:58 Takamitsu Iwai
  2025-08-23  8:58 ` [PATCH v2 net 1/3] net: rose: split remove and free operations in rose_remove_neigh() Takamitsu Iwai
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Takamitsu Iwai @ 2025-08-23  8:58 UTC (permalink / raw)
  To: linux-hams, netdev
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman, Takamitsu Iwai, Kohei Enju, Ingo Molnar,
	Thomas Gleixner, Jesper Dangaard Brouer, Nikita Zhandarovich,
	Kuniyuki Iwashima

The current implementation of rose_neigh uses 'use' and 'count' field of
type unsigned short as a reference count. This approach lacks atomicity,
leading to potential race conditions. As a result, syzbot has reported
slab-use-after-free errors due to unintended removals.

This series introduces refcount_t for reference counting to ensure
atomicity and prevent race conditions. The patches are structured as
follows:

1. Refactor rose_remove_neigh() to separate removal and freeing operations
2. Convert 'use' field to refcount_t for appropriate reference counting
3. Include references from rose_node to 'use' field

These changes should resolve the reported slab-use-after-free issues and
improve the overall stability of the ROSE network layer.

Changes:
 v2:
  - Added rose_neigh_put() in error paths of rose_connect() to prevent
    reference count leaks that could occur after moving the reference
    count increment to rose_get_neigh().
  - Added rose_neigh_put() at the end of rose_route_frame() to properly
    release the temporary reference held by new_neigh variable when
    the function completes.
  - Added rose_neigh_hold() in the second for loop of rose_get_neigh()
    to maintain consistent reference counting behavior between both loops.

  v1:
    https://lore.kernel.org/all/20250820174707.83372-1-takamitz@amazon.co.jp/


Takamitsu Iwai (3):
  net: rose: split remove and free operations in rose_remove_neigh()
  net: rose: convert 'use' field to refcount_t
  net: rose: include node references in rose_neigh refcount

 include/net/rose.h    | 18 ++++++++++++-
 net/rose/af_rose.c    | 13 ++++-----
 net/rose/rose_in.c    | 12 ++++-----
 net/rose/rose_route.c | 62 ++++++++++++++++++++++++++-----------------
 net/rose/rose_timer.c |  2 +-
 5 files changed, 69 insertions(+), 38 deletions(-)

-- 
2.39.5 (Apple Git-154)


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

end of thread, other threads:[~2025-09-02 17:23 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-23  8:58 [PATCH v2 net 0/3] Introduce refcount_t for reference counting of rose_neigh Takamitsu Iwai
2025-08-23  8:58 ` [PATCH v2 net 1/3] net: rose: split remove and free operations in rose_remove_neigh() Takamitsu Iwai
2025-08-27  6:21   ` Kuniyuki Iwashima
2025-08-23  8:58 ` [PATCH v2 net 2/3] net: rose: convert 'use' field to refcount_t Takamitsu Iwai
2025-08-27  6:47   ` Kuniyuki Iwashima
2025-08-23  8:58 ` [PATCH v2 net 3/3] net: rose: include node references in rose_neigh refcount Takamitsu Iwai
2025-08-27  6:48   ` Kuniyuki Iwashima
2025-08-27 14:50 ` [PATCH v2 net 0/3] Introduce refcount_t for reference counting of rose_neigh patchwork-bot+netdevbpf
2025-09-02 17:18   ` F6BVP
2025-09-02 17:23     ` Eric Dumazet

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).