1. 15 Sep, 2023 8 commits
    • Linus Torvalds's avatar
      Merge tag 'firewire-fixes-6.6-rc2' of... · 0e494be7
      Linus Torvalds authored
      Merge tag 'firewire-fixes-6.6-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394
      
      Pull firewire fix from Takashi Sakamoto:
       "A change applied to v6.5 kernel brings an issue that usual GFP
        allocation is done in atomic context under acquired spin-lock. Let us
        revert it"
      
      * tag 'firewire-fixes-6.6-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394:
        Revert "firewire: core: obsolete usage of GFP_ATOMIC at building node tree"
      0e494be7
    • Linus Torvalds's avatar
      Merge tag 'drm-fixes-2023-09-15' of git://anongit.freedesktop.org/drm/drm · 9608c7b7
      Linus Torvalds authored
      Pull drm fixes from Dave Airlie:
       "Regular rc2 fixes pull, mostly made up of amdgpu stuff, one i915, and
        a bunch of others, one vkms locking violation is reverted.
      
        connector:
         - doc fix
      
        exec:
         - workaround lockdep issue
      
        tests:
         - fix a UAF
      
        vkms:
         - revert hrtimer fix
      
        fbdev:
         - g364fb: fix build failure with mips
      
        i915:
         - Only check eDP HPD when AUX CH is shared.
      
        amdgpu:
         - GC 9.4.3 fixes
         - Fix white screen issues with S/G display on system with >= 64G of ram
         - Replay fixes
         - SMU 13.0.6 fixes
         - AUX backlight fix
         - NBIO 4.3 SR-IOV fixes for HDP
         - RAS fixes
         - DP MST resume fix
         - Fix segfault on systems with no vbios
         - DPIA fixes
      
        amdkfd:
         - CWSR grace period fix
         - Unaligned doorbell fix
         - CRIU fix for GFX11
         - Add missing TLB flush on gfx10 and newer
      
        radeon:
         - make fence wait in suballocator uninterrruptable
      
        gm12u320:
         - Fix the timeout usage for usb_bulk_msg()"
      
      * tag 'drm-fixes-2023-09-15' of git://anongit.freedesktop.org/drm/drm: (29 commits)
        drm/tests: helpers: Avoid a driver uaf
        Revert "drm/vkms: Fix race-condition between the hrtimer and the atomic commit"
        drm/amdkfd: Insert missing TLB flush on GFX10 and later
        drm/i915: Only check eDP HPD when AUX CH is shared
        drm/amd/display: Fix 2nd DPIA encoder Assignment
        drm/amd/display: Add DPIA Link Encoder Assignment Fix
        drm/amd/display: fix replay_mode kernel-doc warning
        drm/amdgpu: Handle null atom context in VBIOS info ioctl
        drm/amdkfd: Checkpoint and restore queues on GFX11
        drm/amd/display: Adjust the MST resume flow
        drm/amdgpu: fallback to old RAS error message for aqua_vanjaram
        drm/amdgpu/nbio4.3: set proper rmmio_remap.reg_offset for SR-IOV
        drm/amdgpu/soc21: don't remap HDP registers for SR-IOV
        drm/amd/display: Don't check registers, if using AUX BL control
        drm/amdgpu: fix retry loop test
        drm/amd/display: Add dirty rect support for Replay
        Revert "drm/amd: Disable S/G for APUs when 64GB or more host memory"
        drm/amd/display: fix the white screen issue when >= 64GB DRAM
        drm/amdkfd: Update CU masking for GFX 9.4.3
        drm/amdkfd: Update cache info reporting for GFX v9.4.3
        ...
      9608c7b7
    • Linus Torvalds's avatar
      Merge tag 'efi-fixes-for-v6.6-1' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi · e42bebf6
      Linus Torvalds authored
      Pull EFI fixes from Ard Biesheuvel:
      
       - Missing x86 patch for the runtime cleanup that was merged in -rc1
      
       - Kconfig tweak for kexec on x86 so EFI support does not get disabled
         inadvertently
      
       - Use the right EFI memory type for the unaccepted memory table so
         kexec/kdump exposes it to the crash kernel as well
      
       - Work around EFI implementations which do not implement
         QueryVariableInfo, which is now called by statfs() on efivarfs
      
      * tag 'efi-fixes-for-v6.6-1' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi:
        efivarfs: fix statfs() on efivarfs
        efi/unaccepted: Use ACPI reclaim memory for unaccepted memory table
        efi/x86: Ensure that EFI_RUNTIME_MAP is enabled for kexec
        efi/x86: Move EFI runtime call setup/teardown helpers out of line
      e42bebf6
    • Linus Torvalds's avatar
      Merge tag 'selinux-pr-20230914' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux · 02e768c9
      Linus Torvalds authored
      Pull selinux fix from Paul Moore:
       "A relatively small SELinux patch to fix an issue with a
        vfs/LSM/SELinux patch that went upstream during the recent merge
        window.
      
        The short version is that the original patch changed how we
        initialized mount options to resolve a NFS issue and we inadvertently
        broke a use case due to the changed behavior.
      
        The fix restores this behavior for the cases that require it while
        keeping the original NFS fix in place"
      
      * tag 'selinux-pr-20230914' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux:
        selinux: fix handling of empty opts in selinux_fs_context_submount()
      02e768c9
    • Linus Torvalds's avatar
      Merge tag 'riscv-for-linus-6.6-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux · 82210979
      Linus Torvalds authored
      Pull RISC-V fixes from Palmer Dabbelt:
      
       - A fix to align kexec'd kernels to PMD boundries
      
       - The T-Head dcache.cva encoding was incorrect, it has been fixed to
         invalidate all caches (as opposed to just the L1)
      
      * tag 'riscv-for-linus-6.6-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
        riscv: errata: fix T-Head dcache.cva encoding
        riscv: kexec: Align the kexeced kernel entry
      82210979
    • Takashi Sakamoto's avatar
      Revert "firewire: core: obsolete usage of GFP_ATOMIC at building node tree" · 3c70de9b
      Takashi Sakamoto authored
      This reverts commit 06f45435.
      
      John Ogness reports the case that the allocation is in atomic context under
      acquired spin-lock.
      
      [   12.555784] BUG: sleeping function called from invalid context at include/linux/sched/mm.h:306
      [   12.555808] in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 70, name: kworker/1:2
      [   12.555814] preempt_count: 1, expected: 0
      [   12.555820] INFO: lockdep is turned off.
      [   12.555824] irq event stamp: 208
      [   12.555828] hardirqs last  enabled at (207): [<c00000000111e414>] ._raw_spin_unlock_irq+0x44/0x80
      [   12.555850] hardirqs last disabled at (208): [<c00000000110ff94>] .__schedule+0x854/0xfe0
      [   12.555859] softirqs last  enabled at (188): [<c000000000f73504>] .addrconf_verify_rtnl+0x2c4/0xb70
      [   12.555872] softirqs last disabled at (182): [<c000000000f732b0>] .addrconf_verify_rtnl+0x70/0xb70
      [   12.555884] CPU: 1 PID: 70 Comm: kworker/1:2 Tainted: G S                 6.6.0-rc1 #1
      [   12.555893] Hardware name: PowerMac7,2 PPC970 0x390202 PowerMac
      [   12.555898] Workqueue: firewire_ohci .bus_reset_work [firewire_ohci]
      [   12.555939] Call Trace:
      [   12.555944] [c000000009677830] [c0000000010d83c0] .dump_stack_lvl+0x8c/0xd0 (unreliable)
      [   12.555963] [c0000000096778b0] [c000000000140270] .__might_resched+0x320/0x340
      [   12.555978] [c000000009677940] [c000000000497600] .__kmem_cache_alloc_node+0x390/0x460
      [   12.555993] [c000000009677a10] [c0000000003fe620] .__kmalloc+0x70/0x310
      [   12.556007] [c000000009677ac0] [c0003d00004e2268] .fw_core_handle_bus_reset+0x2c8/0xba0 [firewire_core]
      [   12.556060] [c000000009677c20] [c0003d0000491190] .bus_reset_work+0x330/0x9b0 [firewire_ohci]
      [   12.556079] [c000000009677d10] [c00000000011d0d0] .process_one_work+0x280/0x6f0
      [   12.556094] [c000000009677e10] [c00000000011d8a0] .worker_thread+0x360/0x500
      [   12.556107] [c000000009677ef0] [c00000000012e3b4] .kthread+0x154/0x160
      [   12.556120] [c000000009677f90] [c00000000000bfa8] .start_kernel_thread+0x10/0x14
      
      Cc: stable@kernel.org
      Reported-by: default avatarJohn Ogness <john.ogness@linutronix.de>
      Link: https://lore.kernel.org/lkml/87jzsuv1xk.fsf@jogness.linutronix.de/rawSigned-off-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
      3c70de9b
    • Dave Airlie's avatar
      Merge tag 'drm-misc-fixes-2023-09-14' of git://anongit.freedesktop.org/drm/drm-misc into drm-fixes · c3c9acb8
      Dave Airlie authored
      Short summary of fixes pull:
      
       * radeon: Uninterruptible fence waiting
       * tests: Fix use-after-free bug
       * vkms: Revert hrtimer fix
      Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
      
      From: Thomas Zimmermann <tzimmermann@suse.de>
      Link: https://patchwork.freedesktop.org/patch/msgid/20230914122649.GA28252@linux-uq9g
      c3c9acb8
    • Dave Airlie's avatar
      Merge tag 'drm-intel-fixes-2023-09-14' of... · c6fbd2b0
      Dave Airlie authored
      Merge tag 'drm-intel-fixes-2023-09-14' of git://anongit.freedesktop.org/drm/drm-intel into drm-fixes
      
      - Only check eDP HPD when AUX CH is shared.
      Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
      
      From: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/ZQL+NqtIZH5F/Nxr@intel.com
      c6fbd2b0
  2. 14 Sep, 2023 9 commits
    • Dave Airlie's avatar
      Merge tag 'amd-drm-fixes-6.6-2023-09-13' of... · 1216d491
      Dave Airlie authored
      Merge tag 'amd-drm-fixes-6.6-2023-09-13' of https://gitlab.freedesktop.org/agd5f/linux into drm-fixes
      
      amd-drm-fixes-6.6-2023-09-13:
      
      amdgpu:
      - GC 9.4.3 fixes
      - Fix white screen issues with S/G display on system with >= 64G of ram
      - Replay fixes
      - SMU 13.0.6 fixes
      - AUX backlight fix
      - NBIO 4.3 SR-IOV fixes for HDP
      - RAS fixes
      - DP MST resume fix
      - Fix segfault on systems with no vbios
      - DPIA fixes
      
      amdkfd:
      - CWSR grace period fix
      - Unaligned doorbell fix
      - CRIU fix for GFX11
      - Add missing TLB flush on gfx10 and newer
      Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
      
      From: Alex Deucher <alexander.deucher@amd.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20230913195009.7714-1-alexander.deucher@amd.com
      1216d491
    • Linus Torvalds's avatar
      Merge tag 'net-6.6-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net · 9fdfb15a
      Linus Torvalds authored
      Pull networking fixes from Paolo Abeni:
       "Quite unusually, this does not contains any fix coming from subtrees
        (nf, ebpf, wifi, etc).
      
        Current release - regressions:
      
         - bcmasp: fix possible OOB write in bcmasp_netfilt_get_all_active()
      
        Previous releases - regressions:
      
         - ipv4: fix one memleak in __inet_del_ifa()
      
         - tcp: fix bind() regressions for v4-mapped-v6 addresses.
      
         - tls: do not free tls_rec on async operation in
           bpf_exec_tx_verdict()
      
         - dsa: fixes for SJA1105 FDB regressions
      
         - veth: update XDP feature set when bringing up device
      
         - igb: fix hangup when enabling SR-IOV
      
        Previous releases - always broken:
      
         - kcm: fix memory leak in error path of kcm_sendmsg()
      
         - smc: fix data corruption in smcr_port_add
      
         - microchip: fix possible memory leak for vcap_dup_rule()"
      
      * tag 'net-6.6-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (37 commits)
        kcm: Fix error handling for SOCK_DGRAM in kcm_sendmsg().
        net: renesas: rswitch: Add spin lock protection for irq {un}mask
        net: renesas: rswitch: Fix unmasking irq condition
        igb: clean up in all error paths when enabling SR-IOV
        ixgbe: fix timestamp configuration code
        selftest: tcp: Add v4-mapped-v6 cases in bind_wildcard.c.
        selftest: tcp: Move expected_errno into each test case in bind_wildcard.c.
        selftest: tcp: Fix address length in bind_wildcard.c.
        tcp: Fix bind() regression for v4-mapped-v6 non-wildcard address.
        tcp: Fix bind() regression for v4-mapped-v6 wildcard address.
        tcp: Factorise sk_family-independent comparison in inet_bind2_bucket_match(_addr_any).
        ipv6: fix ip6_sock_set_addr_preferences() typo
        veth: Update XDP feature set when bringing up device
        net: macb: fix sleep inside spinlock
        net/tls: do not free tls_rec on async operation in bpf_exec_tx_verdict()
        net: ethernet: mtk_eth_soc: fix pse_port configuration for MT7988
        net: ethernet: mtk_eth_soc: fix uninitialized variable
        kcm: Fix memory leak in error path of kcm_sendmsg()
        r8152: check budget for r8152_poll()
        net: dsa: sja1105: block FDB accesses that are concurrent with a switch reset
        ...
      9fdfb15a
    • Daniel Vetter's avatar
      Merge tag 'drm-misc-fixes-2023-09-07' of git://anongit.freedesktop.org/drm/drm-misc into drm-fixes · 15794f9d
      Daniel Vetter authored
      One doc fix for drm/connector, one fix for amdgpu for an crash when
      VRAM usage is high, and one fix in gm12u320 to fix the timeout units in
      the code
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      From: Maxime Ripard <mripard@redhat.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/w5nlld5ukeh6bgtljsxmkex3e7s7f4qquuqkv5lv4cv3uxzwqr@pgokpejfsyef
      15794f9d
    • Thomas Hellström's avatar
      drm/tests: helpers: Avoid a driver uaf · 139a2785
      Thomas Hellström authored
      when using __drm_kunit_helper_alloc_drm_device() the driver may be
      dereferenced by device-managed resources up until the device is
      freed, which is typically later than the kunit-managed resource code
      frees it. Fix this by simply make the driver device-managed as well.
      
      In short, the sequence leading to the UAF is as follows:
      
      INIT:
      Code allocates a struct device as a kunit-managed resource.
      Code allocates a drm driver as a kunit-managed resource.
      Code allocates a drm device as a device-managed resource.
      
      EXIT:
      Kunit resource cleanup frees the drm driver
      Kunit resource cleanup puts the struct device, which starts a
            device-managed resource cleanup
      device-managed cleanup calls drm_dev_put()
      drm_dev_put() dereferences the (now freed) drm driver -> Boom.
      
      Related KASAN message:
      [55272.551542] ==================================================================
      [55272.551551] BUG: KASAN: slab-use-after-free in drm_dev_put.part.0+0xd4/0xe0 [drm]
      [55272.551603] Read of size 8 at addr ffff888127502828 by task kunit_try_catch/10353
      
      [55272.551612] CPU: 4 PID: 10353 Comm: kunit_try_catch Tainted: G     U           N 6.5.0-rc7+ #155
      [55272.551620] Hardware name: ASUS System Product Name/PRIME B560M-A AC, BIOS 0403 01/26/2021
      [55272.551626] Call Trace:
      [55272.551629]  <TASK>
      [55272.551633]  dump_stack_lvl+0x57/0x90
      [55272.551639]  print_report+0xcf/0x630
      [55272.551645]  ? _raw_spin_lock_irqsave+0x5f/0x70
      [55272.551652]  ? drm_dev_put.part.0+0xd4/0xe0 [drm]
      [55272.551694]  kasan_report+0xd7/0x110
      [55272.551699]  ? drm_dev_put.part.0+0xd4/0xe0 [drm]
      [55272.551742]  drm_dev_put.part.0+0xd4/0xe0 [drm]
      [55272.551783]  devres_release_all+0x15d/0x1f0
      [55272.551790]  ? __pfx_devres_release_all+0x10/0x10
      [55272.551797]  device_unbind_cleanup+0x16/0x1a0
      [55272.551802]  device_release_driver_internal+0x3e5/0x540
      [55272.551808]  ? kobject_put+0x5d/0x4b0
      [55272.551814]  bus_remove_device+0x1f1/0x3f0
      [55272.551819]  device_del+0x342/0x910
      [55272.551826]  ? __pfx_device_del+0x10/0x10
      [55272.551830]  ? lock_release+0x339/0x5e0
      [55272.551836]  ? kunit_remove_resource+0x128/0x290 [kunit]
      [55272.551845]  ? __pfx_lock_release+0x10/0x10
      [55272.551851]  platform_device_del.part.0+0x1f/0x1e0
      [55272.551856]  ? _raw_spin_unlock_irqrestore+0x30/0x60
      [55272.551863]  kunit_remove_resource+0x195/0x290 [kunit]
      [55272.551871]  ? _raw_spin_unlock_irqrestore+0x30/0x60
      [55272.551877]  kunit_cleanup+0x78/0x120 [kunit]
      [55272.551885]  ? __kthread_parkme+0xc1/0x1f0
      [55272.551891]  ? __pfx_kunit_try_run_case_cleanup+0x10/0x10 [kunit]
      [55272.551900]  ? __pfx_kunit_generic_run_threadfn_adapter+0x10/0x10 [kunit]
      [55272.551909]  kunit_generic_run_threadfn_adapter+0x4a/0x90 [kunit]
      [55272.551919]  kthread+0x2e7/0x3c0
      [55272.551924]  ? __pfx_kthread+0x10/0x10
      [55272.551929]  ret_from_fork+0x2d/0x70
      [55272.551935]  ? __pfx_kthread+0x10/0x10
      [55272.551940]  ret_from_fork_asm+0x1b/0x30
      [55272.551948]  </TASK>
      
      [55272.551953] Allocated by task 10351:
      [55272.551956]  kasan_save_stack+0x1c/0x40
      [55272.551962]  kasan_set_track+0x21/0x30
      [55272.551966]  __kasan_kmalloc+0x8b/0x90
      [55272.551970]  __kmalloc+0x5e/0x160
      [55272.551976]  kunit_kmalloc_array+0x1c/0x50 [kunit]
      [55272.551984]  drm_exec_test_init+0xfa/0x2c0 [drm_exec_test]
      [55272.551991]  kunit_try_run_case+0xdd/0x250 [kunit]
      [55272.551999]  kunit_generic_run_threadfn_adapter+0x4a/0x90 [kunit]
      [55272.552008]  kthread+0x2e7/0x3c0
      [55272.552012]  ret_from_fork+0x2d/0x70
      [55272.552017]  ret_from_fork_asm+0x1b/0x30
      
      [55272.552024] Freed by task 10353:
      [55272.552027]  kasan_save_stack+0x1c/0x40
      [55272.552032]  kasan_set_track+0x21/0x30
      [55272.552036]  kasan_save_free_info+0x27/0x40
      [55272.552041]  __kasan_slab_free+0x106/0x180
      [55272.552046]  slab_free_freelist_hook+0xb3/0x160
      [55272.552051]  __kmem_cache_free+0xb2/0x290
      [55272.552056]  kunit_remove_resource+0x195/0x290 [kunit]
      [55272.552064]  kunit_cleanup+0x78/0x120 [kunit]
      [55272.552072]  kunit_generic_run_threadfn_adapter+0x4a/0x90 [kunit]
      [55272.552080]  kthread+0x2e7/0x3c0
      [55272.552085]  ret_from_fork+0x2d/0x70
      [55272.552089]  ret_from_fork_asm+0x1b/0x30
      
      [55272.552096] The buggy address belongs to the object at ffff888127502800
                      which belongs to the cache kmalloc-512 of size 512
      [55272.552105] The buggy address is located 40 bytes inside of
                      freed 512-byte region [ffff888127502800, ffff888127502a00)
      
      [55272.552115] The buggy address belongs to the physical page:
      [55272.552119] page:00000000af6c70ff refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x127500
      [55272.552127] head:00000000af6c70ff order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0
      [55272.552133] anon flags: 0x17ffffc0010200(slab|head|node=0|zone=2|lastcpupid=0x1fffff)
      [55272.552141] page_type: 0xffffffff()
      [55272.552145] raw: 0017ffffc0010200 ffff888100042c80 0000000000000000 dead000000000001
      [55272.552152] raw: 0000000000000000 0000000080200020 00000001ffffffff 0000000000000000
      [55272.552157] page dumped because: kasan: bad access detected
      
      [55272.552163] Memory state around the buggy address:
      [55272.552167]  ffff888127502700: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
      [55272.552173]  ffff888127502780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
      [55272.552178] >ffff888127502800: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
      [55272.552184]                                   ^
      [55272.552187]  ffff888127502880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
      [55272.552193]  ffff888127502900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
      [55272.552198] ==================================================================
      [55272.552203] Disabling lock debugging due to kernel taint
      
      v2:
      - Update commit message, add Fixes: tag and Cc stable.
      v3:
      - Further commit message updates (Maxime Ripard).
      
      Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Cc: Maxime Ripard <mripard@kernel.org>
      Cc: Thomas Zimmermann <tzimmermann@suse.de>
      Cc: David Airlie <airlied@gmail.com>
      Cc: Daniel Vetter <daniel@ffwll.ch>
      Cc: dri-devel@lists.freedesktop.org
      Cc: stable@vger.kernel.org # v6.3+
      Fixes: d9878031 ("drm/tests: helpers: Allow to pass a custom drm_driver")
      Signed-off-by: default avatarThomas Hellström <thomas.hellstrom@linux.intel.com>
      Reviewed-by: default avatarFrancois Dugast <francois.dugast@intel.com>
      Acked-by: default avatarMaxime Ripard <mripard@kernel.org>
      Link: https://lore.kernel.org/r/20230907135339.7971-2-thomas.hellstrom@linux.intel.comSigned-off-by: default avatarMaxime Ripard <mripard@kernel.org>
      139a2785
    • Maíra Canal's avatar
      Revert "drm/vkms: Fix race-condition between the hrtimer and the atomic commit" · 7908632f
      Maíra Canal authored
      This reverts commit a0e6a017.
      
      Unlocking a mutex in the context of a hrtimer callback is violating mutex
      locking rules, as mutex_unlock() from interrupt context is not permitted.
      
      Link: https://lore.kernel.org/dri-devel/ZQLAc%2FFwkv%2FGiVoK@phenom.ffwll.local/T/#tAcked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: default avatarMaíra Canal <mcanal@igalia.com>
      Signed-off-by: default avatarMaíra Canal <mairacanal@riseup.net>
      Link: https://patchwork.freedesktop.org/patch/msgid/20230914102024.1789154-1-mcanal@igalia.com
      7908632f
    • Kuniyuki Iwashima's avatar
      kcm: Fix error handling for SOCK_DGRAM in kcm_sendmsg(). · a22730b1
      Kuniyuki Iwashima authored
      syzkaller found a memory leak in kcm_sendmsg(), and commit c821a88b
      ("kcm: Fix memory leak in error path of kcm_sendmsg()") suppressed it by
      updating kcm_tx_msg(head)->last_skb if partial data is copied so that the
      following sendmsg() will resume from the skb.
      
      However, we cannot know how many bytes were copied when we get the error.
      Thus, we could mess up the MSG_MORE queue.
      
      When kcm_sendmsg() fails for SOCK_DGRAM, we should purge the queue as we
      do so for UDP by udp_flush_pending_frames().
      
      Even without this change, when the error occurred, the following sendmsg()
      resumed from a wrong skb and the queue was messed up.  However, we have
      yet to get such a report, and only syzkaller stumbled on it.  So, this
      can be changed safely.
      
      Note this does not change SOCK_SEQPACKET behaviour.
      
      Fixes: c821a88b ("kcm: Fix memory leak in error path of kcm_sendmsg()")
      Fixes: ab7ac4eb ("kcm: Kernel Connection Multiplexor module")
      Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Link: https://lore.kernel.org/r/20230912022753.33327-1-kuniyu@amazon.comSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      a22730b1
    • Paolo Abeni's avatar
      Merge branch 'net-renesas-rswitch-fix-a-lot-of-redundant-irq-issue' · 96f7dc69
      Paolo Abeni authored
      Yoshihiro Shimoda says:
      
      ====================
      net: renesas: rswitch: Fix a lot of redundant irq issue
      
      After this patch series was applied, a lot of redundant interrupts
      no longer occur.
      
      For example: when "iperf3 -c <ipaddr> -R" on R-Car S4-8 Spider
       Before the patches are applied: about 800,000 times happened
       After the patches were applied: about 100,000 times happened
      ====================
      
      Link: https://lore.kernel.org/r/20230912014936.3175430-1-yoshihiro.shimoda.uh@renesas.comSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      96f7dc69
    • Yoshihiro Shimoda's avatar
      net: renesas: rswitch: Add spin lock protection for irq {un}mask · c4f922e8
      Yoshihiro Shimoda authored
      Add spin lock protection for irq {un}mask registers' control.
      
      After napi_complete_done() and this protection were applied,
      a lot of redundant interrupts no longer occur.
      
      For example: when "iperf3 -c <ipaddr> -R" on R-Car S4-8 Spider
       Before the patches are applied: about 800,000 times happened
       After the patches were applied: about 100,000 times happened
      
      Fixes: 3590918b ("net: ethernet: renesas: Add support for "Ethernet Switch"")
      Signed-off-by: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      c4f922e8
    • Yoshihiro Shimoda's avatar
      net: renesas: rswitch: Fix unmasking irq condition · e7b1ef29
      Yoshihiro Shimoda authored
      Fix unmasking irq condition by using napi_complete_done(). Otherwise,
      redundant interrupts happen.
      
      Fixes: 3590918b ("net: ethernet: renesas: Add support for "Ethernet Switch"")
      Signed-off-by: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      e7b1ef29
  3. 13 Sep, 2023 14 commits
    • Linus Torvalds's avatar
      Merge tag 'pmdomain-v6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/linux-pm · aed8aee1
      Linus Torvalds authored
      Pull genpm / pmdomain rename from Ulf Hansson:
       "This renames the genpd subsystem to pmdomain.
      
        As discussed on LKML, using 'genpd' as the name of a subsystem isn't
        very self-explanatory and the acronym itself that means Generic PM
        Domain, is known only by a limited group of people.
      
        The suggestion to improve the situation is to rename the subsystem to
        'pmdomain', which there seems to be a good consensus around using.
      
        Ideally it should indicate that its purpose is to manage Power Domains
        or 'PM domains' as we often also use within the Linux Kernel
        terminology"
      
      * tag 'pmdomain-v6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/linux-pm:
        pmdomain: Rename the genpd subsystem to pmdomain
      aed8aee1
    • Linus Torvalds's avatar
      Merge tag 'tpmdd-v6.6-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd · 23f108dc
      Linus Torvalds authored
      Pull tpm fix from Jarkko Sakkinen.
      
      * tag 'tpmdd-v6.6-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd:
        tpm: Fix typo in tpmrm class definition
      23f108dc
    • Linus Torvalds's avatar
      Merge tag 'parisc-for-6.6-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux · 847165d7
      Linus Torvalds authored
      Pull parisc architecture fixes from Helge Deller:
      
       - fix reference to exported symbols for parisc64 [Masahiro Yamada]
      
       - Block-TLB (BTLB) support on 32-bit CPUs
      
       - sparse and build-warning fixes
      
      * tag 'parisc-for-6.6-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux:
        linux/export: fix reference to exported functions for parisc64
        parisc: BTLB: Initialize BTLB tables at CPU startup
        parisc: firmware: Simplify calling non-PA20 functions
        parisc: BTLB: _edata symbol has to be page aligned for BTLB support
        parisc: BTLB: Add BTLB insert and purge firmware function wrappers
        parisc: BTLB: Clear possibly existing BTLB entries
        parisc: Prepare for Block-TLB support on 32-bit kernel
        parisc: shmparam.h: Document aliasing requirements of PA-RISC
        parisc: irq: Make irq_stack_union static to avoid sparse warning
        parisc: drivers: Fix sparse warning
        parisc: iosapic.c: Fix sparse warnings
        parisc: ccio-dma: Fix sparse warnings
        parisc: sba-iommu: Fix sparse warnigs
        parisc: sba: Fix compile warning wrt list of SBA devices
        parisc: sba_iommu: Fix build warning if procfs if disabled
      847165d7
    • Linus Torvalds's avatar
      Merge tag 'trace-v6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace · 99214f67
      Linus Torvalds authored
      Pull tracing fixes from Steven Rostedt:
      
       - Add missing LOCKDOWN checks for eventfs callers
      
         When LOCKDOWN is active for tracing, it causes inconsistent state
         when some functions succeed and others fail.
      
       - Use dput() to free the top level eventfs descriptor
      
         There was a race between accesses and freeing it.
      
       - Fix a long standing bug that eventfs exposed due to changing timings
         by dynamically creating files. That is, If a event file is opened for
         an instance, there's nothing preventing the instance from being
         removed which will make accessing the files cause use-after-free
         bugs.
      
       - Fix a ring buffer race that happens when iterating over the ring
         buffer while writers are active. Check to make sure not to read the
         event meta data if it's beyond the end of the ring buffer sub buffer.
      
       - Fix the print trigger that disappeared because the test to create it
         was looking for the event dir field being filled, but now it has the
         "ef" field filled for the eventfs structure.
      
       - Remove the unused "dir" field from the event structure.
      
       - Fix the order of the trace_dynamic_info as it had it backwards for
         the offset and len fields for which one was for which endianess.
      
       - Fix NULL pointer dereference with eventfs_remove_rec()
      
         If an allocation fails in one of the eventfs_add_*() functions, the
         caller of it in event_subsystem_dir() or event_create_dir() assigns
         the result to the structure. But it's assigning the ERR_PTR and not
         NULL. This was passed to eventfs_remove_rec() which expects either a
         good pointer or a NULL, not ERR_PTR. The fix is to not assign the
         ERR_PTR to the structure, but to keep it NULL on error.
      
       - Fix list_for_each_rcu() to use list_for_each_srcu() in
         dcache_dir_open_wrapper(). One iteration of the code used RCU but
         because it had to call sleepable code, it had to be changed to use
         SRCU, but one of the iterations was missed.
      
       - Fix synthetic event print function to use "as_u64" instead of passing
         in a pointer to the union. To fix big/little endian issues, the u64
         that represented several types was turned into a union to define the
         types properly.
      
      * tag 'trace-v6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
        eventfs: Fix the NULL pointer dereference bug in eventfs_remove_rec()
        tracefs/eventfs: Use list_for_each_srcu() in dcache_dir_open_wrapper()
        tracing/synthetic: Print out u64 values properly
        tracing/synthetic: Fix order of struct trace_dynamic_info
        selftests/ftrace: Fix dependencies for some of the synthetic event tests
        tracing: Remove unused trace_event_file dir field
        tracing: Use the new eventfs descriptor for print trigger
        ring-buffer: Do not attempt to read past "commit"
        tracefs/eventfs: Free top level files on removal
        ring-buffer: Avoid softlockup in ring_buffer_resize()
        tracing: Have event inject files inc the trace array ref count
        tracing: Have option files inc the trace array ref count
        tracing: Have current_trace inc the trace array ref count
        tracing: Have tracing_max_latency inc the trace array ref count
        tracing: Increase trace array ref count on enable and filter files
        tracefs/eventfs: Use dput to free the toplevel events directory
        tracefs/eventfs: Add missing lockdown checks
        tracefs: Add missing lockdown check to tracefs_create_dir()
      99214f67
    • Corinna Vinschen's avatar
      igb: clean up in all error paths when enabling SR-IOV · bc6ed2fa
      Corinna Vinschen authored
      After commit 50f30349 ("igb: Enable SR-IOV after reinit"), removing
      the igb module could hang or crash (depending on the machine) when the
      module has been loaded with the max_vfs parameter set to some value != 0.
      
      In case of one test machine with a dual port 82580, this hang occurred:
      
      [  232.480687] igb 0000:41:00.1: removed PHC on enp65s0f1
      [  233.093257] igb 0000:41:00.1: IOV Disabled
      [  233.329969] pcieport 0000:40:01.0: AER: Multiple Uncorrected (Non-Fatal) err0
      [  233.340302] igb 0000:41:00.0: PCIe Bus Error: severity=Uncorrected (Non-Fata)
      [  233.352248] igb 0000:41:00.0:   device [8086:1516] error status/mask=00100000
      [  233.361088] igb 0000:41:00.0:    [20] UnsupReq               (First)
      [  233.368183] igb 0000:41:00.0: AER:   TLP Header: 40000001 0000040f cdbfc00c c
      [  233.376846] igb 0000:41:00.1: PCIe Bus Error: severity=Uncorrected (Non-Fata)
      [  233.388779] igb 0000:41:00.1:   device [8086:1516] error status/mask=00100000
      [  233.397629] igb 0000:41:00.1:    [20] UnsupReq               (First)
      [  233.404736] igb 0000:41:00.1: AER:   TLP Header: 40000001 0000040f cdbfc00c c
      [  233.538214] pci 0000:41:00.1: AER: can't recover (no error_detected callback)
      [  233.538401] igb 0000:41:00.0: removed PHC on enp65s0f0
      [  233.546197] pcieport 0000:40:01.0: AER: device recovery failed
      [  234.157244] igb 0000:41:00.0: IOV Disabled
      [  371.619705] INFO: task irq/35-aerdrv:257 blocked for more than 122 seconds.
      [  371.627489]       Not tainted 6.4.0-dirty #2
      [  371.632257] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this.
      [  371.641000] task:irq/35-aerdrv   state:D stack:0     pid:257   ppid:2      f0
      [  371.650330] Call Trace:
      [  371.653061]  <TASK>
      [  371.655407]  __schedule+0x20e/0x660
      [  371.659313]  schedule+0x5a/0xd0
      [  371.662824]  schedule_preempt_disabled+0x11/0x20
      [  371.667983]  __mutex_lock.constprop.0+0x372/0x6c0
      [  371.673237]  ? __pfx_aer_root_reset+0x10/0x10
      [  371.678105]  report_error_detected+0x25/0x1c0
      [  371.682974]  ? __pfx_report_normal_detected+0x10/0x10
      [  371.688618]  pci_walk_bus+0x72/0x90
      [  371.692519]  pcie_do_recovery+0xb2/0x330
      [  371.696899]  aer_process_err_devices+0x117/0x170
      [  371.702055]  aer_isr+0x1c0/0x1e0
      [  371.705661]  ? __set_cpus_allowed_ptr+0x54/0xa0
      [  371.710723]  ? __pfx_irq_thread_fn+0x10/0x10
      [  371.715496]  irq_thread_fn+0x20/0x60
      [  371.719491]  irq_thread+0xe6/0x1b0
      [  371.723291]  ? __pfx_irq_thread_dtor+0x10/0x10
      [  371.728255]  ? __pfx_irq_thread+0x10/0x10
      [  371.732731]  kthread+0xe2/0x110
      [  371.736243]  ? __pfx_kthread+0x10/0x10
      [  371.740430]  ret_from_fork+0x2c/0x50
      [  371.744428]  </TASK>
      
      The reproducer was a simple script:
      
        #!/bin/sh
        for i in `seq 1 5`; do
          modprobe -rv igb
          modprobe -v igb max_vfs=1
          sleep 1
          modprobe -rv igb
        done
      
      It turned out that this could only be reproduce on 82580 (quad and
      dual-port), but not on 82576, i350 and i210.  Further debugging showed
      that igb_enable_sriov()'s call to pci_enable_sriov() is failing, because
      dev->is_physfn is 0 on 82580.
      
      Prior to commit 50f30349 ("igb: Enable SR-IOV after reinit"),
      igb_enable_sriov() jumped into the "err_out" cleanup branch.  After this
      commit it only returned the error code.
      
      So the cleanup didn't take place, and the incorrect VF setup in the
      igb_adapter structure fooled the igb driver into assuming that VFs have
      been set up where no VF actually existed.
      
      Fix this problem by cleaning up again if pci_enable_sriov() fails.
      
      Fixes: 50f30349 ("igb: Enable SR-IOV after reinit")
      Signed-off-by: default avatarCorinna Vinschen <vinschen@redhat.com>
      Reviewed-by: default avatarAkihiko Odaki <akihiko.odaki@daynix.com>
      Tested-by: default avatarRafal Romanowski <rafal.romanowski@intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      bc6ed2fa
    • Vadim Fedorenko's avatar
      ixgbe: fix timestamp configuration code · 3c44191d
      Vadim Fedorenko authored
      The commit in fixes introduced flags to control the status of hardware
      configuration while processing packets. At the same time another structure
      is used to provide configuration of timestamper to user-space applications.
      The way it was coded makes this structures go out of sync easily. The
      repro is easy for 82599 chips:
      
      [root@hostname ~]# hwstamp_ctl -i eth0 -r 12 -t 1
      current settings:
      tx_type 0
      rx_filter 0
      new settings:
      tx_type 1
      rx_filter 12
      
      The eth0 device is properly configured to timestamp any PTPv2 events.
      
      [root@hostname ~]# hwstamp_ctl -i eth0 -r 1 -t 1
      current settings:
      tx_type 1
      rx_filter 12
      SIOCSHWTSTAMP failed: Numerical result out of range
      The requested time stamping mode is not supported by the hardware.
      
      The error is properly returned because HW doesn't support all packets
      timestamping. But the adapter->flags is cleared of timestamp flags
      even though no HW configuration was done. From that point no RX timestamps
      are received by user-space application. But configuration shows good
      values:
      
      [root@hostname ~]# hwstamp_ctl -i eth0
      current settings:
      tx_type 1
      rx_filter 12
      
      Fix the issue by applying new flags only when the HW was actually
      configured.
      
      Fixes: a9763f3c ("ixgbe: Update PTP to support X550EM_x devices")
      Signed-off-by: default avatarVadim Fedorenko <vadim.fedorenko@linux.dev>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel)
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      3c44191d
    • Ulf Hansson's avatar
      pmdomain: Rename the genpd subsystem to pmdomain · e2ad626f
      Ulf Hansson authored
      It has been pointed out that naming a subsystem "genpd" isn't very
      self-explanatory and the acronym itself that means Generic PM Domain, is
      known only by a limited group of people.
      
      In a way to improve the situation, let's rename the subsystem to pmdomain,
      which ideally should indicate that this is about so called Power Domains or
      "PM domains" as we often also use within the Linux Kernel terminology.
      Suggested-by: default avatarRafael J. Wysocki <rafael@kernel.org>
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
      Acked-by: default avatarHeiko Stuebner <heiko@sntech.de>
      Acked-by: default avatarRafael J. Wysocki <rafael@kernel.org>
      Acked-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Link: https://lore.kernel.org/r/20230912221127.487327-1-ulf.hansson@linaro.org
      e2ad626f
    • David S. Miller's avatar
      Merge branch 'tcp-bind-fixes' · ab6c4ec8
      David S. Miller authored
      Kuniyuki Iwashima says:
      
      ====================
      tcp: Fix bind() regression for v4-mapped-v6 address
      
      Since bhash2 was introduced, bind() is broken in two cases related
      to v4-mapped-v6 address.
      
      This series fixes the regression and adds test to cover the cases.
      
      Changes:
        v2:
          * Added patch 1 to factorise duplicated comparison (Eric Dumazet)
      
        v1: https://lore.kernel.org/netdev/20230911165106.39384-1-kuniyu@amazon.com/
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ab6c4ec8
    • Kuniyuki Iwashima's avatar
      selftest: tcp: Add v4-mapped-v6 cases in bind_wildcard.c. · 8637d8e8
      Kuniyuki Iwashima authored
      We add these 8 test cases in bind_wildcard.c to check bind() conflicts.
      
        1st bind()          2nd bind()
        ---------           ---------
        0.0.0.0             ::FFFF:0.0.0.0
        ::FFFF:0.0.0.0      0.0.0.0
        0.0.0.0             ::FFFF:127.0.0.1
        ::FFFF:127.0.0.1    0.0.0.0
        127.0.0.1           ::FFFF:0.0.0.0
        ::FFFF:0.0.0.0      127.0.0.1
        127.0.0.1           ::FFFF:127.0.0.1
        ::FFFF:127.0.0.1    127.0.0.1
      
      All test passed without bhash2 and with bhash2 and this series.
      
       Before bhash2:
        $ uname -r
        6.0.0-rc1-00393-g0bf73255
        $ ./bind_wildcard
        ...
        # PASSED: 16 / 16 tests passed.
      
       Just after bhash2:
        $ uname -r
        6.0.0-rc1-00394-g28044fc1
        $ ./bind_wildcard
        ...
        ok 15 bind_wildcard.v4_local_v6_v4mapped_local.v4_v6
        not ok 16 bind_wildcard.v4_local_v6_v4mapped_local.v6_v4
        # FAILED: 15 / 16 tests passed.
      
       On net.git:
        $ ./bind_wildcard
        ...
        not ok 14 bind_wildcard.v4_local_v6_v4mapped_any.v6_v4
        not ok 16 bind_wildcard.v4_local_v6_v4mapped_local.v6_v4
        # FAILED: 13 / 16 tests passed.
      
       With this series:
        $ ./bind_wildcard
        ...
        # PASSED: 16 / 16 tests passed.
      Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      8637d8e8
    • Kuniyuki Iwashima's avatar
      selftest: tcp: Move expected_errno into each test case in bind_wildcard.c. · 2895d879
      Kuniyuki Iwashima authored
      This is a preparation patch for the following patch.
      
      Let's define expected_errno in each test case so that we can add other test
      cases easily.
      Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      2895d879
    • Kuniyuki Iwashima's avatar
      selftest: tcp: Fix address length in bind_wildcard.c. · 0071d155
      Kuniyuki Iwashima authored
      The selftest passes the IPv6 address length for an IPv4 address.
      We should pass the correct length.
      
      Note inet_bind_sk() does not check if the size is larger than
      sizeof(struct sockaddr_in), so there is no real bug in this
      selftest.
      
      Fixes: 13715acf ("selftest: Add test for bind() conflicts.")
      Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      0071d155
    • Kuniyuki Iwashima's avatar
      tcp: Fix bind() regression for v4-mapped-v6 non-wildcard address. · c48ef9c4
      Kuniyuki Iwashima authored
      Since bhash2 was introduced, the example below does not work as expected.
      These two bind() should conflict, but the 2nd bind() now succeeds.
      
        from socket import *
      
        s1 = socket(AF_INET6, SOCK_STREAM)
        s1.bind(('::ffff:127.0.0.1', 0))
      
        s2 = socket(AF_INET, SOCK_STREAM)
        s2.bind(('127.0.0.1', s1.getsockname()[1]))
      
      During the 2nd bind() in inet_csk_get_port(), inet_bind2_bucket_find()
      fails to find the 1st socket's tb2, so inet_bind2_bucket_create() allocates
      a new tb2 for the 2nd socket.  Then, we call inet_csk_bind_conflict() that
      checks conflicts in the new tb2 by inet_bhash2_conflict().  However, the
      new tb2 does not include the 1st socket, thus the bind() finally succeeds.
      
      In this case, inet_bind2_bucket_match() must check if AF_INET6 tb2 has
      the conflicting v4-mapped-v6 address so that inet_bind2_bucket_find()
      returns the 1st socket's tb2.
      
      Note that if we bind two sockets to 127.0.0.1 and then ::FFFF:127.0.0.1,
      the 2nd bind() fails properly for the same reason mentinoed in the previous
      commit.
      
      Fixes: 28044fc1 ("net: Add a bhash2 table hashed by port and address")
      Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Acked-by: default avatarAndrei Vagin <avagin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c48ef9c4
    • Kuniyuki Iwashima's avatar
      tcp: Fix bind() regression for v4-mapped-v6 wildcard address. · aa99e5f8
      Kuniyuki Iwashima authored
      Andrei Vagin reported bind() regression with strace logs.
      
      If we bind() a TCPv6 socket to ::FFFF:0.0.0.0 and then bind() a TCPv4
      socket to 127.0.0.1, the 2nd bind() should fail but now succeeds.
      
        from socket import *
      
        s1 = socket(AF_INET6, SOCK_STREAM)
        s1.bind(('::ffff:0.0.0.0', 0))
      
        s2 = socket(AF_INET, SOCK_STREAM)
        s2.bind(('127.0.0.1', s1.getsockname()[1]))
      
      During the 2nd bind(), if tb->family is AF_INET6 and sk->sk_family is
      AF_INET in inet_bind2_bucket_match_addr_any(), we still need to check
      if tb has the v4-mapped-v6 wildcard address.
      
      The example above does not work after commit 5456262d ("net: Fix
      incorrect address comparison when searching for a bind2 bucket"), but
      the blamed change is not the commit.
      
      Before the commit, the leading zeros of ::FFFF:0.0.0.0 were treated
      as 0.0.0.0, and the sequence above worked by chance.  Technically, this
      case has been broken since bhash2 was introduced.
      
      Note that if we bind() two sockets to 127.0.0.1 and then ::FFFF:0.0.0.0,
      the 2nd bind() fails properly because we fall back to using bhash to
      detect conflicts for the v4-mapped-v6 address.
      
      Fixes: 28044fc1 ("net: Add a bhash2 table hashed by port and address")
      Reported-by: default avatarAndrei Vagin <avagin@google.com>
      Closes: https://lore.kernel.org/netdev/ZPuYBOFC8zsK6r9T@google.com/Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      aa99e5f8
    • Kuniyuki Iwashima's avatar
      tcp: Factorise sk_family-independent comparison in inet_bind2_bucket_match(_addr_any). · c6d27706
      Kuniyuki Iwashima authored
      This is a prep patch to make the following patches cleaner that touch
      inet_bind2_bucket_match() and inet_bind2_bucket_match_addr_any().
      
      Both functions have duplicated comparison for netns, port, and l3mdev.
      Let's factorise them.
      Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c6d27706
  4. 12 Sep, 2023 9 commits