Re: [PATCH v2 net 2/3] net: rose: convert 'use' field to refcount_t
From: Kuniyuki Iwashima <kuniyu@google.com>
Date: 2025-08-27 06:48:03
Also in:
linux-hams
From: Kuniyuki Iwashima <kuniyu@google.com>
Date: 2025-08-27 06:48:03
Also in:
linux-hams
On Sat, Aug 23, 2025 at 2:01 AM Takamitsu Iwai [off-list ref] wrote:
The 'use' field in struct rose_neigh is used as a reference counter but
lacks atomicity. This can lead to race conditions where a rose_neigh
structure is freed while still being referenced by other code paths.
For example, when rose_neigh->use becomes zero during an ioctl operation
via rose_rt_ioctl(), the structure may be removed while its timer is
still active, potentially causing use-after-free issues.
This patch changes the type of 'use' from unsigned short to refcount_t and
updates all code paths to use rose_neigh_hold() and rose_neigh_put() which
operate reference counts atomically.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Takamitsu Iwai <redacted>Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>