On Mon, Mar 30, 2026 at 02:33:05PM +0000, Maciej Wieczor-Retman wrote:
> diff --git a/Documentation/arch/arm64/kasan-offsets.sh
> b/Documentation/arch/arm64/kasan-offsets.sh
> index 2dc5f9e18039..ce777c7c7804 100644
> --- a/Documentation/arch/arm64/kasan-offsets.sh
> +++ b/Documentation/arch/arm64/kasan-offsets.sh
> @@ -5,8 +5,12 @@
>
> print_kasan_offset () {
> printf "%02d\t" $1
> - printf "0x%08x00000000\n" $(( (0xffffffff & (-1 << ($1 - 1 - 32))) \
> - - (1 << (64 - 32 - $2)) ))
> + if [[ $2 -ne 4 ]] then
Nitpick: does this need a semicolon before 'then'?
I can see Sashiko raised it here:
https://sashiko.dev/#/patchset/[email protected]
> + printf "0x%08x00000000\n" $(( (0xffffffff & (-1 << ($1 - 1 -
> 32))) \
> + - (1 << (64 - 32 - $2)) ))
> + else
> + printf "0x%08x00000000\n" $(( (0xffffffff & (-1 << ($1 - 1 -
> 32))) ))
> + fi
> }
>
> echo KASAN_SHADOW_SCALE_SHIFT = 3
[...]
> diff --git a/scripts/gdb/linux/kasan.py b/scripts/gdb/linux/kasan.py
> index 56730b3fde0b..4b86202b155f 100644
> --- a/scripts/gdb/linux/kasan.py
> +++ b/scripts/gdb/linux/kasan.py
> @@ -7,7 +7,8 @@
> #
>
> import gdb
> -from linux import constants, mm
> +from linux import constants, utils, mm
> +from ctypes import c_int64 as s64
>
> def help():
> t = """Usage: lx-kasan_mem_to_shadow [Hex memory addr]
> @@ -39,6 +40,8 @@ class KasanMemToShadow(gdb.Command):
> else:
> help()
> def kasan_mem_to_shadow(self, addr):
> + if constants.CONFIG_KASAN_SW_TAGS and not
> utils.is_target_arch('x86'):
Does this need to be constants.LX_CONFIG_KASAN_SW_TAGS? I don't claim I
fully understand this script but the other constants.* use LX_*.
> + addr = s64(addr)
> return (addr >> self.p_ops.KASAN_SHADOW_SCALE_SHIFT) +
> self.p_ops.KASAN_SHADOW_OFFSET
And, again, Sashiko mentions that the bitwise right shift here will fail
after the cast to c_int64. I just tried this in python:
>>> from ctypes import c_int64 as s64
>>> s64(0xffff000008eca008) >> 4
Traceback (most recent call last):
File "<python-input-1>", line 1, in <module>
s64(0xffff000008eca008) >> 4
~~~~~~~~~~~~~~~~~~~~~~~~^^~~
TypeError: unsupported operand type(s) for >>: 'c_long' and 'int'
I guess it's hidden by the wrong check on
constants.CONFIG_KASAN_SW_TAGS.
Otherwise I think the changes are fine. If you fix the above, feel free
to add:
Acked-by: Catalin Marinas <[email protected]>