Page MenuHomeFreeBSD

_umtx_op: fix a compat32 bug in UMTX_OP_NWAKE_PRIVATE
ClosedPublic

Authored by kevans on Nov 16 2020, 3:34 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Apr 26, 6:48 AM
Unknown Object (File)
Jan 8 2024, 7:16 PM
Unknown Object (File)
Dec 20 2023, 7:44 AM
Unknown Object (File)
Dec 12 2023, 5:25 AM
Unknown Object (File)
Dec 3 2023, 12:35 PM
Unknown Object (File)
Nov 15 2023, 6:35 AM
Unknown Object (File)
Sep 6 2023, 10:54 PM
Unknown Object (File)
Sep 6 2023, 10:53 PM
Subscribers

Details

Summary

Specifically, if we're waking up some value n > BATCH_SIZE, then the copyin(9) is wrong on the second iteration due to upp being the wrong type. upp is currently a uint32_t**, so upp + pos advances it by twice as many elements as it should (host pointer size vs. compat32 pointer size).

Fix it by just making upp a uint32_t*; it's still technically a double pointer, but the distinction doesn't matter all that much here since we're just doing arithmetic on it.

Add a test case that demonstrates the problem, placed with the libthr tests since one messing with _umtx_op should be running these tests. Running under compat32, the new test case will hang as threads after the first 128 get missed in the wake. it's not immediately clear how to hit it in practice, since pthread_cond_broadcast() uses a smaller (sleepq batch?) size observed to be around ~50 -- I did not spend much time digging into it.

The uintptr_t change makes no functional difference, but i've tossed it in since it's more accurate (semantically).

Reported by: Andrew Gierth

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable