diff options
| author | Andrew Turner <andrew@FreeBSD.org> | 2022-05-09 14:28:56 +0000 |
|---|---|---|
| committer | Andrew Turner <andrew@FreeBSD.org> | 2022-05-19 10:30:21 +0000 |
| commit | 11a6ecd4258b9108fb19420ec5db297f6d99a842 (patch) | |
| tree | 67c960f6b2ef5b149b04a6723f3fe7563159ad81 | |
| parent | 190abf86bb455a5b423ca46d309c4492a2d41a94 (diff) | |
| download | src-11a6ecd4258b9108fb19420ec5db297f6d99a842.tar.gz src-11a6ecd4258b9108fb19420ec5db297f6d99a842.zip | |
Handle cas failure when the compare succeeds
When locking a priority inherit mutex we perform a compare and swap
operation to try and acquire the mutex. This may fail even when the
compare succeeds.
Check and handle this case.
PR: 263825
Reviewed by: kib, markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35150
| -rw-r--r-- | sys/kern/kern_umtx.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c index 2f666bdcdc7b..d63381d76eb8 100644 --- a/sys/kern/kern_umtx.c +++ b/sys/kern/kern_umtx.c @@ -2263,6 +2263,17 @@ do_lock_pi(struct thread *td, struct umutex *m, uint32_t flags, } /* + * Nobody owns it, but the acquire failed. This can happen + * with ll/sc atomics. + */ + if (owner == UMUTEX_UNOWNED) { + error = thread_check_susp(td, true); + if (error != 0) + break; + continue; + } + + /* * Avoid overwriting a possible error from sleep due * to the pending signal with suspension check result. */ |
