Skip to content

futex: More robustness tweaks

Thomas Gleixner lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 11 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5futex: Make unlock_pi more robustkernel/futex.c+26 -525 replies
2/5futex: Use futex_top_waiter() in lookup_pi_state()kernel/futex.c+63 -651 reply
3/5futex: Split out the waiter check from lookup_pi_state()kernel/futex.c+71 -671 reply
4/5futex: Split out the first waiter attachment from lookup_pi_state()kernel/futex.c+28 -141 reply
5/5futex: Simplify futex_lock_pi_atomic() and make it more robustkernel/futex.c+53 -867 replies

Reviews trailers per patch

4 of 5 patches have a Reviewed-by or Acked-by.

PatchDarren Hart
1/5R-b
2/5R-b
3/5R-b
4/5R-b
5/5

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [patch 0/5] futex: More robustness tweaks

While looking for the minimal functional fix for the futex CVE, I found a few things which can be done simpler and therefor make the code more robust.

1) UNLOCK_PI

Change the ordering:

- Lookup waiters first. If waiters exist wake up the top priority waiter with all sanity checks applied. That allows us to catch manipulation of the user space value.

- Only if there are no waiters, do the atomic release

2) futex_lock_pi_atomic()

Its a maze of retry hoops and loops. Reduce it to simple and userstandable states.

That requires to split out the lookup and validation functions from lookup_pi_state(), but that turns out to be an overall win on readabilty.

The overall cleanup results in less code and 488 bytes text size reduction on x8664.

Thanks,

tglx

---
 futex.c |  385 ++++++++++++++++++++++++++++------------------------------------
 1 file changed, 171 insertions(+), 214 deletions(-)