Skip to content
  1. Oct 06, 2021
    • Leon Yu's avatar
      net: stmmac: don't attach interface until resume finishes · e81f3b7e
      Leon Yu authored
      commit 31096c3e upstream.
      
      Commit 14b41a29
      
       ("net: stmmac: Delete txtimer in suspend") was the
      first attempt to fix a race between mod_timer() and setup_timer()
      during stmmac_resume(). However the issue still exists as the commit
      only addressed half of the issue.
      
      Same race can still happen as stmmac_resume() re-attaches interface
      way too early - even before hardware is fully initialized.  Worse,
      doing so allows network traffic to restart and stmmac_tx_timer_arm()
      being called in the middle of stmmac_resume(), which re-init tx timers
      in stmmac_init_coalesce().  timer_list will be corrupted and system
      crashes as a result of race between mod_timer() and setup_timer().
      
        systemd--1995    2.... 552950018us : stmmac_suspend: 4994
        ksoftirq-9       0..s2 553123133us : stmmac_tx_timer_arm: 2276
        systemd--1995    0.... 553127896us : stmmac_resume: 5101
        systemd--320     7...2 553132752us : stmmac_tx_timer_arm: 2276
        (sd-exec-1999    5...2 553135204us : stmmac_tx_timer_arm: 2276
        ---------------------------------
        pc : run_timer_softirq+0x468/0x5e0
        lr : run_timer_softirq+0x570/0x5e0
        Call trace:
         run_timer_softirq+0x468/0x5e0
         __do_softirq+0x124/0x398
         irq_exit+0xd8/0xe0
         __handle_domain_irq+0x6c/0xc0
         gic_handle_irq+0x60/0xb0
         el1_irq+0xb8/0x180
         arch_cpu_idle+0x38/0x230
         default_idle_call+0x24/0x3c
         do_idle+0x1e0/0x2b8
         cpu_startup_entry+0x28/0x48
         secondary_start_kernel+0x1b4/0x208
      
      Fix this by deferring netif_device_attach() to the end of
      stmmac_resume().
      
      Signed-off-by: default avatarLeon Yu <leoyu@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Cc: Macpaul Lin <macpaul.lin@mediatek.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e81f3b7e
    • Eric Dumazet's avatar
      net: udp: annotate data race around udp_sk(sk)->corkflag · f8ffde0b
      Eric Dumazet authored
      commit a9f59707 upstream.
      
      up->corkflag field can be read or written without any lock.
      Annotate accesses to avoid possible syzbot/KCSAN reports.
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f8ffde0b
    • Andrej Shadura's avatar
      HID: u2fzero: ignore incomplete packets without data · 9dbf7e34
      Andrej Shadura authored
      commit 22d65765 upstream.
      
      Since the actual_length calculation is performed unsigned, packets
      shorter than 7 bytes (e.g. packets without data or otherwise truncated)
      or non-received packets ("zero" bytes) can cause buffer overflow.
      
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=214437
      Fixes: 42337b9d
      
      ("HID: add driver for U2F Zero built-in LED and RNG")
      Signed-off-by: default avatarAndrej Shadura <andrew.shadura@collabora.co.uk>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9dbf7e34
    • yangerkun's avatar
      ext4: fix potential infinite loop in ext4_dx_readdir() · d518ea03
      yangerkun authored
      commit 42cb4474
      
       upstream.
      
      When ext4_htree_fill_tree() fails, ext4_dx_readdir() can run into an
      infinite loop since if info->last_pos != ctx->pos this will reset the
      directory scan and reread the failing entry.  For example:
      
      1. a dx_dir which has 3 block, block 0 as dx_root block, block 1/2 as
         leaf block which own the ext4_dir_entry_2
      2. block 1 read ok and call_filldir which will fill the dirent and update
         the ctx->pos
      3. block 2 read fail, but we has already fill some dirent, so we will
         return back to userspace will a positive return val(see ksys_getdents64)
      4. the second ext4_dx_readdir will reset the world since info->last_pos
         != ctx->pos, and will also init the curr_hash which pos to block 1
      5. So we will read block1 too, and once block2 still read fail, we can
         only fill one dirent because the hash of the entry in block1(besides
         the last one) won't greater than curr_hash
      6. this time, we forget update last_pos too since the read for block2
         will fail, and since we has got the one entry, ksys_getdents64 can
         return success
      7. Latter we will trapped in a loop with step 4~6
      
      Cc: stable@kernel.org
      Signed-off-by: default avataryangerkun <yangerkun@huawei.com>
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Link: https://lore.kernel.org/r/20210914111415.3921954-1-yangerkun@huawei.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d518ea03
    • Jeffle Xu's avatar
      ext4: fix reserved space counter leakage · 59c19fdc
      Jeffle Xu authored
      commit 6fed8395 upstream.
      
      When ext4_insert_delayed block receives and recovers from an error from
      ext4_es_insert_delayed_block(), e.g., ENOMEM, it does not release the
      space it has reserved for that block insertion as it should. One effect
      of this bug is that s_dirtyclusters_counter is not decremented and
      remains incorrectly elevated until the file system has been unmounted.
      This can result in premature ENOSPC returns and apparent loss of free
      space.
      
      Another effect of this bug is that
      /sys/fs/ext4/<dev>/delayed_allocation_blocks can remain non-zero even
      after syncfs has been executed on the filesystem.
      
      Besides, add check for s_dirtyclusters_counter when inode is going to be
      evicted and freed. s_dirtyclusters_counter can still keep non-zero until
      inode is written back in .evict_inode(), and thus the check is delayed
      to .destroy_inode().
      
      Fixes: 51865fda
      
       ("ext4: let ext4 maintain extent status tree")
      Cc: stable@kernel.org
      Suggested-by: default avatarGao Xiang <hsiangkao@linux.alibaba.com>
      Signed-off-by: default avatarJeffle Xu <jefflexu@linux.alibaba.com>
      Reviewed-by: default avatarEric Whitney <enwlinux@gmail.com>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Link: https://lore.kernel.org/r/20210823061358.84473-1-jefflexu@linux.alibaba.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      59c19fdc
    • Ritesh Harjani's avatar
      ext4: fix loff_t overflow in ext4_max_bitmap_size() · c4b8db2b
      Ritesh Harjani authored
      commit 75ca6ad4
      
       upstream.
      
      We should use unsigned long long rather than loff_t to avoid
      overflow in ext4_max_bitmap_size() for comparison before returning.
      w/o this patch sbi->s_bitmap_maxbytes was becoming a negative
      value due to overflow of upper_limit (with has_huge_files as true)
      
      Below is a quick test to trigger it on a 64KB pagesize system.
      
      sudo mkfs.ext4 -b 65536 -O ^has_extents,^64bit /dev/loop2
      sudo mount /dev/loop2 /mnt
      sudo echo "hello" > /mnt/hello 	-> This will error out with
      				"echo: write error: File too large"
      
      Signed-off-by: default avatarRitesh Harjani <riteshh@linux.ibm.com>
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Cc: stable@kernel.org
      Link: https://lore.kernel.org/r/594f409e2c543e90fd836b78188dfa5c575065ba.1622867594.git.riteshh@linux.ibm.com
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c4b8db2b
    • Johan Hovold's avatar
      ipack: ipoctal: fix module reference leak · 3253c87e
      Johan Hovold authored
      commit bb8a4fcb upstream.
      
      A reference to the carrier module was taken on every open but was only
      released once when the final reference to the tty struct was dropped.
      
      Fix this by taking the module reference and initialising the tty driver
      data when installing the tty.
      
      Fixes: 82a82340
      
       ("ipoctal: get carrier driver to avoid rmmod")
      Cc: stable@vger.kernel.org      # 3.18
      Cc: Federico Vaga <federico.vaga@cern.ch>
      Acked-by: default avatarSamuel Iglesias Gonsalvez <siglesias@igalia.com>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Link: https://lore.kernel.org/r/20210917114622.5412-6-johan@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3253c87e
    • Johan Hovold's avatar
      ipack: ipoctal: fix missing allocation-failure check · 9c802a05
      Johan Hovold authored
      commit 445c8132 upstream.
      
      Add the missing error handling when allocating the transmit buffer to
      avoid dereferencing a NULL pointer in write() should the allocation
      ever fail.
      
      Fixes: ba4dc61f
      
       ("Staging: ipack: add support for IP-OCTAL mezzanine board")
      Cc: stable@vger.kernel.org      # 3.5
      Acked-by: default avatarSamuel Iglesias Gonsalvez <siglesias@igalia.com>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Link: https://lore.kernel.org/r/20210917114622.5412-5-johan@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9c802a05
    • Johan Hovold's avatar
      ipack: ipoctal: fix tty-registration error handling · 3fd682d4
      Johan Hovold authored
      commit cd20d592 upstream.
      
      Registration of the ipoctal tty devices is unlikely to fail, but if it
      ever does, make sure not to deregister a never registered tty device
      (and dereference a NULL pointer) when the driver is later unbound.
      
      Fixes: 2afb41d9
      
       ("Staging: ipack/devices/ipoctal: Check tty_register_device return value.")
      Cc: stable@vger.kernel.org      # 3.7
      Acked-by: default avatarSamuel Iglesias Gonsalvez <siglesias@igalia.com>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Link: https://lore.kernel.org/r/20210917114622.5412-4-johan@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3fd682d4
    • Johan Hovold's avatar
      ipack: ipoctal: fix tty registration race · e6a71c17
      Johan Hovold authored
      commit 65c001df upstream.
      
      Make sure to set the tty class-device driver data before registering the
      tty to avoid having a racing open() dereference a NULL pointer.
      
      Fixes: 9c1d784a
      
       ("Staging: ipack/devices/ipoctal: Get rid of ipoctal_list.")
      Cc: stable@vger.kernel.org      # 3.7
      Acked-by: default avatarSamuel Iglesias Gonsalvez <siglesias@igalia.com>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Link: https://lore.kernel.org/r/20210917114622.5412-3-johan@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e6a71c17
    • Johan Hovold's avatar
      ipack: ipoctal: fix stack information leak · 8657158a
      Johan Hovold authored
      commit a89936cc upstream.
      
      The tty driver name is used also after registering the driver and must
      specifically not be allocated on the stack to avoid leaking information
      to user space (or triggering an oops).
      
      Drivers should not try to encode topology information in the tty device
      name but this one snuck in through staging without anyone noticing and
      another driver has since copied this malpractice.
      
      Fixing the ABI is a separate issue, but this at least plugs the security
      hole.
      
      Fixes: ba4dc61f
      
       ("Staging: ipack: add support for IP-OCTAL mezzanine board")
      Cc: stable@vger.kernel.org      # 3.5
      Acked-by: default avatarSamuel Iglesias Gonsalvez <siglesias@igalia.com>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Link: https://lore.kernel.org/r/20210917114622.5412-2-johan@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8657158a
    • Nirmoy Das's avatar
      debugfs: debugfs_create_file_size(): use IS_ERR to check for error · 91d5de0b
      Nirmoy Das authored
      commit af505cad
      
       upstream.
      
      debugfs_create_file() returns encoded error so use IS_ERR for checking
      return value.
      
      Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
      Signed-off-by: default avatarNirmoy Das <nirmoy.das@amd.com>
      Fixes: ff9fb72b
      
       ("debugfs: return error values, not NULL")
      Cc: stable <stable@vger.kernel.org>
      References: https://gitlab.freedesktop.org/drm/amd/-/issues/1686
      Link: https://lore.kernel.org/r/20210902102917.2233-1-nirmoy.das@amd.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      91d5de0b
    • Chen Jingwen's avatar
      elf: don't use MAP_FIXED_NOREPLACE for elf interpreter mappings · 98574c91
      Chen Jingwen authored
      commit 9b2f72cc upstream.
      
      In commit b212921b ("elf: don't use MAP_FIXED_NOREPLACE for elf
      executable mappings") we still leave MAP_FIXED_NOREPLACE in place for
      load_elf_interp.
      
      Unfortunately, this will cause kernel to fail to start with:
      
          1 (init): Uhuuh, elf segment at 00003ffff7ffd000 requested but the memory is mapped already
          Failed to execute /init (error -17)
      
      The reason is that the elf interpreter (ld.so) has overlapping segments.
      
        readelf -l ld-2.31.so
        Program Headers:
          Type           Offset             VirtAddr           PhysAddr
                         FileSiz            MemSiz              Flags  Align
          LOAD           0x0000000000000000 0x0000000000000000 0x0000000000000000
                         0x000000000002c94c 0x000000000002c94c  R E    0x10000
          LOAD           0x000000000002dae0 0x000000000003dae0 0x000000000003dae0
                         0x00000000000021e8 0x0000000000002320  RW     0x10000
          LOAD           0x000000000002fe00 0x000000000003fe00 0x000000000003fe00
                         0x00000000000011ac 0x0000000000001328  RW     0x10000
      
      The reason for this problem is the same as described in commit
      ad55eac7 ("elf: enforce MAP_FIXED on overlaying elf segments").
      
      Not only executable binaries, elf interpreters (e.g. ld.so) can have
      overlapping elf segments, so we better drop MAP_FIXED_NOREPLACE and go
      back to MAP_FIXED in load_elf_interp.
      
      Fixes: 4ed28639
      
       ("fs, elf: drop MAP_FIXED usage from elf_map")
      Cc: <stable@vger.kernel.org> # v4.19
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Michal Hocko <mhocko@suse.com>
      Signed-off-by: default avatarChen Jingwen <chenjingwen6@huawei.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      98574c91
    • Kan Liang's avatar
      perf/x86/intel: Update event constraints for ICX · 9356e4dc
      Kan Liang authored
      [ Upstream commit ecc2123e ]
      
      According to the latest event list, the event encoding 0xEF is only
      available on the first 4 counters. Add it into the event constraints
      table.
      
      Fixes: 60176089
      
       ("perf/x86/intel: Add Icelake support")
      Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/1632842343-25862-1-git-send-email-kan.liang@linux.intel.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9356e4dc
    • Eric Dumazet's avatar
      af_unix: fix races in sk_peer_pid and sk_peer_cred accesses · 0fcfaa8e
      Eric Dumazet authored
      [ Upstream commit 35306eb2 ]
      
      Jann Horn reported that SO_PEERCRED and SO_PEERGROUPS implementations
      are racy, as af_unix can concurrently change sk_peer_pid and sk_peer_cred.
      
      In order to fix this issue, this patch adds a new spinlock that needs
      to be used whenever these fields are read or written.
      
      Jann also pointed out that l2cap_sock_get_peer_pid_cb() is currently
      reading sk->sk_peer_pid which makes no sense, as this field
      is only possibly set by AF_UNIX sockets.
      We will have to clean this in a separate patch.
      This could be done by reverting b48596d1 "Bluetooth: L2CAP: Add get_peer_pid callback"
      or implementing what was truly expected.
      
      Fixes: 109f6e39
      
       ("af_unix: Allow SO_PEERCRED to work across namespaces.")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarJann Horn <jannh@google.com>
      Cc: Eric W. Biederman <ebiederm@xmission.com>
      Cc: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Cc: Marcel Holtmann <marcel@holtmann.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0fcfaa8e
    • Vlad Buslov's avatar
      net: sched: flower: protect fl_walk() with rcu · 694b0cee
      Vlad Buslov authored
      [ Upstream commit d5ef1906 ]
      
      Patch that refactored fl_walk() to use idr_for_each_entry_continue_ul()
      also removed rcu protection of individual filters which causes following
      use-after-free when filter is deleted concurrently. Fix fl_walk() to obtain
      rcu read lock while iterating and taking the filter reference and temporary
      release the lock while calling arg->fn() callback that can sleep.
      
      KASAN trace:
      
      [  352.773640] ==================================================================
      [  352.775041] BUG: KASAN: use-after-free in fl_walk+0x159/0x240 [cls_flower]
      [  352.776304] Read of size 4 at addr ffff8881c8251480 by task tc/2987
      
      [  352.777862] CPU: 3 PID: 2987 Comm: tc Not tainted 5.15.0-rc2+ #2
      [  352.778980] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
      [  352.781022] Call Trace:
      [  352.781573]  dump_stack_lvl+0x46/0x5a
      [  352.782332]  print_address_description.constprop.0+0x1f/0x140
      [  352.783400]  ? fl_walk+0x159/0x240 [cls_flower]
      [  352.784292]  ? fl_walk+0x159/0x240 [cls_flower]
      [  352.785138]  kasan_report.cold+0x83/0xdf
      [  352.785851]  ? fl_walk+0x159/0x240 [cls_flower]
      [  352.786587]  kasan_check_range+0x145/0x1a0
      [  352.787337]  fl_walk+0x159/0x240 [cls_flower]
      [  352.788163]  ? fl_put+0x10/0x10 [cls_flower]
      [  352.789007]  ? __mutex_unlock_slowpath.constprop.0+0x220/0x220
      [  352.790102]  tcf_chain_dump+0x231/0x450
      [  352.790878]  ? tcf_chain_tp_delete_empty+0x170/0x170
      [  352.791833]  ? __might_sleep+0x2e/0xc0
      [  352.792594]  ? tfilter_notify+0x170/0x170
      [  352.793400]  ? __mutex_unlock_slowpath.constprop.0+0x220/0x220
      [  352.794477]  tc_dump_tfilter+0x385/0x4b0
      [  352.795262]  ? tc_new_tfilter+0x1180/0x1180
      [  352.796103]  ? __mod_node_page_state+0x1f/0xc0
      [  352.796974]  ? __build_skb_around+0x10e/0x130
      [  352.797826]  netlink_dump+0x2c0/0x560
      [  352.798563]  ? netlink_getsockopt+0x430/0x430
      [  352.799433]  ? __mutex_unlock_slowpath.constprop.0+0x220/0x220
      [  352.800542]  __netlink_dump_start+0x356/0x440
      [  352.801397]  rtnetlink_rcv_msg+0x3ff/0x550
      [  352.802190]  ? tc_new_tfilter+0x1180/0x1180
      [  352.802872]  ? rtnl_calcit.isra.0+0x1f0/0x1f0
      [  352.803668]  ? tc_new_tfilter+0x1180/0x1180
      [  352.804344]  ? _copy_from_iter_nocache+0x800/0x800
      [  352.805202]  ? kasan_set_track+0x1c/0x30
      [  352.805900]  netlink_rcv_skb+0xc6/0x1f0
      [  352.806587]  ? rht_deferred_worker+0x6b0/0x6b0
      [  352.807455]  ? rtnl_calcit.isra.0+0x1f0/0x1f0
      [  352.808324]  ? netlink_ack+0x4d0/0x4d0
      [  352.809086]  ? netlink_deliver_tap+0x62/0x3d0
      [  352.809951]  netlink_unicast+0x353/0x480
      [  352.810744]  ? netlink_attachskb+0x430/0x430
      [  352.811586]  ? __alloc_skb+0xd7/0x200
      [  352.812349]  netlink_sendmsg+0x396/0x680
      [  352.813132]  ? netlink_unicast+0x480/0x480
      [  352.813952]  ? __import_iovec+0x192/0x210
      [  352.814759]  ? netlink_unicast+0x480/0x480
      [  352.815580]  sock_sendmsg+0x6c/0x80
      [  352.816299]  ____sys_sendmsg+0x3a5/0x3c0
      [  352.817096]  ? kernel_sendmsg+0x30/0x30
      [  352.817873]  ? __ia32_sys_recvmmsg+0x150/0x150
      [  352.818753]  ___sys_sendmsg+0xd8/0x140
      [  352.819518]  ? sendmsg_copy_msghdr+0x110/0x110
      [  352.820402]  ? ___sys_recvmsg+0xf4/0x1a0
      [  352.821110]  ? __copy_msghdr_from_user+0x260/0x260
      [  352.821934]  ? _raw_spin_lock+0x81/0xd0
      [  352.822680]  ? __handle_mm_fault+0xef3/0x1b20
      [  352.823549]  ? rb_insert_color+0x2a/0x270
      [  352.824373]  ? copy_page_range+0x16b0/0x16b0
      [  352.825209]  ? perf_event_update_userpage+0x2d0/0x2d0
      [  352.826190]  ? __fget_light+0xd9/0xf0
      [  352.826941]  __sys_sendmsg+0xb3/0x130
      [  352.827613]  ? __sys_sendmsg_sock+0x20/0x20
      [  352.828377]  ? do_user_addr_fault+0x2c5/0x8a0
      [  352.829184]  ? fpregs_assert_state_consistent+0x52/0x60
      [  352.830001]  ? exit_to_user_mode_prepare+0x32/0x160
      [  352.830845]  do_syscall_64+0x35/0x80
      [  352.831445]  entry_SYSCALL_64_after_hwframe+0x44/0xae
      [  352.832331] RIP: 0033:0x7f7bee973c17
      [  352.833078] Code: 0c 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b7 0f 1f 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 2e 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 51 c3 48 83 ec 28 89 54 24 1c 48 89 74 24 10
      [  352.836202] RSP: 002b:00007ffcbb368e28 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
      [  352.837524] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f7bee973c17
      [  352.838715] RDX: 0000000000000000 RSI: 00007ffcbb368e50 RDI: 0000000000000003
      [  352.839838] RBP: 00007ffcbb36d090 R08: 00000000cea96d79 R09: 00007f7beea34a40
      [  352.841021] R10: 00000000004059bb R11: 0000000000000246 R12: 000000000046563f
      [  352.842208] R13: 0000000000000000 R14: 0000000000000000 R15: 00007ffcbb36d088
      
      [  352.843784] Allocated by task 2960:
      [  352.844451]  kasan_save_stack+0x1b/0x40
      [  352.845173]  __kasan_kmalloc+0x7c/0x90
      [  352.845873]  fl_change+0x282/0x22db [cls_flower]
      [  352.846696]  tc_new_tfilter+0x6cf/0x1180
      [  352.847493]  rtnetlink_rcv_msg+0x471/0x550
      [  352.848323]  netlink_rcv_skb+0xc6/0x1f0
      [  352.849097]  netlink_unicast+0x353/0x480
      [  352.849886]  netlink_sendmsg+0x396/0x680
      [  352.850678]  sock_sendmsg+0x6c/0x80
      [  352.851398]  ____sys_sendmsg+0x3a5/0x3c0
      [  352.852202]  ___sys_sendmsg+0xd8/0x140
      [  352.852967]  __sys_sendmsg+0xb3/0x130
      [  352.853718]  do_syscall_64+0x35/0x80
      [  352.854457]  entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      [  352.855830] Freed by task 7:
      [  352.856421]  kasan_save_stack+0x1b/0x40
      [  352.857139]  kasan_set_track+0x1c/0x30
      [  352.857854]  kasan_set_free_info+0x20/0x30
      [  352.858609]  __kasan_slab_free+0xed/0x130
      [  352.859348]  kfree+0xa7/0x3c0
      [  352.859951]  process_one_work+0x44d/0x780
      [  352.860685]  worker_thread+0x2e2/0x7e0
      [  352.861390]  kthread+0x1f4/0x220
      [  352.862022]  ret_from_fork+0x1f/0x30
      
      [  352.862955] Last potentially related work creation:
      [  352.863758]  kasan_save_stack+0x1b/0x40
      [  352.864378]  kasan_record_aux_stack+0xab/0xc0
      [  352.865028]  insert_work+0x30/0x160
      [  352.865617]  __queue_work+0x351/0x670
      [  352.866261]  rcu_work_rcufn+0x30/0x40
      [  352.866917]  rcu_core+0x3b2/0xdb0
      [  352.867561]  __do_softirq+0xf6/0x386
      
      [  352.868708] Second to last potentially related work creation:
      [  352.869779]  kasan_save_stack+0x1b/0x40
      [  352.870560]  kasan_record_aux_stack+0xab/0xc0
      [  352.871426]  call_rcu+0x5f/0x5c0
      [  352.872108]  queue_rcu_work+0x44/0x50
      [  352.872855]  __fl_put+0x17c/0x240 [cls_flower]
      [  352.873733]  fl_delete+0xc7/0x100 [cls_flower]
      [  352.874607]  tc_del_tfilter+0x510/0xb30
      [  352.886085]  rtnetlink_rcv_msg+0x471/0x550
      [  352.886875]  netlink_rcv_skb+0xc6/0x1f0
      [  352.887636]  netlink_unicast+0x353/0x480
      [  352.888285]  netlink_sendmsg+0x396/0x680
      [  352.888942]  sock_sendmsg+0x6c/0x80
      [  352.889583]  ____sys_sendmsg+0x3a5/0x3c0
      [  352.890311]  ___sys_sendmsg+0xd8/0x140
      [  352.891019]  __sys_sendmsg+0xb3/0x130
      [  352.891716]  do_syscall_64+0x35/0x80
      [  352.892395]  entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      [  352.893666] The buggy address belongs to the object at ffff8881c8251000
                      which belongs to the cache kmalloc-2k of size 2048
      [  352.895696] The buggy address is located 1152 bytes inside of
                      2048-byte region [ffff8881c8251000, ffff8881c8251800)
      [  352.897640] The buggy address belongs to the page:
      [  352.898492] page:00000000213bac35 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1c8250
      [  352.900110] head:00000000213bac35 order:3 compound_mapcount:0 compound_pincount:0
      [  352.901541] flags: 0x2ffff800010200(slab|head|node=0|zone=2|lastcpupid=0x1ffff)
      [  352.902908] raw: 002ffff800010200 0000000000000000 dead000000000122 ffff888100042f00
      [  352.904391] raw: 0000000000000000 0000000000080008 00000001ffffffff 0000000000000000
      [  352.905861] page dumped because: kasan: bad access detected
      
      [  352.907323] Memory state around the buggy address:
      [  352.908218]  ffff8881c8251380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
      [  352.909471]  ffff8881c8251400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
      [  352.910735] >ffff8881c8251480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
      [  352.912012]                    ^
      [  352.912642]  ffff8881c8251500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
      [  352.913919]  ffff8881c8251580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
      [  352.915185] ==================================================================
      
      Fixes: d39d7149
      
       ("idr: introduce idr_for_each_entry_continue_ul()")
      Signed-off-by: default avatarVlad Buslov <vladbu@nvidia.com>
      Acked-by: default avatarCong Wang <cong.wang@bytedance.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      694b0cee
    • Jian Shen's avatar
      net: hns3: do not allow call hns3_nic_net_open repeatedly · 5a31d4e7
      Jian Shen authored
      [ Upstream commit 5b09e88e ]
      
      hns3_nic_net_open() is not allowed to called repeatly, but there
      is no checking for this. When doing device reset and setup tc
      concurrently, there is a small oppotunity to call hns3_nic_net_open
      repeatedly, and cause kernel bug by calling napi_enable twice.
      
      The calltrace information is like below:
      [ 3078.222780] ------------[ cut here ]------------
      [ 3078.230255] kernel BUG at net/core/dev.c:6991!
      [ 3078.236224] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
      [ 3078.243431] Modules linked in: hns3 hclgevf hclge hnae3 vfio_iommu_type1 vfio_pci vfio_virqfd vfio pv680_mii(O)
      [ 3078.258880] CPU: 0 PID: 295 Comm: kworker/u8:5 Tainted: G           O      5.14.0-rc4+ #1
      [ 3078.269102] Hardware name:  , BIOS KpxxxFPGA 1P B600 V181 08/12/2021
      [ 3078.276801] Workqueue: hclge hclge_service_task [hclge]
      [ 3078.288774] pstate: 60400009 (nZCv daif +PAN -UAO -TCO BTYPE=--)
      [ 3078.296168] pc : napi_enable+0x80/0x84
      tc qdisc sho[w  3d0e7v8 .e3t0h218 79] lr : hns3_nic_net_open+0x138/0x510 [hns3]
      
      [ 3078.314771] sp : ffff8000108abb20
      [ 3078.319099] x29: ffff8000108abb20 x28: 0000000000000000 x27: ffff0820a8490300
      [ 3078.329121] x26: 0000000000000001 x25: ffff08209cfc6200 x24: 0000000000000000
      [ 3078.339044] x23: ffff0820a8490300 x22: ffff08209cd76000 x21: ffff0820abfe3880
      [ 3078.349018] x20: 0000000000000000 x19: ffff08209cd76900 x18: 0000000000000000
      [ 3078.358620] x17: 0000000000000000 x16: ffffc816e1727a50 x15: 0000ffff8f4ff930
      [ 3078.368895] x14: 0000000000000000 x13: 0000000000000000 x12: 0000259e9dbeb6b4
      [ 3078.377987] x11: 0096a8f7e764eb40 x10: 634615ad28d3eab5 x9 : ffffc816ad8885b8
      [ 3078.387091] x8 : ffff08209cfc6fb8 x7 : ffff0820ac0da058 x6 : ffff0820a8490344
      [ 3078.396356] x5 : 0000000000000140 x4 : 0000000000000003 x3 : ffff08209cd76938
      [ 3078.405365] x2 : 0000000000000000 x1 : 0000000000000010 x0 : ffff0820abfe38a0
      [ 3078.414657] Call trace:
      [ 3078.418517]  napi_enable+0x80/0x84
      [ 3078.424626]  hns3_reset_notify_up_enet+0x78/0xd0 [hns3]
      [ 3078.433469]  hns3_reset_notify+0x64/0x80 [hns3]
      [ 3078.441430]  hclge_notify_client+0x68/0xb0 [hclge]
      [ 3078.450511]  hclge_reset_rebuild+0x524/0x884 [hclge]
      [ 3078.458879]  hclge_reset_service_task+0x3c4/0x680 [hclge]
      [ 3078.467470]  hclge_service_task+0xb0/0xb54 [hclge]
      [ 3078.475675]  process_one_work+0x1dc/0x48c
      [ 3078.481888]  worker_thread+0x15c/0x464
      [ 3078.487104]  kthread+0x160/0x170
      [ 3078.492479]  ret_from_fork+0x10/0x18
      [ 3078.498785] Code: c8027c81 35ffffa2 d50323bf d65f03c0 (d4210000)
      [ 3078.506889] ---[ end trace 8ebe0340a1b0fb44 ]---
      
      Once hns3_nic_net_open() is excute success, the flag
      HNS3_NIC_STATE_DOWN will be cleared. So add checking for this
      flag, directly return when HNS3_NIC_STATE_DOWN is no set.
      
      Fixes: e8884027
      
       ("net: hns3: call hns3_nic_net_open() while doing HNAE3_UP_CLIENT")
      Signed-off-by: default avatarJian Shen <shenjian15@huawei.com>
      Signed-off-by: default avatarGuangbin Huang <huangguangbin2@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5a31d4e7
    • Rahul Lakkireddy's avatar
      scsi: csiostor: Add module softdep on cxgb4 · 87de237b
      Rahul Lakkireddy authored
      [ Upstream commit 79a74822 ]
      
      Both cxgb4 and csiostor drivers run on their own independent Physical
      Function. But when cxgb4 and csiostor are both being loaded in parallel via
      modprobe, there is a race when firmware upgrade is attempted by both the
      drivers.
      
      When the cxgb4 driver initiates the firmware upgrade, it halts the firmware
      and the chip until upgrade is complete. When the csiostor driver is coming
      up in parallel, the firmware mailbox communication fails with timeouts and
      the csiostor driver probe fails.
      
      Add a module soft dependency on cxgb4 driver to ensure loading csiostor
      triggers cxgb4 to load first when available to avoid the firmware upgrade
      race.
      
      Link: https://lore.kernel.org/r/1632759248-15382-1-git-send-email-rahul.lakkireddy@chelsio.com
      Fixes: a3667aae
      
       ("[SCSI] csiostor: Chelsio FCoE offload driver")
      Signed-off-by: default avatarRahul Lakkireddy <rahul.lakkireddy@chelsio.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      87de237b
    • Jens Axboe's avatar
      Revert "block, bfq: honor already-setup queue merges" · 1b6ccfce
      Jens Axboe authored
      [ Upstream commit ebc69e89 ]
      
      This reverts commit 2d52c58b.
      
      We have had several folks complain that this causes hangs for them, which
      is especially problematic as the commit has also hit stable already.
      
      As no resolution seems to be forthcoming right now, revert the patch.
      
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=214503
      Fixes: 2d52c58b
      
       ("block, bfq: honor already-setup queue merges")
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1b6ccfce
    • Jiri Benc's avatar
      selftests, bpf: test_lwt_ip_encap: Really disable rp_filter · 753096c3
      Jiri Benc authored
      [ Upstream commit 79e2c306 ]
      
      It's not enough to set net.ipv4.conf.all.rp_filter=0, that does not override
      a greater rp_filter value on the individual interfaces. We also need to set
      net.ipv4.conf.default.rp_filter=0 before creating the interfaces. That way,
      they'll also get their own rp_filter value of zero.
      
      Fixes: 0fde56e4
      
       ("selftests: bpf: add test_lwt_ip_encap selftest")
      Signed-off-by: default avatarJiri Benc <jbenc@redhat.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/b1cdd9d469f09ea6e01e9c89a6071c79b7380f89.1632386362.git.jbenc@redhat.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      753096c3
    • Jacob Keller's avatar
      e100: fix buffer overrun in e100_get_regs · 897d1401
      Jacob Keller authored
      [ Upstream commit 51032e6f ]
      
      The e100_get_regs function is used to implement a simple register dump
      for the e100 device. The data is broken into a couple of MAC control
      registers, and then a series of PHY registers, followed by a memory dump
      buffer.
      
      The total length of the register dump is defined as (1 + E100_PHY_REGS)
      * sizeof(u32) + sizeof(nic->mem->dump_buf).
      
      The logic for filling in the PHY registers uses a convoluted inverted
      count for loop which counts from E100_PHY_REGS (0x1C) down to 0, and
      assigns the slots 1 + E100_PHY_REGS - i. The first loop iteration will
      fill in [1] and the final loop iteration will fill in [1 + 0x1C]. This
      is actually one more than the supposed number of PHY registers.
      
      The memory dump buffer is then filled into the space at
      [2 + E100_PHY_REGS] which will cause that memcpy to assign 4 bytes past
      the total size.
      
      The end result is that we overrun the total buffer size allocated by the
      kernel, which could lead to a panic or other issues due to memory
      corruption.
      
      It is difficult to determine the actual total number of registers
      here. The only 8255x datasheet I could find indicates there are 28 total
      MDI registers. However, we're reading 29 here, and reading them in
      reverse!
      
      In addition, the ethtool e100 register dump interface appears to read
      the first PHY register to determine if the device is in MDI or MDIx
      mode. This doesn't appear to be documented anywhere within the 8255x
      datasheet. I can only assume it must be in register 28 (the extra
      register we're reading here).
      
      Lets not change any of the intended meaning of what we copy here. Just
      extend the space by 4 bytes to account for the extra register and
      continue copying the data out in the same order.
      
      Change the E100_PHY_REGS value to be the correct total (29) so that the
      total register dump size is calculated properly. Fix the offset for
      where we copy the dump buffer so that it doesn't overrun the total size.
      
      Re-write the for loop to use counting up instead of the convoluted
      down-counting. Correct the mdio_read offset to use the 0-based register
      offsets, but maintain the bizarre reverse ordering so that we have the
      ABI expected by applications like ethtool. This requires and additional
      subtraction of 1. It seems a bit odd but it makes the flow of assignment
      into the register buffer easier to follow.
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Reported-by: default avatarFelicitas Hetzelt <felicitashetzelt@gmail.com>
      Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Tested-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      897d1401
    • Jacob Keller's avatar
      e100: fix length calculation in e100_get_regs_len · 93372e02
      Jacob Keller authored
      [ Upstream commit 4329c8dc ]
      
      commit abf9b902 ("e100: cleanup unneeded math") tried to simplify
      e100_get_regs_len and remove a double 'divide and then multiply'
      calculation that the e100_reg_regs_len function did.
      
      This change broke the size calculation entirely as it failed to account
      for the fact that the numbered registers are actually 4 bytes wide and
      not 1 byte. This resulted in a significant under allocation of the
      register buffer used by e100_get_regs.
      
      Fix this by properly multiplying the register count by u32 first before
      adding the size of the dump buffer.
      
      Fixes: abf9b902
      
       ("e100: cleanup unneeded math")
      Reported-by: default avatarFelicitas Hetzelt <felicitashetzelt@gmail.com>
      Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      93372e02
    • Xiao Liang's avatar
      net: ipv4: Fix rtnexthop len when RTA_FLOW is present · a2624e09
      Xiao Liang authored
      [ Upstream commit 597aa16c ]
      
      Multipath RTA_FLOW is embedded in nexthop. Dump it in fib_add_nexthop()
      to get the length of rtnexthop correct.
      
      Fixes: b0f60193
      
       ("ipv4: Refactor nexthop attributes in fib_dump_info")
      Signed-off-by: default avatarXiao Liang <shaw.leon@gmail.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a2624e09
    • Paul Fertser's avatar
      hwmon: (tmp421) fix rounding for negative values · c37d3287
      Paul Fertser authored
      [ Upstream commit 724e8af8 ]
      
      Old code produces -24999 for 0b1110011100000000 input in standard format due to
      always rounding up rather than "away from zero".
      
      Use the common macro for division, unify and simplify the conversion code along
      the way.
      
      Fixes: 9410700b
      
       ("hwmon: Add driver for Texas Instruments TMP421/422/423 sensor chips")
      Signed-off-by: default avatarPaul Fertser <fercerpav@gmail.com>
      Link: https://lore.kernel.org/r/20210924093011.26083-3-fercerpav@gmail.com
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c37d3287
    • Paul Fertser's avatar
      hwmon: (tmp421) report /PVLD condition as fault · 8a07d5ab
      Paul Fertser authored
      [ Upstream commit 540effa7 ]
      
      For both local and remote sensors all the supported ICs can report an
      "undervoltage lockout" condition which means the conversion wasn't
      properly performed due to insufficient power supply voltage and so the
      measurement results can't be trusted.
      
      Fixes: 9410700b
      
       ("hwmon: Add driver for Texas Instruments TMP421/422/423 sensor chips")
      Signed-off-by: default avatarPaul Fertser <fercerpav@gmail.com>
      Link: https://lore.kernel.org/r/20210924093011.26083-2-fercerpav@gmail.com
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8a07d5ab
    • Xin Long's avatar
      sctp: break out if skb_header_pointer returns NULL in sctp_rcv_ootb · ec018021
      Xin Long authored
      [ Upstream commit f7e745f8 ]
      
      We should always check if skb_header_pointer's return is NULL before
      using it, otherwise it may cause null-ptr-deref, as syzbot reported:
      
        KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]
        RIP: 0010:sctp_rcv_ootb net/sctp/input.c:705 [inline]
        RIP: 0010:sctp_rcv+0x1d84/0x3220 net/sctp/input.c:196
        Call Trace:
        <IRQ>
         sctp6_rcv+0x38/0x60 net/sctp/ipv6.c:1109
         ip6_protocol_deliver_rcu+0x2e9/0x1ca0 net/ipv6/ip6_input.c:422
         ip6_input_finish+0x62/0x170 net/ipv6/ip6_input.c:463
         NF_HOOK include/linux/netfilter.h:307 [inline]
         NF_HOOK include/linux/netfilter.h:301 [inline]
         ip6_input+0x9c/0xd0 net/ipv6/ip6_input.c:472
         dst_input include/net/dst.h:460 [inline]
         ip6_rcv_finish net/ipv6/ip6_input.c:76 [inline]
         NF_HOOK include/linux/netfilter.h:307 [inline]
         NF_HOOK include/linux/netfilter.h:301 [inline]
         ipv6_rcv+0x28c/0x3c0 net/ipv6/ip6_input.c:297
      
      Fixes: 3acb50c1
      
       ("sctp: delay as much as possible skb_linearize")
      Reported-by: default avatar <syzbot+581aff2ae6b860625116@syzkaller.appspotmail.com>
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Acked-by: default avatarMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ec018021
    • Johannes Berg's avatar
      mac80211-hwsim: fix late beacon hrtimer handling · 9bee85de
      Johannes Berg authored
      [ Upstream commit 313bbd19
      
       ]
      
      Thomas explained in https://lore.kernel.org/r/87mtoeb4hb.ffs@tglx
      that our handling of the hrtimer here is wrong: If the timer fires
      late (e.g. due to vCPU scheduling, as reported by Dmitry/syzbot)
      then it tries to actually rearm the timer at the next deadline,
      which might be in the past already:
      
       1          2          3          N          N+1
       |          |          |   ...    |          |
      
       ^ intended to fire here (1)
                  ^ next deadline here (2)
                                            ^ actually fired here
      
      The next time it fires, it's later, but will still try to schedule
      for the next deadline (now 3), etc. until it catches up with N,
      but that might take a long time, causing stalls etc.
      
      Now, all of this is simulation, so we just have to fix it, but
      note that the behaviour is wrong even per spec, since there's no
      value then in sending all those beacons unaligned - they should be
      aligned to the TBTT (1, 2, 3, ... in the picture), and if we're a
      bit (or a lot) late, then just resume at that point.
      
      Therefore, change the code to use hrtimer_forward_now() which will
      ensure that the next firing of the timer would be at N+1 (in the
      picture), i.e. the next interval point after the current time.
      
      Suggested-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reported-by: default avatarDmitry Vyukov <dvyukov@google.com>
      Reported-by: default avatar <syzbot+0e964fad69a9c462bc1e@syzkaller.appspotmail.com>
      Fixes: 01e59e46
      
       ("mac80211_hwsim: hrtimer beacon")
      Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Link: https://lore.kernel.org/r/20210915112936.544f383472eb.I3f9712009027aa09244b65399bf18bf482a8c4f1@changeid
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9bee85de
    • Johannes Berg's avatar
      mac80211: mesh: fix potentially unaligned access · 21c3a844
      Johannes Berg authored
      [ Upstream commit b9731062 ]
      
      The pointer here points directly into the frame, so the
      access is potentially unaligned. Use get_unaligned_le16
      to avoid that.
      
      Fixes: 3f52b7e3
      
       ("mac80211: mesh power save basics")
      Link: https://lore.kernel.org/r/20210920154009.3110ff75be0c.Ib6a2ff9e9cc9bc6fca50fce631ec1ce725cc926b@changeid
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      21c3a844
    • Lorenzo Bianconi's avatar
      mac80211: limit injected vht mcs/nss in ieee80211_parse_tx_radiotap · ab859974
      Lorenzo Bianconi authored
      [ Upstream commit 13cb6d82
      
       ]
      
      Limit max values for vht mcs and nss in ieee80211_parse_tx_radiotap
      routine in order to fix the following warning reported by syzbot:
      
      WARNING: CPU: 0 PID: 10717 at include/net/mac80211.h:989 ieee80211_rate_set_vht include/net/mac80211.h:989 [inline]
      WARNING: CPU: 0 PID: 10717 at include/net/mac80211.h:989 ieee80211_parse_tx_radiotap+0x101e/0x12d0 net/mac80211/tx.c:2244
      Modules linked in:
      CPU: 0 PID: 10717 Comm: syz-executor.5 Not tainted 5.14.0-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      RIP: 0010:ieee80211_rate_set_vht include/net/mac80211.h:989 [inline]
      RIP: 0010:ieee80211_parse_tx_radiotap+0x101e/0x12d0 net/mac80211/tx.c:2244
      RSP: 0018:ffffc9000186f3e8 EFLAGS: 00010216
      RAX: 0000000000000618 RBX: ffff88804ef76500 RCX: ffffc900143a5000
      RDX: 0000000000040000 RSI: ffffffff888f478e RDI: 0000000000000003
      RBP: 00000000ffffffff R08: 0000000000000000 R09: 0000000000000100
      R10: ffffffff888f46f9 R11: 0000000000000000 R12: 00000000fffffff8
      R13: ffff88804ef7653c R14: 0000000000000001 R15: 0000000000000004
      FS:  00007fbf5718f700(0000) GS:ffff8880b9c00000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 0000001b2de23000 CR3: 000000006a671000 CR4: 00000000001506f0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000600
      Call Trace:
       ieee80211_monitor_select_queue+0xa6/0x250 net/mac80211/iface.c:740
       netdev_core_pick_tx+0x169/0x2e0 net/core/dev.c:4089
       __dev_queue_xmit+0x6f9/0x3710 net/core/dev.c:4165
       __bpf_tx_skb net/core/filter.c:2114 [inline]
       __bpf_redirect_no_mac net/core/filter.c:2139 [inline]
       __bpf_redirect+0x5ba/0xd20 net/core/filter.c:2162
       ____bpf_clone_redirect net/core/filter.c:2429 [inline]
       bpf_clone_redirect+0x2ae/0x420 net/core/filter.c:2401
       bpf_prog_eeb6f53a69e5c6a2+0x59/0x234
       bpf_dispatcher_nop_func include/linux/bpf.h:717 [inline]
       __bpf_prog_run include/linux/filter.h:624 [inline]
       bpf_prog_run include/linux/filter.h:631 [inline]
       bpf_test_run+0x381/0xa30 net/bpf/test_run.c:119
       bpf_prog_test_run_skb+0xb84/0x1ee0 net/bpf/test_run.c:663
       bpf_prog_test_run kernel/bpf/syscall.c:3307 [inline]
       __sys_bpf+0x2137/0x5df0 kernel/bpf/syscall.c:4605
       __do_sys_bpf kernel/bpf/syscall.c:4691 [inline]
       __se_sys_bpf kernel/bpf/syscall.c:4689 [inline]
       __x64_sys_bpf+0x75/0xb0 kernel/bpf/syscall.c:4689
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      RIP: 0033:0x4665f9
      
      Reported-by: default avatar <syzbot+0196ac871673f0c20f68@syzkaller.appspotmail.com>
      Fixes: 646e76bb
      
       ("mac80211: parse VHT info in injected frames")
      Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
      Link: https://lore.kernel.org/r/c26c3f02dcb38ab63b2f2534cb463d95ee81bb13.1632141760.git.lorenzo@kernel.org
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ab859974
    • Chih-Kang Chang's avatar
      mac80211: Fix ieee80211_amsdu_aggregate frag_tail bug · 87e06c44
      Chih-Kang Chang authored
      [ Upstream commit fe94bac6 ]
      
      In ieee80211_amsdu_aggregate() set a pointer frag_tail point to the
      end of skb_shinfo(head)->frag_list, and use it to bind other skb in
      the end of this function. But when execute ieee80211_amsdu_aggregate()
      ->ieee80211_amsdu_realloc_pad()->pskb_expand_head(), the address of
      skb_shinfo(head)->frag_list will be changed. However, the
      ieee80211_amsdu_aggregate() not update frag_tail after call
      pskb_expand_head(). That will cause the second skb can't bind to the
      head skb appropriately.So we update the address of frag_tail to fix it.
      
      Fixes: 6e0456b5
      
       ("mac80211: add A-MSDU tx support")
      Signed-off-by: default avatarChih-Kang Chang <gary.chang@realtek.com>
      Signed-off-by: default avatarZong-Zhe Yang <kevin_yang@realtek.com>
      Signed-off-by: default avatarPing-Ke Shih <pkshih@realtek.com>
      Link: https://lore.kernel.org/r/20210830073240.12736-1-pkshih@realtek.com
      [reword comment]
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      87e06c44
    • Vadim Pasternak's avatar
      hwmon: (mlxreg-fan) Return non-zero value when fan current state is enforced from sysfs · a6c42ae1
      Vadim Pasternak authored
      [ Upstream commit e6fab7af ]
      
      Fan speed minimum can be enforced from sysfs. For example, setting
      current fan speed to 20 is used to enforce fan speed to be at 100%
      speed, 19 - to be not below 90% speed, etcetera. This feature provides
      ability to limit fan speed according to some system wise
      considerations, like absence of some replaceable units or high system
      ambient temperature.
      
      Request for changing fan minimum speed is configuration request and can
      be set only through 'sysfs' write procedure. In this situation value of
      argument 'state' is above nominal fan speed maximum.
      
      Return non-zero code in this case to avoid
      thermal_cooling_device_stats_update() call, because in this case
      statistics update violates thermal statistics table range.
      The issues is observed in case kernel is configured with option
      CONFIG_THERMAL_STATISTICS.
      
      Here is the trace from KASAN:
      [  159.506659] BUG: KASAN: slab-out-of-bounds in thermal_cooling_device_stats_update+0x7d/0xb0
      [  159.516016] Read of size 4 at addr ffff888116163840 by task hw-management.s/7444
      [  159.545625] Call Trace:
      [  159.548366]  dump_stack+0x92/0xc1
      [  159.552084]  ? thermal_cooling_device_stats_update+0x7d/0xb0
      [  159.635869]  thermal_zone_device_update+0x345/0x780
      [  159.688711]  thermal_zone_device_set_mode+0x7d/0xc0
      [  159.694174]  mlxsw_thermal_modules_init+0x48f/0x590 [mlxsw_core]
      [  159.700972]  ? mlxsw_thermal_set_cur_state+0x5a0/0x5a0 [mlxsw_core]
      [  159.731827]  mlxsw_thermal_init+0x763/0x880 [mlxsw_core]
      [  160.070233] RIP: 0033:0x7fd995909970
      [  160.074239] Code: 73 01 c3 48 8b 0d 28 d5 2b 00 f7 d8 64 89 01 48 83 c8 ff c3 66 0f 1f 44 00 00 83 3d 99 2d 2c 00 00 75 10 b8 01 00 00 00 0f 05 <48> 3d 01 f0 ff ..
      [  160.095242] RSP: 002b:00007fff54f5d938 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
      [  160.103722] RAX: ffffffffffffffda RBX: 0000000000000013 RCX: 00007fd995909970
      [  160.111710] RDX: 0000000000000013 RSI: 0000000001906008 RDI: 0000000000000001
      [  160.119699] RBP: 0000000001906008 R08: 00007fd995bc9760 R09: 00007fd996210700
      [  160.127687] R10: 0000000000000073 R11: 0000000000000246 R12: 0000000000000013
      [  160.135673] R13: 0000000000000001 R14: 00007fd995bc8600 R15: 0000000000000013
      [  160.143671]
      [  160.145338] Allocated by task 2924:
      [  160.149242]  kasan_save_stack+0x19/0x40
      [  160.153541]  __kasan_kmalloc+0x7f/0xa0
      [  160.157743]  __kmalloc+0x1a2/0x2b0
      [  160.161552]  thermal_cooling_device_setup_sysfs+0xf9/0x1a0
      [  160.167687]  __thermal_cooling_device_register+0x1b5/0x500
      [  160.173833]  devm_thermal_of_cooling_device_register+0x60/0xa0
      [  160.180356]  mlxreg_fan_probe+0x474/0x5e0 [mlxreg_fan]
      [  160.248140]
      [  160.249807] The buggy address belongs to the object at ffff888116163400
      [  160.249807]  which belongs to the cache kmalloc-1k of size 1024
      [  160.263814] The buggy address is located 64 bytes to the right of
      [  160.263814]  1024-byte region [ffff888116163400, ffff888116163800)
      [  160.277536] The buggy address belongs to the page:
      [  160.282898] page:0000000012275840 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff888116167000 pfn:0x116160
      [  160.294872] head:0000000012275840 order:3 compound_mapcount:0 compound_pincount:0
      [  160.303251] flags: 0x200000000010200(slab|head|node=0|zone=2)
      [  160.309694] raw: 0200000000010200 ffffea00046f7208 ffffea0004928208 ffff88810004dbc0
      [  160.318367] raw: ffff888116167000 00000000000a0006 00000001ffffffff 0000000000000000
      [  160.327033] page dumped because: kasan: bad access detected
      [  160.333270]
      [  160.334937] Memory state around the buggy address:
      [  160.356469] >ffff888116163800: fc ..
      
      Fixes: 65afb4c8
      
       ("hwmon: (mlxreg-fan) Add support for Mellanox FAN driver")
      Signed-off-by: default avatarVadim Pasternak <vadimp@nvidia.com>
      Link: https://lore.kernel.org/r/20210916183151.869427-1-vadimp@nvidia.com
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a6c42ae1
    • Andrea Claudi's avatar
      ipvs: check that ip_vs_conn_tab_bits is between 8 and 20 · 2c305922
      Andrea Claudi authored
      [ Upstream commit 69e73dbf ]
      
      ip_vs_conn_tab_bits may be provided by the user through the
      conn_tab_bits module parameter. If this value is greater than 31, or
      less than 0, the shift operator used to derive tab_size causes undefined
      behaviour.
      
      Fix this checking ip_vs_conn_tab_bits value to be in the range specified
      in ipvs Kconfig. If not, simply use default value.
      
      Fixes: 6f7edb48
      
       ("IPVS: Allow boot time change of hash size")
      Reported-by: default avatarYi Chen <yiche@redhat.com>
      Signed-off-by: default avatarAndrea Claudi <aclaudi@redhat.com>
      Acked-by: default avatarJulian Anastasov <ja@ssi.bg>
      Acked-by: default avatarSimon Horman <horms@verge.net.au>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2c305922
    • Charlene Liu's avatar
      drm/amd/display: Pass PCI deviceid into DC · 9a571d83
      Charlene Liu authored
      commit d9428568
      
       upstream.
      
      [why]
      pci deviceid not passed to dal dc, without proper break,
      dcn2.x falls into dcn3.x code path
      
      [how]
      pass in pci deviceid, and break once dal_version initialized.
      
      Reviewed-by: default avatarZhan Liu <Zhan.Liu@amd.com>
      Acked-by: default avatarAnson Jacob <Anson.Jacob@amd.com>
      Signed-off-by: default avatarCharlene Liu <Charlene.Liu@amd.com>
      Tested-by: default avatarDaniel Wheeler <daniel.wheeler@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9a571d83
    • Zelin Deng's avatar
      x86/kvmclock: Move this_cpu_pvti into kvmclock.h · 3443eb44
      Zelin Deng authored
      commit ad9af930
      
       upstream.
      
      There're other modules might use hv_clock_per_cpu variable like ptp_kvm,
      so move it into kvmclock.h and export the symbol to make it visiable to
      other modules.
      
      Signed-off-by: default avatarZelin Deng <zelin.deng@linux.alibaba.com>
      Cc: <stable@vger.kernel.org>
      Message-Id: <1632892429-101194-2-git-send-email-zelin.deng@linux.alibaba.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3443eb44
    • Johannes Berg's avatar
      mac80211: fix use-after-free in CCMP/GCMP RX · 50149e08
      Johannes Berg authored
      commit 94513069 upstream.
      
      When PN checking is done in mac80211, for fragmentation we need
      to copy the PN to the RX struct so we can later use it to do a
      comparison, since commit bf30ca92 ("mac80211: check defrag
      PN against current frame").
      
      Unfortunately, in that commit I used the 'hdr' variable without
      it being necessarily valid, so use-after-free could occur if it
      was necessary to reallocate (parts of) the frame.
      
      Fix this by reloading the variable after the code that results
      in the reallocations, if any.
      
      This fixes https://bugzilla.kernel.org/show_bug.cgi?id=214401.
      
      Cc: stable@vger.kernel.org
      Fixes: bf30ca92
      
       ("mac80211: check defrag PN against current frame")
      Link: https://lore.kernel.org/r/20210927115838.12b9ac6bb233.I1d066acd5408a662c3b6e828122cd314fcb28cdb@changeid
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      50149e08
    • Jonathan Hsu's avatar
      scsi: ufs: Fix illegal offset in UPIU event trace · 956bc3ee
      Jonathan Hsu authored
      commit e8c2da7e upstream.
      
      Fix incorrect index for UTMRD reference in ufshcd_add_tm_upiu_trace().
      
      Link: https://lore.kernel.org/r/20210924085848.25500-1-jonathan.hsu@mediatek.com
      Fixes: 4b42d557
      
       ("scsi: ufs: core: Fix wrong Task Tag used in task management request UPIUs")
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarStanley Chu <stanley.chu@mediatek.com>
      Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarJonathan Hsu <jonathan.hsu@mediatek.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      956bc3ee
    • Nadezda Lutovinova's avatar
      hwmon: (w83791d) Fix NULL pointer dereference by removing unnecessary structure field · 44d3c480
      Nadezda Lutovinova authored
      commit 943c15ac
      
       upstream.
      
      If driver read val value sufficient for
      (val & 0x08) && (!(val & 0x80)) && ((val & 0x7) == ((val >> 4) & 0x7))
      from device then Null pointer dereference occurs.
      (It is possible if tmp = 0b0xyz1xyz, where same literals mean same numbers)
      Also lm75[] does not serve a purpose anymore after switching to
      devm_i2c_new_dummy_device() in w83791d_detect_subclients().
      
      The patch fixes possible NULL pointer dereference by removing lm75[].
      
      Found by Linux Driver Verification project (linuxtesting.org).
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarNadezda Lutovinova <lutovinova@ispras.ru>
      Link: https://lore.kernel.org/r/20210921155153.28098-1-lutovinova@ispras.ru
      [groeck: Dropped unnecessary continuation lines, fixed multi-line alignment]
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      44d3c480
    • Nadezda Lutovinova's avatar
      hwmon: (w83792d) Fix NULL pointer dereference by removing unnecessary structure field · 200ced5b
      Nadezda Lutovinova authored
      commit 0f36b881
      
       upstream.
      
      If driver read val value sufficient for
      (val & 0x08) && (!(val & 0x80)) && ((val & 0x7) == ((val >> 4) & 0x7))
      from device then Null pointer dereference occurs.
      (It is possible if tmp = 0b0xyz1xyz, where same literals mean same numbers)
      Also lm75[] does not serve a purpose anymore after switching to
      devm_i2c_new_dummy_device() in w83791d_detect_subclients().
      
      The patch fixes possible NULL pointer dereference by removing lm75[].
      
      Found by Linux Driver Verification project (linuxtesting.org).
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarNadezda Lutovinova <lutovinova@ispras.ru>
      Link: https://lore.kernel.org/r/20210921155153.28098-2-lutovinova@ispras.ru
      [groeck: Dropped unnecessary continuation lines, fixed multipline alignment]
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      200ced5b
    • Nadezda Lutovinova's avatar
      hwmon: (w83793) Fix NULL pointer dereference by removing unnecessary structure field · 6cb01fe6
      Nadezda Lutovinova authored
      commit dd4d747e
      
       upstream.
      
      If driver read tmp value sufficient for
      (tmp & 0x08) && (!(tmp & 0x80)) && ((tmp & 0x7) == ((tmp >> 4) & 0x7))
      from device then Null pointer dereference occurs.
      (It is possible if tmp = 0b0xyz1xyz, where same literals mean same numbers)
      Also lm75[] does not serve a purpose anymore after switching to
      devm_i2c_new_dummy_device() in w83791d_detect_subclients().
      
      The patch fixes possible NULL pointer dereference by removing lm75[].
      
      Found by Linux Driver Verification project (linuxtesting.org).
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarNadezda Lutovinova <lutovinova@ispras.ru>
      Link: https://lore.kernel.org/r/20210921155153.28098-3-lutovinova@ispras.ru
      [groeck: Dropped unnecessary continuation lines, fixed multi-line alignments]
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6cb01fe6
    • Eric Biggers's avatar
      fs-verity: fix signed integer overflow with i_size near S64_MAX · 504cf969
      Eric Biggers authored
      commit 80f6e308
      
       upstream.
      
      If the file size is almost S64_MAX, the calculated number of Merkle tree
      levels exceeds FS_VERITY_MAX_LEVELS, causing FS_IOC_ENABLE_VERITY to
      fail.  This is unintentional, since as the comment above the definition
      of FS_VERITY_MAX_LEVELS states, it is enough for over U64_MAX bytes of
      data using SHA-256 and 4K blocks.  (Specifically, 4096*128**8 >= 2**64.)
      
      The bug is actually that when the number of blocks in the first level is
      calculated from i_size, there is a signed integer overflow due to i_size
      being signed.  Fix this by treating i_size as unsigned.
      
      This was found by the new test "generic: test fs-verity EFBIG scenarios"
      (https://lkml.kernel.org/r/b1d116cd4d0ea74b9cd86f349c672021e005a75c.1631558495.git.boris@bur.io).
      
      This didn't affect ext4 or f2fs since those have a smaller maximum file
      size, but it did affect btrfs which allows files up to S64_MAX bytes.
      
      Reported-by: default avatarBoris Burkov <boris@bur.io>
      Fixes: 3fda4c61 ("fs-verity: implement FS_IOC_ENABLE_VERITY ioctl")
      Fixes: fd2d1acf
      
       ("fs-verity: add the hook for file ->open()")
      Cc: <stable@vger.kernel.org> # v5.4+
      Reviewed-by: default avatarBoris Burkov <boris@bur.io>
      Link: https://lore.kernel.org/r/20210916203424.113376-1-ebiggers@kernel.org
      Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      504cf969