#15710

futex: fix FUTEX_WAKE_OP

Opencopybara-service[bot]wants to merge intofrom

futex: fix FUTEX_WAKE_OP

atomicOp reads the 12-bit oparg and cmparg fields as unsigned, shifts by oparg without masking it, and compares the old value as unsigned. Linux's kernel/futex/waitwake.c:futex_atomic_op_inuser() sign-extends both fields, masks the shift to 5 bits, and compares signed ints. Qt 5.15.2-5.15.3's QSemaphore depends on the signed comparison and hangs under gVisor.

Match Linux, and add a syscall test for each case. The new tests fail on runsc without this change, and pass with it and on native Linux, on x86_64 and arm64.

An earlier attempt, #15249, was closed.

Fixes #15219

Assisted-by: Claude Code

Reviewed and tested by me.

FUTURE_COPYBARA_INTEGRATE_REVIEW=https://github.com/google/gvisor/pull/15641 from samridh10exe:samridh/futex-wake-op 3382105914dee721775f04aced3ed9ef8495266b

Activity

1