lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAADnVQKFPpzbcakNmq2RkYQvm1TsdgO73UNuoaa_F8SCm6suNw@mail.gmail.com>
Date: Fri, 21 Nov 2025 13:40:36 -0800
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: david.laight.linux@...il.com
Cc: LKML <linux-kernel@...r.kernel.org>, bpf <bpf@...r.kernel.org>, 
	Alexei Starovoitov <ast@...nel.org>, Andrii Nakryiko <andrii@...nel.org>, 
	Daniel Borkmann <daniel@...earbox.net>
Subject: Re: [PATCH 06/44] bpf: Verifier, remove some unusual uses of min_t()
 and max_t()

On Wed, Nov 19, 2025 at 2:42 PM <david.laight.linux@...il.com> wrote:
>
> From: David Laight <david.laight.linux@...il.com>
>
> min_t() and max_t() are normally used to change the signedness
> of a positive value to avoid a signed-v-unsigned compare warning.
>
> However they are used here to convert an unsigned 64bit pattern
> to a signed to a 32/64bit signed number.
> To avoid any confusion use plain min()/max() and explicitely cast
> the u64 expression to the correct signed value.
>
> Use a simple max() for the max_pkt_offset calulation and delete the
> comment about why the cast to u32 is safe.
>
> Signed-off-by: David Laight <david.laight.linux@...il.com>
> ---
>  kernel/bpf/verifier.c | 29 +++++++++++------------------
>  1 file changed, 11 insertions(+), 18 deletions(-)
>
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index ff40e5e65c43..22fa9769fbdb 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -2319,12 +2319,12 @@ static void __update_reg32_bounds(struct bpf_reg_state *reg)
>         struct tnum var32_off = tnum_subreg(reg->var_off);
>
>         /* min signed is max(sign bit) | min(other bits) */
> -       reg->s32_min_value = max_t(s32, reg->s32_min_value,
> -                       var32_off.value | (var32_off.mask & S32_MIN));
> +       reg->s32_min_value = max(reg->s32_min_value,
> +                       (s32)(var32_off.value | (var32_off.mask & S32_MIN)));
>         /* max signed is min(sign bit) | max(other bits) */
> -       reg->s32_max_value = min_t(s32, reg->s32_max_value,
> -                       var32_off.value | (var32_off.mask & S32_MAX));
> -       reg->u32_min_value = max_t(u32, reg->u32_min_value, (u32)var32_off.value);
> +       reg->s32_max_value = min(reg->s32_max_value,
> +                       (s32)(var32_off.value | (var32_off.mask & S32_MAX)));

Nack.
This is plain ugly for no good reason.
Leave the code as-is.

pw-bot: cr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ