From: Alexei Starovoitov Date: Fri, 12 Jul 2024 15:54:08 +0000 (-0700) Subject: Merge branch 'use-overflow-h-helpers-to-check-for-overflows' X-Git-Tag: v6.11-rc1~163^2~37^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a1010fce1c0c2ce3b305aa6e8ff70e86f99e3226;p=thirdparty%2Fkernel%2Flinux.git Merge branch 'use-overflow-h-helpers-to-check-for-overflows' Shung-Hsi Yu says: ==================== Use overflow.h helpers to check for overflows This patch set refactors kernel/bpf/verifier.c to use type-agnostic, generic overflow-check helpers defined in include/linux/overflow.h to check for addition and subtraction overflow, and drop the signed_*_overflows() helpers we currently have in kernel/bpf/verifier.c; with a fix for overflow check in adjust_jmp_off() in patch 1. There should be no functional change in how the verifier works and the main motivation is to make future refactoring[1] easier. While check_mul_overflow() also exists and could potentially replace what we have in scalar*_min_max_mul(), it does not help with refactoring and would either change how the verifier works (e.g. lifting restriction on umax<=U32_MAX and u32_max<=U16_MAX) or make the code slightly harder to read, so it is left for future endeavour. Changes from v2 - add fix for 5337ac4c9b80 ("bpf: Fix the corner case with may_goto and jump to the 1st insn.") to correct the overflow check for general jump instructions - adapt to changes in commit 5337ac4c9b80 ("bpf: Fix the corner case with may_goto and jump to the 1st insn.") - refactor in adjust_jmp_off() as well and remove signed_add16_overflow() Changes from v1 : - use pointers to values in dst_reg directly as the sum/diff pointer and remove the else branch (Jiri) - change local variables to be dst_reg pointers instead of src_reg values - include comparison of generated assembly before & after the change (Alexei) 1: https://github.com/kernel-patches/bpf/pull/7205/commits ==================== Link: https://lore.kernel.org/r/20240712080127.136608-1-shung-hsi.yu@suse.com Signed-off-by: Alexei Starovoitov --- a1010fce1c0c2ce3b305aa6e8ff70e86f99e3226