NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/58610: localcount(9) races with interrupts



>Number:         58610
>Category:       kern
>Synopsis:       localcount(9) races with interrupts
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Aug 16 18:40:00 +0000 2024
>Originator:     Taylor R Campbell
>Release:        current, 10, 9, ...
>Organization:
The localNetBSD Foundation
>Environment:
>Description:
If localcount_acquire, localcount_release, or localcount_xc is interrupted and the interrupt handler also does localcount_acquire or localcount_release, it may lose counts, leading to deadlock or premature free.
>How-To-Repeat:
code inspection
>Fix:
1. Make localcount_adjust (localcount_acquire/release) use atomic_add_64_ni, and localcount_xc use atomic_swap_64_ni, if available and worthwhile (which pretty much means `on x86').
2. Otherwise, use splhigh/splx in localcount_adjust and localcount_xc.

Alternatively, forbid localcount_acquire/release in (soft) interrupt context, but that makes them less useful and I suspect ipsec(4) uses them in soft interrupt context already, if not in hard interrupt context.



Home | Main Index | Thread Index | Old Index