1. 13 Jul, 2024 23 commits
  2. 12 Jul, 2024 17 commits
    • Tengda Wu's avatar
      selftests/bpf: Test for null-pointer-deref bugfix in resolve_prog_type() · e435b043
      Tengda Wu authored
      This test verifies that resolve_prog_type() works as expected when
      `attach_prog_fd` is not passed in.
      
      `prog->aux->dst_prog` in resolve_prog_type() is assigned by
      `attach_prog_fd`, and would be NULL if `attach_prog_fd` is not provided.
      
      Loading EXT prog with bpf_dynptr_from_skb() kfunc call in this way will
      lead to null-pointer-deref.
      
      Verify that the null-pointer-deref bug in resolve_prog_type() is fixed.
      Signed-off-by: default avatarTengda Wu <wutengda@huaweicloud.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20240711145819.254178-3-wutengda@huaweicloud.com
      e435b043
    • Tengda Wu's avatar
      bpf: Fix null pointer dereference in resolve_prog_type() for BPF_PROG_TYPE_EXT · f7866c35
      Tengda Wu authored
      When loading a EXT program without specifying `attr->attach_prog_fd`,
      the `prog->aux->dst_prog` will be null. At this time, calling
      resolve_prog_type() anywhere will result in a null pointer dereference.
      
      Example stack trace:
      
      [    8.107863] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000004
      [    8.108262] Mem abort info:
      [    8.108384]   ESR = 0x0000000096000004
      [    8.108547]   EC = 0x25: DABT (current EL), IL = 32 bits
      [    8.108722]   SET = 0, FnV = 0
      [    8.108827]   EA = 0, S1PTW = 0
      [    8.108939]   FSC = 0x04: level 0 translation fault
      [    8.109102] Data abort info:
      [    8.109203]   ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000
      [    8.109399]   CM = 0, WnR = 0, TnD = 0, TagAccess = 0
      [    8.109614]   GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
      [    8.109836] user pgtable: 4k pages, 48-bit VAs, pgdp=0000000101354000
      [    8.110011] [0000000000000004] pgd=0000000000000000, p4d=0000000000000000
      [    8.112624] Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP
      [    8.112783] Modules linked in:
      [    8.113120] CPU: 0 PID: 99 Comm: may_access_dire Not tainted 6.10.0-rc3-next-20240613-dirty #1
      [    8.113230] Hardware name: linux,dummy-virt (DT)
      [    8.113390] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
      [    8.113429] pc : may_access_direct_pkt_data+0x24/0xa0
      [    8.113746] lr : add_subprog_and_kfunc+0x634/0x8e8
      [    8.113798] sp : ffff80008283b9f0
      [    8.113813] x29: ffff80008283b9f0 x28: ffff800082795048 x27: 0000000000000001
      [    8.113881] x26: ffff0000c0bb2600 x25: 0000000000000000 x24: 0000000000000000
      [    8.113897] x23: ffff0000c1134000 x22: 000000000001864f x21: ffff0000c1138000
      [    8.113912] x20: 0000000000000001 x19: ffff0000c12b8000 x18: ffffffffffffffff
      [    8.113929] x17: 0000000000000000 x16: 0000000000000000 x15: 0720072007200720
      [    8.113944] x14: 0720072007200720 x13: 0720072007200720 x12: 0720072007200720
      [    8.113958] x11: 0720072007200720 x10: 0000000000f9fca4 x9 : ffff80008021f4e4
      [    8.113991] x8 : 0101010101010101 x7 : 746f72705f6d656d x6 : 000000001e0e0f5f
      [    8.114006] x5 : 000000000001864f x4 : ffff0000c12b8000 x3 : 000000000000001c
      [    8.114020] x2 : 0000000000000002 x1 : 0000000000000000 x0 : 0000000000000000
      [    8.114126] Call trace:
      [    8.114159]  may_access_direct_pkt_data+0x24/0xa0
      [    8.114202]  bpf_check+0x3bc/0x28c0
      [    8.114214]  bpf_prog_load+0x658/0xa58
      [    8.114227]  __sys_bpf+0xc50/0x2250
      [    8.114240]  __arm64_sys_bpf+0x28/0x40
      [    8.114254]  invoke_syscall.constprop.0+0x54/0xf0
      [    8.114273]  do_el0_svc+0x4c/0xd8
      [    8.114289]  el0_svc+0x3c/0x140
      [    8.114305]  el0t_64_sync_handler+0x134/0x150
      [    8.114331]  el0t_64_sync+0x168/0x170
      [    8.114477] Code: 7100707f 54000081 f9401c00 f9403800 (b9400403)
      [    8.118672] ---[ end trace 0000000000000000 ]---
      
      One way to fix it is by forcing `attach_prog_fd` non-empty when
      bpf_prog_load(). But this will lead to `libbpf_probe_bpf_prog_type`
      API broken which use verifier log to probe prog type and will log
      nothing if we reject invalid EXT prog before bpf_check().
      
      Another way is by adding null check in resolve_prog_type().
      
      The issue was introduced by commit 4a9c7bbe ("bpf: Resolve to
      prog->aux->dst_prog->type only for BPF_PROG_TYPE_EXT") which wanted
      to correct type resolution for BPF_PROG_TYPE_TRACING programs. Before
      that, the type resolution of BPF_PROG_TYPE_EXT prog actually follows
      the logic below:
      
        prog->aux->dst_prog ? prog->aux->dst_prog->type : prog->type;
      
      It implies that when EXT program is not yet attached to `dst_prog`,
      the prog type should be EXT itself. This code worked fine in the past.
      So just keep using it.
      
      Fix this by returning `prog->type` for BPF_PROG_TYPE_EXT if `dst_prog`
      is not present in resolve_prog_type().
      
      Fixes: 4a9c7bbe ("bpf: Resolve to prog->aux->dst_prog->type only for BPF_PROG_TYPE_EXT")
      Signed-off-by: default avatarTengda Wu <wutengda@huaweicloud.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Link: https://lore.kernel.org/bpf/20240711145819.254178-2-wutengda@huaweicloud.com
      f7866c35
    • Linus Torvalds's avatar
      Merge tag 'for-6.10-rc7-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux · 975f3b6d
      Linus Torvalds authored
      Pull btrfs fixes from David Sterba:
       "Fix a regression in extent map shrinker behaviour.
      
        In the past weeks we got reports from users that there are huge
        latency spikes or freezes. This was bisected to newly added shrinker
        of extent maps (it was added to fix a build up of the structures in
        memory).
      
        I'm assuming that the freezes would happen to many users after release
        so I'd like to get it merged now so it's in 6.10. Although the diff
        size is not small the changes are relatively straightforward, the
        reporters verified the fixes and we did testing on our side.
      
        The fixes:
      
         - adjust behaviour under memory pressure and check lock or scheduling
           conditions, bail out if needed
      
         - synchronize tracking of the scanning progress so inode ranges are
           not skipped or work duplicated
      
         - do a delayed iput when scanning a root so evicting an inode does
           not slow things down in case of lots of dirty data, also fix
           lockdep warning, a deadlock could happen when writing the dirty
           data would need to start a transaction"
      
      * tag 'for-6.10-rc7-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
        btrfs: avoid races when tracking progress for extent map shrinking
        btrfs: stop extent map shrinker if reschedule is needed
        btrfs: use delayed iput during extent map shrinking
      975f3b6d
    • Linus Torvalds's avatar
      Merge tag 'ceph-for-6.10-rc8' of https://github.com/ceph/ceph-client · a52ff901
      Linus Torvalds authored
      Pull ceph fixes from Ilya Dryomov:
       "A fix for a possible use-after-free following "rbd unmap" or "umount"
        marked for stable and two kernel-doc fixups"
      
      * tag 'ceph-for-6.10-rc8' of https://github.com/ceph/ceph-client:
        libceph: fix crush_choose_firstn() kernel-doc warnings
        libceph: suppress crush_choose_indep() kernel-doc warnings
        libceph: fix race between delayed_work() and ceph_monc_stop()
      a52ff901
    • Linus Torvalds's avatar
      Merge tag 'pmdomain-v6.10-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/linux-pm · ac6a9e07
      Linus Torvalds authored
      Pull pmdomain fix from Ulf Hansson:
      
       - qcom: Skip retention level for rpmhpd's
      
      * tag 'pmdomain-v6.10-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/linux-pm:
        pmdomain: qcom: rpmhpd: Skip retention level for Power Domains
      ac6a9e07
    • Linus Torvalds's avatar
      Merge tag 'mmc-v6.10-rc4-2' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc · 01ec3bb6
      Linus Torvalds authored
      Pull MMC host fixes from Ulf Hansson:
      
       - davinci_mmc: Prevent transmitted data size from exceeding sgm's
         length
      
       - sdhci: Fix max_seg_size for 64KiB PAGE_SIZE
      
      * tag 'mmc-v6.10-rc4-2' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc:
        mmc: davinci_mmc: Prevent transmitted data size from exceeding sgm's length
        mmc: sdhci: Fix max_seg_size for 64KiB PAGE_SIZE
      01ec3bb6
    • Daniel Borkmann's avatar
      selftests/bpf: DENYLIST.aarch64: Skip fexit_sleep again · 517125f6
      Daniel Borkmann authored
      Revert commit 90dc9460 ("selftests/bpf: DENYLIST.aarch64: Remove
      fexit_sleep") again. The fix in 19d3c179 ("bpf, arm64: Fix trampoline
      for BPF_TRAMP_F_CALL_ORIG") does not address all of the issues and BPF
      CI is still hanging and timing out:
      
         https://github.com/kernel-patches/bpf/actions/runs/9905842936/job/27366435436
      
         [...]
         #89/11   fexit_bpf2bpf/func_replace_global_func:OK
         #89/12   fexit_bpf2bpf/fentry_to_cgroup_bpf:OK
         #89/13   fexit_bpf2bpf/func_replace_progmap:OK
         #89      fexit_bpf2bpf:OK
         Error: The operation was canceled.
      
      Thus more investigation work & fixing is needed before the test can be put
      in place again.
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Cc: Puranjay Mohan <puranjay@kernel.org>
      Link: https://lore.kernel.org/bpf/20240705145009.32340-1-puranjay@kernel.org
      517125f6
    • Linus Torvalds's avatar
      Merge tag 'arm-fixes-6.10-3' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc · e091caf9
      Linus Torvalds authored
      Pull ARM SoC fixes from Arnd Bergmann:
       "Most of these changes are Qualcomm SoC specific and came in just after
        I sent out the last set of fixes. This includes two regression fixes
        for SoC drivers, a defconfig change to ensure the Lenovo X13s is
        usable and 11 changes to DT files to fix regressions and minor
        platform specific issues.
      
        Tony and Chunyan step back from their respective maintainership roles
        on the omap and unisoc platforms, and Christophe in turn takes over
        maintaining some of the Freescale SoC drivers that he has been taking
        care of in practice already.
      
        Lastly, there are two trivial fixes for the davinci and sunxi
        platforms"
      
      * tag 'arm-fixes-6.10-3' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc:
        MAINTAINERS: Update FREESCALE SOC DRIVERS and QUICC ENGINE LIBRARY
        MAINTAINERS: Add more maintainers for omaps
        ARM: davinci: Convert comma to semicolon
        MAINTAINERS: Move myself from SPRD Maintainer to Reviewer
        Revert "dt-bindings: cache: qcom,llcc: correct QDU1000 reg entries"
        arm64: dts: qcom: qdu1000: Fix LLCC reg property
        arm64: dts: qcom: sm6115: add iommu for sdhc_1
        arm64: dts: qcom: x1e80100-crd: fix DAI used for headset recording
        arm64: dts: qcom: x1e80100-crd: fix WCD audio codec TX port mapping
        soc: qcom: pmic_glink: disable UCSI on sc8280xp
        arm64: defconfig: enable Elan i2c-hid driver
        arm64: dts: qcom: sc8280xp-crd: use external pull up for touch reset
        arm64: dts: qcom: sc8280xp-x13s: fix touchscreen power on
        arm64: dts: qcom: x1e80100: Fix PCIe 6a reg offsets and add MHI
        arm64: dts: qcom: sa8775p: Correct IRQ number of EL2 non-secure physical timer
        arm64: dts: allwinner: Fix PMIC interrupt number
        arm64: dts: qcom: sc8280xp: Set status = "reserved" on PSHOLD
        arm64: dts: qcom: x1e80100-*: Allocate some CMA buffers
        arm64: dts: qcom: sc8180x: Fix LLCC reg property again
      e091caf9
    • Alexei Starovoitov's avatar
      Merge branch 'use-overflow-h-helpers-to-check-for-overflows' · a1010fce
      Alexei Starovoitov authored
      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 <https://lore.kernel.org/r/20240701055907.82481-1-shung-hsi.yu@suse.com>
      - add fix for 5337ac4c ("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 5337ac4c ("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 <https://lore.kernel.org/r/20240623070324.12634-1-shung-hsi.yu@suse.com>:
      - 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.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      a1010fce
    • Shung-Hsi Yu's avatar
      bpf: use check_sub_overflow() to check for subtraction overflows · deac5871
      Shung-Hsi Yu authored
      Similar to previous patch that drops signed_add*_overflows() and uses
      (compiler) builtin-based check_add_overflow(), do the same for
      signed_sub*_overflows() and replace them with the generic
      check_sub_overflow() to make future refactoring easier and have the
      checks implemented more efficiently.
      
      Unsigned overflow check for subtraction does not use helpers and are
      simple enough already, so they're left untouched.
      
      After the change GCC 13.3.0 generates cleaner assembly on x86_64:
      
      	if (check_sub_overflow(*dst_smin, src_reg->smax_value, dst_smin) ||
         139bf:	mov    0x28(%r12),%rax
         139c4:	mov    %edx,0x54(%r12)
         139c9:	sub    %r11,%rax
         139cc:	mov    %rax,0x28(%r12)
         139d1:	jo     14627 <adjust_reg_min_max_vals+0x1237>
      	    check_sub_overflow(*dst_smax, src_reg->smin_value, dst_smax)) {
         139d7:	mov    0x30(%r12),%rax
         139dc:	sub    %r9,%rax
         139df:	mov    %rax,0x30(%r12)
      	if (check_sub_overflow(*dst_smin, src_reg->smax_value, dst_smin) ||
         139e4:	jo     14627 <adjust_reg_min_max_vals+0x1237>
         ...
      		*dst_smin = S64_MIN;
         14627:	movabs $0x8000000000000000,%rax
         14631:	mov    %rax,0x28(%r12)
      		*dst_smax = S64_MAX;
         14636:	sub    $0x1,%rax
         1463a:	mov    %rax,0x30(%r12)
      
      Before the change it gives:
      
      	if (signed_sub_overflows(dst_reg->smin_value, smax_val) ||
         13a50:	mov    0x28(%r12),%rdi
         13a55:	mov    %edx,0x54(%r12)
      		dst_reg->smax_value = S64_MAX;
         13a5a:	movabs $0x7fffffffffffffff,%rdx
         13a64:	mov    %eax,0x50(%r12)
      		dst_reg->smin_value = S64_MIN;
         13a69:	movabs $0x8000000000000000,%rax
      	s64 res = (s64)((u64)a - (u64)b);
         13a73:	mov    %rdi,%rsi
         13a76:	sub    %rcx,%rsi
      	if (b < 0)
         13a79:	test   %rcx,%rcx
         13a7c:	js     145ea <adjust_reg_min_max_vals+0x119a>
      	if (signed_sub_overflows(dst_reg->smin_value, smax_val) ||
         13a82:	cmp    %rsi,%rdi
         13a85:	jl     13ac7 <adjust_reg_min_max_vals+0x677>
      	    signed_sub_overflows(dst_reg->smax_value, smin_val)) {
         13a87:	mov    0x30(%r12),%r8
      	s64 res = (s64)((u64)a - (u64)b);
         13a8c:	mov    %r8,%rax
         13a8f:	sub    %r9,%rax
      	return res > a;
         13a92:	cmp    %rax,%r8
         13a95:	setl   %sil
      	if (b < 0)
         13a99:	test   %r9,%r9
         13a9c:	js     147d1 <adjust_reg_min_max_vals+0x1381>
      		dst_reg->smax_value = S64_MAX;
         13aa2:	movabs $0x7fffffffffffffff,%rdx
      		dst_reg->smin_value = S64_MIN;
         13aac:	movabs $0x8000000000000000,%rax
      	if (signed_sub_overflows(dst_reg->smin_value, smax_val) ||
         13ab6:	test   %sil,%sil
         13ab9:	jne    13ac7 <adjust_reg_min_max_vals+0x677>
      		dst_reg->smin_value -= smax_val;
         13abb:	mov    %rdi,%rax
      		dst_reg->smax_value -= smin_val;
         13abe:	mov    %r8,%rdx
      		dst_reg->smin_value -= smax_val;
         13ac1:	sub    %rcx,%rax
      		dst_reg->smax_value -= smin_val;
         13ac4:	sub    %r9,%rdx
         13ac7:	mov    %rax,0x28(%r12)
         ...
         13ad1:	mov    %rdx,0x30(%r12)
         ...
      	if (signed_sub_overflows(dst_reg->smin_value, smax_val) ||
         145ea:	cmp    %rsi,%rdi
         145ed:	jg     13ac7 <adjust_reg_min_max_vals+0x677>
         145f3:	jmp    13a87 <adjust_reg_min_max_vals+0x637>
      Suggested-by: default avatarJiri Olsa <jolsa@kernel.org>
      Signed-off-by: default avatarShung-Hsi Yu <shung-hsi.yu@suse.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Link: https://lore.kernel.org/r/20240712080127.136608-4-shung-hsi.yu@suse.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      deac5871
    • Shung-Hsi Yu's avatar
      bpf: use check_add_overflow() to check for addition overflows · 28a44110
      Shung-Hsi Yu authored
      signed_add*_overflows() was added back when there was no overflow-check
      helper. With the introduction of such helpers in commit f0907827
      ("compiler.h: enable builtin overflow checkers and add fallback code"), we
      can drop signed_add*_overflows() in kernel/bpf/verifier.c and use the
      generic check_add_overflow() instead.
      
      This will make future refactoring easier, and takes advantage of
      compiler-emitted hardware instructions that efficiently implement these
      checks.
      
      After the change GCC 13.3.0 generates cleaner assembly on x86_64:
      
      	err = adjust_scalar_min_max_vals(env, insn, dst_reg, *src_reg);
         13625:	mov    0x28(%rbx),%r9  /*  r9 = src_reg->smin_value */
         13629:	mov    0x30(%rbx),%rcx /* rcx = src_reg->smax_value */
         ...
      	if (check_add_overflow(*dst_smin, src_reg->smin_value, dst_smin) ||
         141c1:	mov    %r9,%rax
         141c4:	add    0x28(%r12),%rax
         141c9:	mov    %rax,0x28(%r12)
         141ce:	jo     146e4 <adjust_reg_min_max_vals+0x1294>
      	    check_add_overflow(*dst_smax, src_reg->smax_value, dst_smax)) {
         141d4:	add    0x30(%r12),%rcx
         141d9:	mov    %rcx,0x30(%r12)
      	if (check_add_overflow(*dst_smin, src_reg->smin_value, dst_smin) ||
         141de:	jo     146e4 <adjust_reg_min_max_vals+0x1294>
         ...
      		*dst_smin = S64_MIN;
         146e4:	movabs $0x8000000000000000,%rax
         146ee:	mov    %rax,0x28(%r12)
      		*dst_smax = S64_MAX;
         146f3:	sub    $0x1,%rax
         146f7:	mov    %rax,0x30(%r12)
      
      Before the change it gives:
      
      	s64 smin_val = src_reg->smin_value;
           675:	mov    0x28(%rsi),%r8
      	s64 smax_val = src_reg->smax_value;
      	u64 umin_val = src_reg->umin_value;
      	u64 umax_val = src_reg->umax_value;
           679:	mov    %rdi,%rax /* rax = dst_reg */
      	if (signed_add_overflows(dst_reg->smin_value, smin_val) ||
           67c:	mov    0x28(%rdi),%rdi /* rdi = dst_reg->smin_value */
      	u64 umin_val = src_reg->umin_value;
           680:	mov    0x38(%rsi),%rdx
      	u64 umax_val = src_reg->umax_value;
           684:	mov    0x40(%rsi),%rcx
      	s64 res = (s64)((u64)a + (u64)b);
           688:	lea    (%r8,%rdi,1),%r9 /* r9 = dst_reg->smin_value + src_reg->smin_value */
      	return res < a;
           68c:	cmp    %r9,%rdi
           68f:	setg   %r10b /* r10b = (dst_reg->smin_value + src_reg->smin_value) > dst_reg->smin_value */
      	if (b < 0)
           693:	test   %r8,%r8
           696:	js     72b <scalar_min_max_add+0xbb>
      	    signed_add_overflows(dst_reg->smax_value, smax_val)) {
      		dst_reg->smin_value = S64_MIN;
      		dst_reg->smax_value = S64_MAX;
           69c:	movabs $0x7fffffffffffffff,%rdi
      	s64 smax_val = src_reg->smax_value;
           6a6:	mov    0x30(%rsi),%r8
      		dst_reg->smin_value = S64_MIN;
           6aa:	00 00 00 	movabs $0x8000000000000000,%rsi
      	if (signed_add_overflows(dst_reg->smin_value, smin_val) ||
           6b4:	test   %r10b,%r10b /* (dst_reg->smin_value + src_reg->smin_value) > dst_reg->smin_value ? goto 6cb */
           6b7:	jne    6cb <scalar_min_max_add+0x5b>
      	    signed_add_overflows(dst_reg->smax_value, smax_val)) {
           6b9:	mov    0x30(%rax),%r10   /* r10 = dst_reg->smax_value */
      	s64 res = (s64)((u64)a + (u64)b);
           6bd:	lea    (%r10,%r8,1),%r11 /* r11 = dst_reg->smax_value + src_reg->smax_value */
      	if (b < 0)
           6c1:	test   %r8,%r8
           6c4:	js     71e <scalar_min_max_add+0xae>
      	if (signed_add_overflows(dst_reg->smin_value, smin_val) ||
           6c6:	cmp    %r11,%r10 /* (dst_reg->smax_value + src_reg->smax_value) <= dst_reg->smax_value ? goto 723 */
           6c9:	jle    723 <scalar_min_max_add+0xb3>
      	} else {
      		dst_reg->smin_value += smin_val;
      		dst_reg->smax_value += smax_val;
      	}
           6cb:	mov    %rsi,0x28(%rax)
           ...
           6d5:	mov    %rdi,0x30(%rax)
           ...
      	if (signed_add_overflows(dst_reg->smin_value, smin_val) ||
           71e:	cmp    %r11,%r10
           721:	jl     6cb <scalar_min_max_add+0x5b>
      		dst_reg->smin_value += smin_val;
           723:	mov    %r9,%rsi
      		dst_reg->smax_value += smax_val;
           726:	mov    %r11,%rdi
           729:	jmp    6cb <scalar_min_max_add+0x5b>
      		return res > a;
           72b:	cmp    %r9,%rdi
           72e:	setl   %r10b
           732:	jmp    69c <scalar_min_max_add+0x2c>
           737:	nopw   0x0(%rax,%rax,1)
      
      Note: unlike adjust_ptr_min_max_vals() and scalar*_min_max_add(), it is
      necessary to introduce intermediate variable in adjust_jmp_off() to keep
      the functional behavior unchanged. Without an intermediate variable
      imm/off will be altered even on overflow.
      Suggested-by: default avatarJiri Olsa <jolsa@kernel.org>
      Signed-off-by: default avatarShung-Hsi Yu <shung-hsi.yu@suse.com>
      Link: https://lore.kernel.org/r/20240712080127.136608-3-shung-hsi.yu@suse.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      28a44110
    • Shung-Hsi Yu's avatar
      bpf: fix overflow check in adjust_jmp_off() · 4a04b4f0
      Shung-Hsi Yu authored
      adjust_jmp_off() incorrectly used the insn->imm field for all overflow check,
      which is incorrect as that should only be done or the BPF_JMP32 | BPF_JA case,
      not the general jump instruction case. Fix it by using insn->off for overflow
      check in the general case.
      
      Fixes: 5337ac4c ("bpf: Fix the corner case with may_goto and jump to the 1st insn.")
      Signed-off-by: default avatarShung-Hsi Yu <shung-hsi.yu@suse.com>
      Link: https://lore.kernel.org/r/20240712080127.136608-2-shung-hsi.yu@suse.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      4a04b4f0
    • Linus Torvalds's avatar
      Merge tag 'char-misc-6.10-final' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc · f469cf96
      Linus Torvalds authored
      Pull char / misc driver fixes from Greg KH:
       "Here are some small remaining driver fixes for 6.10-final that have
        all been in linux-next for a while and resolve reported issues.
        Included in here are:
      
         - mei driver fixes (and a spelling fix at the end just to be clean)
      
         - iio driver fixes for reported problems
      
         - fastrpc bugfixes
      
         - nvmem small fixes"
      
      * tag 'char-misc-6.10-final' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc:
        mei: vsc: Fix spelling error
        mei: vsc: Enhance SPI transfer of IVSC ROM
        mei: vsc: Utilize the appropriate byte order swap function
        mei: vsc: Prevent timeout error with added delay post-firmware download
        mei: vsc: Enhance IVSC chipset stability during warm reboot
        nvmem: core: limit cell sysfs permissions to main attribute ones
        nvmem: core: only change name to fram for current attribute
        nvmem: meson-efuse: Fix return value of nvmem callbacks
        nvmem: rmem: Fix return value of rmem_read()
        misc: microchip: pci1xxxx: Fix return value of nvmem callbacks
        hpet: Support 32-bit userspace
        misc: fastrpc: Restrict untrusted app to attach to privileged PD
        misc: fastrpc: Fix ownership reassignment of remote heap
        misc: fastrpc: Fix memory leak in audio daemon attach operation
        misc: fastrpc: Avoid updating PD type for capability request
        misc: fastrpc: Copy the complete capability structure to user
        misc: fastrpc: Fix DSP capabilities request
        iio: light: apds9306: Fix error handing
        iio: trigger: Fix condition for own trigger
      f469cf96
    • Linus Torvalds's avatar
      Merge tag 'tty-6.10-final' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty · 1cb67bcc
      Linus Torvalds authored
      Pull tty / serial fixes from Greg KH:
       "Here are some small serial driver fixes for 6.10-final. Included in
        here are:
      
         - qcom-geni fixes for a much much much discussed issue and everyone
           now seems to be agreed that this is the proper way forward to
           resolve the reported lockups
      
         - imx serial driver bugfixes
      
         - 8250_omap errata fix
      
         - ma35d1 serial driver bugfix
      
        All of these have been in linux-next for over a week with no reported
        issues"
      
      * tag 'tty-6.10-final' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty:
        serial: qcom-geni: do not kill the machine on fifo underrun
        serial: qcom-geni: fix hard lockup on buffer flush
        serial: qcom-geni: fix soft lockup on sw flow control and suspend
        serial: imx: ensure RTS signal is not left active after shutdown
        tty: serial: ma35d1: Add a NULL check for of_node
        serial: 8250_omap: Fix Errata i2310 with RX FIFO level check
        serial: imx: only set receiver level if it is zero
      1cb67bcc
    • Linus Torvalds's avatar
      Merge tag 'usb-6.10-final' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb · 1293147a
      Linus Torvalds authored
      Pull USB fixes from Greg KH:
       "Here are some small USB driver fixes and new device ids for
        6.10-final. Included in here are:
      
         - new usb-serial device ids for reported devices
      
         - syzbot-triggered duplicate endpoint bugfix
      
         - gadget bugfix for configfs memory overwrite
      
         - xhci resume bugfix
      
         - new device quirk added
      
         - usb core error path bugfix
      
        All of these have been in linux-next (most for a while) with no
        reported issues"
      
      * tag 'usb-6.10-final' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb:
        USB: serial: mos7840: fix crash on resume
        USB: serial: option: add Rolling RW350-GL variants
        USB: serial: option: add support for Foxconn T99W651
        USB: serial: option: add Netprisma LCUK54 series modules
        usb: gadget: configfs: Prevent OOB read/write in usb_string_copy()
        usb: dwc3: pci: add support for the Intel Panther Lake
        usb: core: add missing of_node_put() in usb_of_has_devices_or_graph
        USB: Add USB_QUIRK_NO_SET_INTF quirk for START BP-850k
        USB: core: Fix duplicate endpoint bug by clearing reserved bits in the descriptor
        xhci: always resume roothubs if xHC was reset during resume
        USB: serial: option: add Telit generic core-dump composition
        USB: serial: option: add Fibocom FM350-GL
        USB: serial: option: add Telit FN912 rmnet compositions
      1293147a
    • Linus Torvalds's avatar
      Merge tag 'sound-6.10' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound · 9b48104b
      Linus Torvalds authored
      Pull sound fixes from Takashi Iwai:
       "The majority of changes here are small device-specific fixes for ASoC
        SOF / Intel and usual HD-audio quirks.
      
        The only significant high LOC is found in the Cirrus firmware driver,
        but all those are for hardening against malicious firmware blobs, and
        they look fine for taking as a last minute fix, too"
      
      * tag 'sound-6.10' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound:
        ALSA: hda/realtek: Enable Mute LED on HP 250 G7
        firmware: cs_dsp: Use strnlen() on name fields in V1 wmfw files
        ALSA: hda/realtek: Limit mic boost on VAIO PRO PX
        ALSA: hda: cs35l41: Fix swapped l/r audio channels for Lenovo ThinBook 13x Gen4
        ASoC: SOF: Intel: hda-pcm: Limit the maximum number of periods by MAX_BDL_ENTRIES
        ASoC: rt711-sdw: add missing readable registers
        ASoC: SOF: Intel: hda: fix null deref on system suspend entry
        ALSA: hda/realtek: add quirk for Clevo V5[46]0TU
        firmware: cs_dsp: Prevent buffer overrun when processing V2 alg headers
        firmware: cs_dsp: Validate payload length before processing block
        firmware: cs_dsp: Return error if block header overflows file
        firmware: cs_dsp: Fix overflow checking of wmfw header
      9b48104b
    • Linus Torvalds's avatar
      Merge tag 'bcachefs-2024-07-12' of https://evilpiepirate.org/git/bcachefs · 5d4c8513
      Linus Torvalds authored
      Pull more bcachefs fixes from Kent Overstreet:
      
       - revert the SLAB_ACCOUNT patch, something crazy is going on in memcg
         and someone forgot to test
      
       - minor fixes: missing rcu_read_lock(), scheduling while atomic (in an
         emergency shutdown path)
      
       - two lockdep fixes; these could have gone earlier, but were left to
         bake awhile
      
      * tag 'bcachefs-2024-07-12' of https://evilpiepirate.org/git/bcachefs:
        bcachefs: bch2_gc_btree() should not use btree_root_lock
        bcachefs: Set PF_MEMALLOC_NOFS when trans->locked
        bcachefs; Use trans_unlock_long() when waiting on allocator
        Revert "bcachefs: Mark bch_inode_info as SLAB_ACCOUNT"
        bcachefs: fix scheduling while atomic in break_cycle()
        bcachefs: Fix RCU splat
      5d4c8513