Re: [PATCH] workqueue: Fix UBSAN 'subtraction overflow' error in shift_and_mask()

From: Tejun Heo
Date: Tue Jul 30 2024 - 17:37:22 EST


On Tue, Jul 30, 2024 at 12:44:31PM +0100, Will Deacon wrote:
...
> This is due to shift_and_mask() using a signed immediate to construct
> the mask and being called with a shift of 31 (WORK_OFFQ_POOL_SHIFT) so
> that it ends up decrementing from INT_MIN.
>
> Use an unsigned constant '1U' to generate the mask in shift_and_mask().
>
> Cc: Tejun Heo <tj@xxxxxxxxxx>
> Cc: Lai Jiangshan <jiangshanlai@xxxxxxxxx>
> Fixes: 1211f3b21c2a ("workqueue: Preserve OFFQ bits in cancel[_sync] paths")
> Signed-off-by: Will Deacon <will@xxxxxxxxxx>

Applied to wq/for-6.11-fixes.

Thanks.

--
tejun