[PATCH] workqueue: Fix memory ordering race in queue_work*()

Herbert Xu herbert at gondor.apana.org.au
Tue Aug 16 00:48:00 PDT 2022


On Tue, Aug 16, 2022 at 03:28:50PM +0900, Hector Martin wrote:
>
> This is the same reason I argued queue_work() itself needs to have a
> similar guarantee, even when it doesn't queue work (and I updated the
> doc to match). If test_and_set_bit() is used in this kind of context
> often in the kernel, clearly the current implementation/doc clashes with
> that.

Kernel code all over the place rely on the fact that test_and_set_bit
provides a memory barrier.  So this bug that you've discovered is
not at all isolated to the workqeueue system.  It'll break the kernel
in lots of places in exactly the same way.

> As I said, I don't have any particular beef in this fight, but this is
> horribly broken on M1/2 right now, so I'll send a patch to change the
> bitops instead and you all can fight it out over which way is correct :)

Please do.

Thanks,
-- 
Email: Herbert Xu <herbert at gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt



More information about the linux-arm-kernel mailing list