Re: [PATCH] tools intel-speed-select: Fix signed shift UB in BIT() macro

From: srinivas pandruvada

Date: Wed Sep 09 2026 - 21:08:23 EST


On Thu, 2026-09-03 at 16:28 +0800, liujing wrote:
> From: Liu Jing <liujing@xxxxxxxxxxxxxxxxxxxx>
>
> The BIT() macro is defined as `(1 << (x))` with a signed integer 1.
> When x >= 31, this causes signed integer overflow which is undefined
> behavior in C. This macro is used with BIT(31) in isst-core.c and
> isst-core-mbox.c.
>
> Fix it by using `1U` instead of `1` to perform an unsigned shift,
> matching the kernel's own BIT() definition which uses unsigned.
>
> Signed-off-by: Liu Jing <liujing@xxxxxxxxxxxxxxxxxxxx>


Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/spandruvada/linux.git/log/?h=for-sst-v7.4.rc1


Thanks,
Srinivas

> ---
> --- a/tools/power/x86/intel-speed-select/isst.h
> +++ b/tools/power/x86/intel-speed-select/isst.h
> @@ -30,7 +30,7 @@
>  
>  #include <linux/isst_if.h>
>  
> -#define BIT(x) (1 << (x))
> +#define BIT(x) (1U << (x))
>  #define BIT_ULL(nr) (1ULL << (nr))
>  #define GENMASK(h, l) (((~0UL) << (l)) & (~0UL >> (sizeof(long) * 8
> - 1 - (h))))
>  #define GENMASK_ULL(h,
> l)                                                      \
>
>
>