landlock: Fix TSYNC deadlock and clean up error path
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v5 Latest2 patches 2 repliesIn review
- v42 patches 2 repliesSuperseded
- v3 posting 2/22 patches 14 repliesSuperseded
Earlier versions · 2
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v3 posting 1/2 | 0 of 2 patches | 0 replies | Superseded | |
| v2 | 2 patches | 4 replies | Superseded |
Changes in v5 from the cover letter
- Just simple formatting changes, no code changes.
Patches in v5 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | landlock: Serialize TSYNC thread restrictionsecurity/ | +10 | 1 reply | |
| 2/2 | landlock: Clean up interrupted thread logic in TSYNCsecurity/ | +10 | 1 reply |
Reviews trailers per patch
All 2 patches have a Reviewed-by or Acked-by.
| Patch | Justin Suess | Günther Noack |
|---|---|---|
| 1/2 | T-b | T-b R-b |
| 2/2 | T-b R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v5 0/2] landlock: Fix TSYNC deadlock and clean up error path
Hello,
This patch series fixes a deadlock in the Landlock TSYNC multithreading support, originally reported by syzbot, and cleans up the associated interrupt recovery path.
The deadlock occurs when multiple threads concurrently call landlock_restrict_self() with sibling thread restriction enabled, causing them to mutually queue task_works on each other and block indefinitely.
* Patch 1 fixes the root cause by serializing the TSYNC operations within the same process using the exec_update_lock.
* Patch 2 cleans up the interrupt recovery path by replacing an unnecessary wait_for_completion() with a straightforward loop break, avoiding Use-After-Free while unblocking remaining task_works.
---
Changes in v5:
- Just simple formatting changes, no code changes.
Changes in v4:
- Patch 1: Use restart_syscall() instead of returning -ERESTARTNOINTR. This ensures the syscall is properly restarted without leaking the internal error code to userspace, fixing a test failure in tsync_test.competing_enablement. (Caught by Justin Suess, suggested by Tingmao Wang).
- Patch 1 and 2: Wrap comments to fit in 80 columns
Changes in v3:
- Patch 1: Changed down_write_killable() to down_write_trylock() and return -ERESTARTNOINTR on failure. This avoids a secondary deadlock where a blocking wait prevents a sibling thread from waking up to execute the requested TSYNC task_work. (Noted by Günther Noack. down_write_interruptible() was also suggested but is not implemented for rw_semaphores in the kernel).
- Patch 2: No changes.
Changes in v2:
- Split the changes into a 2-patch series.
- Patch 1: Adopted down_write_killable() instead of down_write().
- Patch 2: Removed wait_for_completion(&shared_ctx.all_prepared) and replaced it with a break to prevent UAF.
Link to v4: https://lore.kernel.org/all/[email protected]/
Link to v3: https://lore.kernel.org/all/[email protected]/
Link to v2: https://lore.kernel.org/all/[email protected]/
Link to v1: https://lore.kernel.org/all/[email protected]/
Yihan Ding (2):
landlock: Serialize TSYNC thread restriction
landlock: Clean up interrupted thread logic in TSYNC
security/landlock/tsync.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-)
Signature · 1 line
2.20.1