Skip to content
  1. Dec 08, 2022
    • Helge Deller's avatar
      parisc: Increase FRAME_WARN to 2048 bytes on parisc · 19d91d37
      Helge Deller authored
      [ Upstream commit 8d192bec
      
       ]
      
      PA-RISC uses a much bigger frame size for functions than other
      architectures. So increase it to 2048 for 32- and 64-bit kernels.
      This fixes e.g. a warning in lib/xxhash.c.
      
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Stable-dep-of: 152fe65f
      
       ("Kconfig.debug: provide a little extra FRAME_WARN leeway when KASAN is enabled")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      19d91d37
    • Guenter Roeck's avatar
      xtensa: increase size of gcc stack frame check · fcf20da0
      Guenter Roeck authored
      [ Upstream commit 86705024
      
       ]
      
      xtensa frame size is larger than the frame size for almost all other
      architectures.  This results in more than 50 "the frame size of <n> is
      larger than 1024 bytes" errors when trying to build xtensa:allmodconfig.
      
      Increase frame size for xtensa to 1536 bytes to avoid compile errors due
      to frame size limits.
      
      Link: https://lkml.kernel.org/r/20210912025235.3514761-1-linux@roeck-us.net
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Reviewed-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Masahiro Yamada <masahiroy@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Stable-dep-of: 152fe65f
      
       ("Kconfig.debug: provide a little extra FRAME_WARN leeway when KASAN is enabled")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fcf20da0
    • Helge Deller's avatar
      parisc: Increase size of gcc stack frame check · a1877001
      Helge Deller authored
      [ Upstream commit 55b70eed
      
       ]
      
      parisc uses much bigger frames than other architectures, so increase the
      stack frame check value to avoid compiler warnings.
      
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Abd-Alrhman Masalkhi <abd.masalkhi@gmail.com>
      Cc: Christoph Hellwig <hch@infradead.org>
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Stable-dep-of: 152fe65f
      
       ("Kconfig.debug: provide a little extra FRAME_WARN leeway when KASAN is enabled")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a1877001
    • Xiongfeng Wang's avatar
      iommu/vt-d: Fix PCI device refcount leak in dmar_dev_scope_init() · a5c65cd5
      Xiongfeng Wang authored
      [ Upstream commit 4bedbbd7 ]
      
      for_each_pci_dev() is implemented by pci_get_device(). The comment of
      pci_get_device() says that it will increase the reference count for the
      returned pci_dev and also decrease the reference count for the input
      pci_dev @from if it is not NULL.
      
      If we break for_each_pci_dev() loop with pdev not NULL, we need to call
      pci_dev_put() to decrease the reference count. Add the missing
      pci_dev_put() for the error path to avoid reference count leak.
      
      Fixes: 2e455289
      
       ("iommu/vt-d: Unify the way to process DMAR device scope array")
      Signed-off-by: default avatarXiongfeng Wang <wangxiongfeng2@huawei.com>
      Link: https://lore.kernel.org/r/20221121113649.190393-3-wangxiongfeng2@huawei.com
      Signed-off-by: default avatarLu Baolu <baolu.lu@linux.intel.com>
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a5c65cd5
    • Xiongfeng Wang's avatar
      iommu/vt-d: Fix PCI device refcount leak in has_external_pci() · 10ed7655
      Xiongfeng Wang authored
      [ Upstream commit afca9e19 ]
      
      for_each_pci_dev() is implemented by pci_get_device(). The comment of
      pci_get_device() says that it will increase the reference count for the
      returned pci_dev and also decrease the reference count for the input
      pci_dev @from if it is not NULL.
      
      If we break for_each_pci_dev() loop with pdev not NULL, we need to call
      pci_dev_put() to decrease the reference count. Add the missing
      pci_dev_put() before 'return true' to avoid reference count leak.
      
      Fixes: 89a6079d
      
       ("iommu/vt-d: Force IOMMU on for platform opt in hint")
      Signed-off-by: default avatarXiongfeng Wang <wangxiongfeng2@huawei.com>
      Link: https://lore.kernel.org/r/20221121113649.190393-2-wangxiongfeng2@huawei.com
      Signed-off-by: default avatarLu Baolu <baolu.lu@linux.intel.com>
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      10ed7655
    • Maxim Korotkov's avatar
      pinctrl: single: Fix potential division by zero · 302edce1
      Maxim Korotkov authored
      [ Upstream commit 64c15033 ]
      
      There is a possibility of dividing by zero due to the pcs->bits_per_pin
      if pcs->fmask() also has a value of zero and called fls
      from asm-generic/bitops/builtin-fls.h or arch/x86/include/asm/bitops.h.
      The function pcs_probe() has the branch that assigned to fmask 0 before
      pcs_allocate_pin_table() was called
      
      Found by Linux Verification Center (linuxtesting.org) with SVACE.
      
      Fixes: 4e7e8017
      
       ("pinctrl: pinctrl-single: enhance to configure multiple pins of different modules")
      Signed-off-by: default avatarMaxim Korotkov <korotkov.maxim.s@gmail.com>
      Reviewed-by: default avatarTony Lindgren <tony@atomide.com>
      Link: https://lore.kernel.org/r/20221117123034.27383-1-korotkov.maxim.s@gmail.com
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      302edce1
    • Mark Brown's avatar
      ASoC: ops: Fix bounds check for _sx controls · b50c9641
      Mark Brown authored
      [ Upstream commit 698813ba ]
      
      For _sx controls the semantics of the max field is not the usual one, max
      is the number of steps rather than the maximum value. This means that our
      check in snd_soc_put_volsw_sx() needs to just check against the maximum
      value.
      
      Fixes: 4f1e50d6
      
       ("ASoC: ops: Reject out of bounds values in snd_soc_put_volsw_sx()")
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Link: https://lore.kernel.org/r/20220511134137.169575-1-broonie@kernel.org
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b50c9641
    • Hao Xu's avatar
      io_uring: don't hold uring_lock when calling io_run_task_work* · a2efc465
      Hao Xu authored
      commit 8bad28d8
      
       upstream.
      
      Abaci reported the below issue:
      [  141.400455] hrtimer: interrupt took 205853 ns
      [  189.869316] process 'usr/local/ilogtail/ilogtail_0.16.26' started with executable stack
      [  250.188042]
      [  250.188327] ============================================
      [  250.189015] WARNING: possible recursive locking detected
      [  250.189732] 5.11.0-rc4 #1 Not tainted
      [  250.190267] --------------------------------------------
      [  250.190917] a.out/7363 is trying to acquire lock:
      [  250.191506] ffff888114dbcbe8 (&ctx->uring_lock){+.+.}-{3:3}, at: __io_req_task_submit+0x29/0xa0
      [  250.192599]
      [  250.192599] but task is already holding lock:
      [  250.193309] ffff888114dbfbe8 (&ctx->uring_lock){+.+.}-{3:3}, at: __x64_sys_io_uring_register+0xad/0x210
      [  250.194426]
      [  250.194426] other info that might help us debug this:
      [  250.195238]  Possible unsafe locking scenario:
      [  250.195238]
      [  250.196019]        CPU0
      [  250.196411]        ----
      [  250.196803]   lock(&ctx->uring_lock);
      [  250.197420]   lock(&ctx->uring_lock);
      [  250.197966]
      [  250.197966]  *** DEADLOCK ***
      [  250.197966]
      [  250.198837]  May be due to missing lock nesting notation
      [  250.198837]
      [  250.199780] 1 lock held by a.out/7363:
      [  250.200373]  #0: ffff888114dbfbe8 (&ctx->uring_lock){+.+.}-{3:3}, at: __x64_sys_io_uring_register+0xad/0x210
      [  250.201645]
      [  250.201645] stack backtrace:
      [  250.202298] CPU: 0 PID: 7363 Comm: a.out Not tainted 5.11.0-rc4 #1
      [  250.203144] Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011
      [  250.203887] Call Trace:
      [  250.204302]  dump_stack+0xac/0xe3
      [  250.204804]  __lock_acquire+0xab6/0x13a0
      [  250.205392]  lock_acquire+0x2c3/0x390
      [  250.205928]  ? __io_req_task_submit+0x29/0xa0
      [  250.206541]  __mutex_lock+0xae/0x9f0
      [  250.207071]  ? __io_req_task_submit+0x29/0xa0
      [  250.207745]  ? 0xffffffffa0006083
      [  250.208248]  ? __io_req_task_submit+0x29/0xa0
      [  250.208845]  ? __io_req_task_submit+0x29/0xa0
      [  250.209452]  ? __io_req_task_submit+0x5/0xa0
      [  250.210083]  __io_req_task_submit+0x29/0xa0
      [  250.210687]  io_async_task_func+0x23d/0x4c0
      [  250.211278]  task_work_run+0x89/0xd0
      [  250.211884]  io_run_task_work_sig+0x50/0xc0
      [  250.212464]  io_sqe_files_unregister+0xb2/0x1f0
      [  250.213109]  __io_uring_register+0x115a/0x1750
      [  250.213718]  ? __x64_sys_io_uring_register+0xad/0x210
      [  250.214395]  ? __fget_files+0x15a/0x260
      [  250.214956]  __x64_sys_io_uring_register+0xbe/0x210
      [  250.215620]  ? trace_hardirqs_on+0x46/0x110
      [  250.216205]  do_syscall_64+0x2d/0x40
      [  250.216731]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
      [  250.217455] RIP: 0033:0x7f0fa17e5239
      [  250.218034] Code: 01 00 48 81 c4 80 00 00 00 e9 f1 fe ff ff 0f 1f 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05  3d 01 f0 ff ff 73 01 c3 48 8b 0d 27 ec 2c 00 f7 d8 64 89 01 48
      [  250.220343] RSP: 002b:00007f0fa1eeac48 EFLAGS: 00000246 ORIG_RAX: 00000000000001ab
      [  250.221360] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f0fa17e5239
      [  250.222272] RDX: 0000000000000000 RSI: 0000000000000003 RDI: 0000000000000008
      [  250.223185] RBP: 00007f0fa1eeae20 R08: 0000000000000000 R09: 0000000000000000
      [  250.224091] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
      [  250.224999] R13: 0000000000021000 R14: 0000000000000000 R15: 00007f0fa1eeb700
      
      This is caused by calling io_run_task_work_sig() to do work under
      uring_lock while the caller io_sqe_files_unregister() already held
      uring_lock.
      To fix this issue, briefly drop uring_lock when calling
      io_run_task_work_sig(), and there are two things to concern:
      
      - hold uring_lock in io_ring_ctx_free() around io_sqe_files_unregister()
          this is for consistency of lock/unlock.
      - add new fixed rsrc ref node before dropping uring_lock
          it's not safe to do io_uring_enter-->percpu_ref_get() with a dying one.
      - check if rsrc_data->refs is dying to avoid parallel io_sqe_files_unregister
      
      Reported-by: default avatarAbaci <abaci@linux.alibaba.com>
      Fixes: 1ffc5422
      
       ("io_uring: fix io_sqe_files_unregister() hangs")
      Suggested-by: default avatarPavel Begunkov <asml.silence@gmail.com>
      Signed-off-by: default avatarHao Xu <haoxu@linux.alibaba.com>
      [axboe: fixes from Pavel folded in]
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarSamiullah Khawaja <skhawaja@google.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a2efc465
    • Steven Rostedt (Google)'s avatar
      tracing: Free buffers when a used dynamic event is removed · be111ebd
      Steven Rostedt (Google) authored
      commit 4313e5a6 upstream.
      
      After 65536 dynamic events have been added and removed, the "type" field
      of the event then uses the first type number that is available (not
      currently used by other events). A type number is the identifier of the
      binary blobs in the tracing ring buffer (known as events) to map them to
      logic that can parse the binary blob.
      
      The issue is that if a dynamic event (like a kprobe event) is traced and
      is in the ring buffer, and then that event is removed (because it is
      dynamic, which means it can be created and destroyed), if another dynamic
      event is created that has the same number that new event's logic on
      parsing the binary blob will be used.
      
      To show how this can be an issue, the following can crash the kernel:
      
       # cd /sys/kernel/tracing
       # for i in `seq 65536`; do
           echo 'p:kprobes/foo do_sys_openat2 $arg1:u32' > kprobe_events
       # done
      
      For every iteration of the above, the writing to the kprobe_events will
      remove the old event and create a new one (with the same format) and
      increase the type number to the next available on until the type number
      reaches over 65535 which is the max number for the 16 bit type. After it
      reaches that number, the logic to allocate a new number simply looks for
      the next available number. When an dynamic event is removed, that number
      is then available to be reused by the next dynamic event created. That is,
      once the above reaches the max number, the number assigned to the event in
      that loop will remain the same.
      
      Now that means deleting one dynamic event and created another will reuse
      the previous events type number. This is where bad things can happen.
      After the above loop finishes, the kprobes/foo event which reads the
      do_sys_openat2 function call's first parameter as an integer.
      
       # echo 1 > kprobes/foo/enable
       # cat /etc/passwd > /dev/null
       # cat trace
                   cat-2211    [005] ....  2007.849603: foo: (do_sys_openat2+0x0/0x130) arg1=4294967196
                   cat-2211    [005] ....  2007.849620: foo: (do_sys_openat2+0x0/0x130) arg1=4294967196
                   cat-2211    [005] ....  2007.849838: foo: (do_sys_openat2+0x0/0x130) arg1=4294967196
                   cat-2211    [005] ....  2007.849880: foo: (do_sys_openat2+0x0/0x130) arg1=4294967196
       # echo 0 > kprobes/foo/enable
      
      Now if we delete the kprobe and create a new one that reads a string:
      
       # echo 'p:kprobes/foo do_sys_openat2 +0($arg2):string' > kprobe_events
      
      And now we can the trace:
      
       # cat trace
              sendmail-1942    [002] .....   530.136320: foo: (do_sys_openat2+0x0/0x240) arg1=             cat-2046    [004] .....   530.930817: foo: (do_sys_openat2+0x0/0x240) arg1="������������������������������������������������������������������������������������������������"
                   cat-2046    [004] .....   530.930961: foo: (do_sys_openat2+0x0/0x240) arg1="������������������������������������������������������������������������������������������������"
                   cat-2046    [004] .....   530.934278: foo: (do_sys_openat2+0x0/0x240) arg1="������������������������������������������������������������������������������������������������"
                   cat-2046    [004] .....   530.934563: foo: (do_sys_openat2+0x0/0x240) arg1="������������������������������������������������������������������������������������������������"
                  bash-1515    [007] .....   534.299093: foo: (do_sys_openat2+0x0/0x240) arg1="kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk���������@��4Z����;Y�����U
      
      And dmesg has:
      
      ==================================================================
      BUG: KASAN: use-after-free in string+0xd4/0x1c0
      Read of size 1 at addr ffff88805fdbbfa0 by task cat/2049
      
       CPU: 0 PID: 2049 Comm: cat Not tainted 6.1.0-rc6-test+ #641
       Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS K01 v03.03 07/14/2016
       Call Trace:
        <TASK>
        dump_stack_lvl+0x5b/0x77
        print_report+0x17f/0x47b
        kasan_report+0xad/0x130
        string+0xd4/0x1c0
        vsnprintf+0x500/0x840
        seq_buf_vprintf+0x62/0xc0
        trace_seq_printf+0x10e/0x1e0
        print_type_string+0x90/0xa0
        print_kprobe_event+0x16b/0x290
        print_trace_line+0x451/0x8e0
        s_show+0x72/0x1f0
        seq_read_iter+0x58e/0x750
        seq_read+0x115/0x160
        vfs_read+0x11d/0x460
        ksys_read+0xa9/0x130
        do_syscall_64+0x3a/0x90
        entry_SYSCALL_64_after_hwframe+0x63/0xcd
       RIP: 0033:0x7fc2e972ade2
       Code: c0 e9 b2 fe ff ff 50 48 8d 3d b2 3f 0a 00 e8 05 f0 01 00 0f 1f 44 00 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 0f 05 <48> 3d 00 f0 ff ff 77 56 c3 0f 1f 44 00 00 48 83 ec 28 48 89 54 24
       RSP: 002b:00007ffc64e687c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
       RAX: ffffffffffffffda RBX: 0000000000020000 RCX: 00007fc2e972ade2
       RDX: 0000000000020000 RSI: 00007fc2e980d000 RDI: 0000000000000003
       RBP: 00007fc2e980d000 R08: 00007fc2e980c010 R09: 0000000000000000
       R10: 0000000000000022 R11: 0000000000000246 R12: 0000000000020f00
       R13: 0000000000000003 R14: 0000000000020000 R15: 0000000000020000
        </TASK>
      
       The buggy address belongs to the physical page:
       page:ffffea00017f6ec0 refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x5fdbb
       flags: 0xfffffc0000000(node=0|zone=1|lastcpupid=0x1fffff)
       raw: 000fffffc0000000 0000000000000000 ffffea00017f6ec8 0000000000000000
       raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
       page dumped because: kasan: bad access detected
      
       Memory state around the buggy address:
        ffff88805fdbbe80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
        ffff88805fdbbf00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
       >ffff88805fdbbf80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
                                      ^
        ffff88805fdbc000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
        ffff88805fdbc080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
       ==================================================================
      
      This was found when Zheng Yejian sent a patch to convert the event type
      number assignment to use IDA, which gives the next available number, and
      this bug showed up in the fuzz testing by Yujie Liu and the kernel test
      robot. But after further analysis, I found that this behavior is the same
      as when the event type numbers go past the 16bit max (and the above shows
      that).
      
      As modules have a similar issue, but is dealt with by setting a
      "WAS_ENABLED" flag when a module event is enabled, and when the module is
      freed, if any of its events were enabled, the ring buffer that holds that
      event is also cleared, to prevent reading stale events. The same can be
      done for dynamic events.
      
      If any dynamic event that is being removed was enabled, then make sure the
      buffers they were enabled in are now cleared.
      
      Link: https://lkml.kernel.org/r/20221123171434.545706e3@gandalf.local.home
      Link: https://lore.kernel.org/all/20221110020319.1259291-1-zhengyejian1@huawei.com/
      
      Cc: stable@vger.kernel.org
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Depends-on: e18eb878 ("tracing: Add tracing_reset_all_online_cpus_unlocked() function")
      Depends-on: 5448d44c ("tracing: Add unified dynamic event framework")
      Depends-on: 6212dd29 ("tracing/kprobes: Use dyn_event framework for kprobe events")
      Depends-on: 065e63f9 ("tracing: Only have rmmod clear buffers that its events were active in")
      Depends-on: 575380da ("tracing: Only clear trace buffer on module unload if event was traced")
      Fixes: 77b44d1b
      
       ("tracing/kprobes: Rename Kprobe-tracer to kprobe-event")
      Reported-by: default avatarZheng Yejian <zhengyejian1@huawei.com>
      Reported-by: default avatarYujie Liu <yujie.liu@intel.com>
      Reported-by: default avatarkernel test robot <yujie.liu@intel.com>
      Acked-by: default avatarMasami Hiramatsu (Google) <mhiramat@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      be111ebd
    • Janusz Krzysztofik's avatar
      drm/i915: Never return 0 if not all requests retired · 648b92e5
      Janusz Krzysztofik authored
      commit 12b8b046 upstream.
      
      Users of intel_gt_retire_requests_timeout() expect 0 return value on
      success.  However, we have no protection from passing back 0 potentially
      returned by a call to dma_fence_wait_timeout() when it succedes right
      after its timeout has expired.
      
      Replace 0 with -ETIME before potentially using the timeout value as return
      code, so -ETIME is returned if there are still some requests not retired
      after timeout, 0 otherwise.
      
      v3: Use conditional expression, more compact but also better reflecting
          intention standing behind the change.
      
      v2: Move the added lines down so flush_submission() is not affected.
      
      Fixes: f33a8a51
      
       ("drm/i915: Merge wait_for_timelines with retire_request")
      Signed-off-by: default avatarJanusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
      Reviewed-by: default avatarAndrzej Hajda <andrzej.hajda@intel.com>
      Cc: stable@vger.kernel.org # v5.5+
      Signed-off-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20221121145655.75141-3-janusz.krzysztofik@linux.intel.com
      (cherry picked from commit f301a29f
      
      )
      Signed-off-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      648b92e5
    • Lee Jones's avatar
      drm/amdgpu: temporarily disable broken Clang builds due to blown stack-frame · 8649c023
      Lee Jones authored
      commit 6f6cb171 upstream.
      
      Patch series "Fix a bunch of allmodconfig errors", v2.
      
      Since b339ec9c
      
       ("kbuild: Only default to -Werror if COMPILE_TEST")
      WERROR now defaults to COMPILE_TEST meaning that it's enabled for
      allmodconfig builds.  This leads to some interesting build failures when
      using Clang, each resolved in this set.
      
      With this set applied, I am able to obtain a successful allmodconfig Arm
      build.
      
      
      This patch (of 2):
      
      calculate_bandwidth() is presently broken on all !(X86_64 || SPARC64 ||
      ARM64) architectures built with Clang (all released versions), whereby the
      stack frame gets blown up to well over 5k.  This would cause an immediate
      kernel panic on most architectures.  We'll revert this when the following
      bug report has been resolved:
      https://github.com/llvm/llvm-project/issues/41896.
      
      Link: https://lkml.kernel.org/r/20221125120750.3537134-1-lee@kernel.org
      Link: https://lkml.kernel.org/r/20221125120750.3537134-2-lee@kernel.org
      Signed-off-by: default avatarLee Jones <lee@kernel.org>
      Suggested-by: default avatarArnd Bergmann <arnd@arndb.de>
      Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Cc: "Christian König" <christian.koenig@amd.com>
      Cc: Daniel Vetter <daniel@ffwll.ch>
      Cc: David Airlie <airlied@gmail.com>
      Cc: Harry Wentland <harry.wentland@amd.com>
      Cc: Lee Jones <lee@kernel.org>
      Cc: Leo Li <sunpeng.li@amd.com>
      Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Cc: Maxime Ripard <mripard@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: "Pan, Xinhui" <Xinhui.Pan@amd.com>
      Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
      Cc: Thomas Zimmermann <tzimmermann@suse.de>
      Cc: Tom Rix <trix@redhat.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8649c023
    • Adrian Hunter's avatar
      mmc: sdhci: Fix voltage switch delay · 940b7740
      Adrian Hunter authored
      commit c981cdfb upstream.
      
      Commit 20b92a30 ("mmc: sdhci: update signal voltage switch code")
      removed voltage switch delays from sdhci because mmc core had been
      enhanced to support them. However that assumed that sdhci_set_ios()
      did a single clock change, which it did not, and so the delays in mmc
      core, which should have come after the first clock change, were not
      effective.
      
      Fix by avoiding re-configuring UHS and preset settings when the clock
      is turning on and the settings have not changed. That then also avoids
      the associated clock changes, so that then sdhci_set_ios() does a single
      clock change when voltage switching, and the mmc core delays become
      effective.
      
      To do that has meant keeping track of driver strength (host->drv_type),
      and cases of reinitialization (host->reinit_uhs).
      
      Note also, the 'turning_on_clk' restriction should not be necessary
      but is done to minimize the impact of the change on stable kernels.
      
      Fixes: 20b92a30
      
       ("mmc: sdhci: update signal voltage switch code")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Link: https://lore.kernel.org/r/20221128133259.38305-2-adrian.hunter@intel.com
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      940b7740
    • Wenchao Chen's avatar
      mmc: sdhci-sprd: Fix no reset data and command after voltage switch · ed196624
      Wenchao Chen authored
      commit dd30dcfa upstream.
      
      After switching the voltage, no reset data and command will cause
      CMD2 timeout.
      
      Fixes: 29ca763f
      
       ("mmc: sdhci-sprd: Add pin control support for voltage switch")
      Signed-off-by: default avatarWenchao Chen <wenchao.chen@unisoc.com>
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Reviewed-by: default avatarBaolin Wang <baolin.wang@linux.alibaba.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20221130121328.25553-1-wenchao.chen@unisoc.com
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ed196624
    • Sebastian Falbesoner's avatar
      mmc: sdhci-esdhc-imx: correct CQHCI exit halt state check · ef767907
      Sebastian Falbesoner authored
      commit a3cab1d2 upstream.
      
      With the current logic the "failed to exit halt state" error would be
      shown even if any other bit than CQHCI_HALT was set in the CQHCI_CTL
      register, since the right hand side is always true. Fix this by using
      the correct operator (bit-wise instead of logical AND) to only check for
      the halt bit flag, which was obviously intended here.
      
      Fixes: 85236d2b
      
       ("mmc: sdhci-esdhc-imx: clear the HALT bit when enable CQE")
      Signed-off-by: default avatarSebastian Falbesoner <sebastian.falbesoner@gmail.com>
      Acked-by: default avatarHaibo Chen <haibo.chen@nxp.com>
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20221121105721.1903878-1-sebastian.falbesoner@gmail.com
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ef767907
    • Christian Löhle's avatar
      mmc: core: Fix ambiguous TRIM and DISCARD arg · 46ee041c
      Christian Löhle authored
      commit 489d1445 upstream.
      
      Clean up the MMC_TRIM_ARGS define that became ambiguous with DISCARD
      introduction.  While at it, let's fix one usage where MMC_TRIM_ARGS falsely
      included DISCARD too.
      
      Fixes: b3bf9153
      
       ("mmc: core: new discard feature support at eMMC v4.5")
      Signed-off-by: default avatarChristian Loehle <cloehle@hyperstone.com>
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/11376b5714964345908f3990f17e0701@hyperstone.com
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      46ee041c
    • Ye Bin's avatar
      mmc: mmc_test: Fix removal of debugfs file · b79be962
      Ye Bin authored
      commit f4307b4d upstream.
      
      In __mmc_test_register_dbgfs_file(), we need to assign 'file', as it's
      being used when removing the debugfs files when the mmc_test module is
      removed.
      
      Fixes: a04c50aa
      
       ("mmc: core: no need to check return value of debugfs_create functions")
      Signed-off-by: default avatarYe Bin <yebin10@huawei.com>
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: stable@vger.kernel.org
      [Ulf: Re-wrote the commit msg]
      Link: https://lore.kernel.org/r/20221123095506.1965691-1-yebin@huaweicloud.com
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b79be962
    • Goh, Wei Sheng's avatar
      net: stmmac: Set MAC's flow control register to reflect current settings · d4fc344c
      Goh, Wei Sheng authored
      commit cc3d2b5f upstream.
      
      Currently, pause frame register GMAC_RX_FLOW_CTRL_RFE is not updated
      correctly when 'ethtool -A <IFACE> autoneg off rx off tx off' command
      is issued. This fix ensures the flow control change is reflected directly
      in the GMAC_RX_FLOW_CTRL_RFE register.
      
      Fixes: 46f69ded
      
       ("net: stmmac: Use resolved link config in mac_link_up()")
      Cc: <stable@vger.kernel.org> # 5.10.x
      Signed-off-by: default avatarGoh, Wei Sheng <wei.sheng.goh@intel.com>
      Signed-off-by: default avatarNoor Azura Ahmad Tarmizi <noor.azura.ahmad.tarmizi@intel.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d4fc344c
    • Andy Shevchenko's avatar
      pinctrl: intel: Save and restore pins in "direct IRQ" mode · 549e2440
      Andy Shevchenko authored
      commit 6989ea48
      
       upstream.
      
      The firmware on some systems may configure GPIO pins to be
      an interrupt source in so called "direct IRQ" mode. In such
      cases the GPIO controller driver has no idea if those pins
      are being used or not. At the same time, there is a known bug
      in the firmwares that don't restore the pin settings correctly
      after suspend, i.e. by an unknown reason the Rx value becomes
      inverted.
      
      Hence, let's save and restore the pins that are configured
      as GPIOs in the input mode with GPIROUTIOXAPIC bit set.
      
      Cc: stable@vger.kernel.org
      Reported-and-tested-by: default avatarDale Smith <dalepsmith@gmail.com>
      Reported-and-tested-by: default avatarJohn Harris <jmharris@gmail.com>
      BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=214749
      Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Acked-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
      Link: https://lore.kernel.org/r/20221124222926.72326-1-andriy.shevchenko@linux.intel.com
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      549e2440
    • Pawan Gupta's avatar
      x86/bugs: Make sure MSR_SPEC_CTRL is updated properly upon resume from S3 · 471fb7b7
      Pawan Gupta authored
      commit 66065157 upstream.
      
      The "force" argument to write_spec_ctrl_current() is currently ambiguous
      as it does not guarantee the MSR write. This is due to the optimization
      that writes to the MSR happen only when the new value differs from the
      cached value.
      
      This is fine in most cases, but breaks for S3 resume when the cached MSR
      value gets out of sync with the hardware MSR value due to S3 resetting
      it.
      
      When x86_spec_ctrl_current is same as x86_spec_ctrl_base, the MSR write
      is skipped. Which results in SPEC_CTRL mitigations not getting restored.
      
      Move the MSR write from write_spec_ctrl_current() to a new function that
      unconditionally writes to the MSR. Update the callers accordingly and
      rename functions.
      
        [ bp: Rework a bit. ]
      
      Fixes: caa0ff24
      
       ("x86/bugs: Keep a per-CPU IA32_SPEC_CTRL value")
      Suggested-by: default avatarBorislav Petkov <bp@alien8.de>
      Signed-off-by: default avatarPawan Gupta <pawan.kumar.gupta@linux.intel.com>
      Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
      Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: <stable@kernel.org>
      Link: https://lore.kernel.org/r/806d39b0bfec2fe8f50dc5446dff20f5bb24a959.1669821572.git.pawan.kumar.gupta@linux.intel.com
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      471fb7b7
    • ZhangPeng's avatar
      nilfs2: fix NULL pointer dereference in nilfs_palloc_commit_free_entry() · e858917a
      ZhangPeng authored
      commit f0a0ccda
      
       upstream.
      
      Syzbot reported a null-ptr-deref bug:
      
       NILFS (loop0): segctord starting. Construction interval = 5 seconds, CP
       frequency < 30 seconds
       general protection fault, probably for non-canonical address
       0xdffffc0000000002: 0000 [#1] PREEMPT SMP KASAN
       KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017]
       CPU: 1 PID: 3603 Comm: segctord Not tainted
       6.1.0-rc2-syzkaller-00105-gb229b6ca5abb #0
       Hardware name: Google Compute Engine/Google Compute Engine, BIOS Google
       10/11/2022
       RIP: 0010:nilfs_palloc_commit_free_entry+0xe5/0x6b0
       fs/nilfs2/alloc.c:608
       Code: 00 00 00 00 fc ff df 80 3c 02 00 0f 85 cd 05 00 00 48 b8 00 00 00
       00 00 fc ff df 4c 8b 73 08 49 8d 7e 10 48 89 fa 48 c1 ea 03 <80> 3c 02
       00 0f 85 26 05 00 00 49 8b 46 10 be a6 00 00 00 48 c7 c7
       RSP: 0018:ffffc90003dff830 EFLAGS: 00010212
       RAX: dffffc0000000000 RBX: ffff88802594e218 RCX: 000000000000000d
       RDX: 0000000000000002 RSI: 0000000000002000 RDI: 0000000000000010
       RBP: ffff888071880222 R08: 0000000000000005 R09: 000000000000003f
       R10: 000000000000000d R11: 0000000000000000 R12: ffff888071880158
       R13: ffff88802594e220 R14: 0000000000000000 R15: 0000000000000004
       FS:  0000000000000000(0000) GS:ffff8880b9b00000(0000)
       knlGS:0000000000000000
       CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
       CR2: 00007fb1c08316a8 CR3: 0000000018560000 CR4: 0000000000350ee0
       Call Trace:
        <TASK>
        nilfs_dat_commit_free fs/nilfs2/dat.c:114 [inline]
        nilfs_dat_commit_end+0x464/0x5f0 fs/nilfs2/dat.c:193
        nilfs_dat_commit_update+0x26/0x40 fs/nilfs2/dat.c:236
        nilfs_btree_commit_update_v+0x87/0x4a0 fs/nilfs2/btree.c:1940
        nilfs_btree_commit_propagate_v fs/nilfs2/btree.c:2016 [inline]
        nilfs_btree_propagate_v fs/nilfs2/btree.c:2046 [inline]
        nilfs_btree_propagate+0xa00/0xd60 fs/nilfs2/btree.c:2088
        nilfs_bmap_propagate+0x73/0x170 fs/nilfs2/bmap.c:337
        nilfs_collect_file_data+0x45/0xd0 fs/nilfs2/segment.c:568
        nilfs_segctor_apply_buffers+0x14a/0x470 fs/nilfs2/segment.c:1018
        nilfs_segctor_scan_file+0x3f4/0x6f0 fs/nilfs2/segment.c:1067
        nilfs_segctor_collect_blocks fs/nilfs2/segment.c:1197 [inline]
        nilfs_segctor_collect fs/nilfs2/segment.c:1503 [inline]
        nilfs_segctor_do_construct+0x12fc/0x6af0 fs/nilfs2/segment.c:2045
        nilfs_segctor_construct+0x8e3/0xb30 fs/nilfs2/segment.c:2379
        nilfs_segctor_thread_construct fs/nilfs2/segment.c:2487 [inline]
        nilfs_segctor_thread+0x3c3/0xf30 fs/nilfs2/segment.c:2570
        kthread+0x2e4/0x3a0 kernel/kthread.c:376
        ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306
        </TASK>
       ...
      
      If DAT metadata file is corrupted on disk, there is a case where
      req->pr_desc_bh is NULL and blocknr is 0 at nilfs_dat_commit_end() during
      a b-tree operation that cascadingly updates ancestor nodes of the b-tree,
      because nilfs_dat_commit_alloc() for a lower level block can initialize
      the blocknr on the same DAT entry between nilfs_dat_prepare_end() and
      nilfs_dat_commit_end().
      
      If this happens, nilfs_dat_commit_end() calls nilfs_dat_commit_free()
      without valid buffer heads in req->pr_desc_bh and req->pr_bitmap_bh, and
      causes the NULL pointer dereference above in
      nilfs_palloc_commit_free_entry() function, which leads to a crash.
      
      Fix this by adding a NULL check on req->pr_desc_bh and req->pr_bitmap_bh
      before nilfs_palloc_commit_free_entry() in nilfs_dat_commit_free().
      
      This also calls nilfs_error() in that case to notify that there is a fatal
      flaw in the filesystem metadata and prevent further operations.
      
      Link: https://lkml.kernel.org/r/00000000000097c20205ebaea3d6@google.com
      Link: https://lkml.kernel.org/r/20221114040441.1649940-1-zhangpeng362@huawei.com
      Link: https://lkml.kernel.org/r/20221119120542.17204-1-konishi.ryusuke@gmail.com
      Signed-off-by: default avatarZhangPeng <zhangpeng362@huawei.com>
      Signed-off-by: default avatarRyusuke Konishi <konishi.ryusuke@gmail.com>
      Reported-by: default avatar <syzbot+ebe05ee8e98f755f61d0@syzkaller.appspotmail.com>
      Tested-by: default avatarRyusuke Konishi <konishi.ryusuke@gmail.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e858917a
    • Tiezhu Yang's avatar
      tools/vm/slabinfo-gnuplot: use "grep -E" instead of "egrep" · 6ddf7884
      Tiezhu Yang authored
      commit a435874b
      
       upstream.
      
      The latest version of grep claims the egrep is now obsolete so the build
      now contains warnings that look like:
      
      	egrep: warning: egrep is obsolescent; using grep -E
      
      fix this up by moving the related file to use "grep -E" instead.
      
        sed -i "s/egrep/grep -E/g" `grep egrep -rwl tools/vm`
      
      Here are the steps to install the latest grep:
      
        wget http://ftp.gnu.org/gnu/grep/grep-3.8.tar.gz
        tar xf grep-3.8.tar.gz
        cd grep-3.8 && ./configure && make
        sudo make install
        export PATH=/usr/local/bin:$PATH
      
      Link: https://lkml.kernel.org/r/1668825419-30584-1-git-send-email-yangtiezhu@loongson.cn
      Signed-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
      Reviewed-by: default avatarSergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6ddf7884
    • Steven Rostedt (Google)'s avatar
      error-injection: Add prompt for function error injection · c099d12c
      Steven Rostedt (Google) authored
      commit a4412fdd upstream.
      
      The config to be able to inject error codes into any function annotated
      with ALLOW_ERROR_INJECTION() is enabled when FUNCTION_ERROR_INJECTION is
      enabled.  But unfortunately, this is always enabled on x86 when KPROBES
      is enabled, and there's no way to turn it off.
      
      As kprobes is useful for observability of the kernel, it is useful to
      have it enabled in production environments.  But error injection should
      be avoided.  Add a prompt to the config to allow it to be disabled even
      when kprobes is enabled, and get rid of the "def_bool y".
      
      This is a kernel debug feature (it's in Kconfig.debug), and should have
      never been something enabled by default.
      
      Cc: stable@vger.kernel.org
      Fixes: 540adea3
      
       ("error-injection: Separate error-injection from kprobe")
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c099d12c
    • Jisheng Zhang's avatar
      riscv: vdso: fix section overlapping under some conditions · 26b6f927
      Jisheng Zhang authored
      commit 74f6bb55
      
       upstream.
      
      lkp reported a build error, I tried the config and can reproduce
      build error as below:
      
        VDSOLD  arch/riscv/kernel/vdso/vdso.so.dbg
      ld.lld: error: section .note file range overlaps with .text
      >>> .note range is [0x7C8, 0x803]
      >>> .text range is [0x800, 0x1993]
      
      ld.lld: error: section .text file range overlaps with .dynamic
      >>> .text range is [0x800, 0x1993]
      >>> .dynamic range is [0x808, 0x937]
      
      ld.lld: error: section .note virtual address range overlaps with .text
      >>> .note range is [0x7C8, 0x803]
      >>> .text range is [0x800, 0x1993]
      
      Fix it by setting DISABLE_BRANCH_PROFILING which will disable branch
      tracing for vdso, thus avoid useless _ftrace_annotated_branch section
      and _ftrace_branch section. Although we can also fix it by removing
      the hardcoded .text begin address, but I think that's another story
      and should be put into another patch.
      
      Link: https://lore.kernel.org/lkml/202210122123.Cc4FPShJ-lkp@intel.com/#r
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarJisheng Zhang <jszhang@kernel.org>
      Link: https://lore.kernel.org/r/20221102170254.1925-1-jszhang@kernel.org
      Fixes: ad5d1122
      
       ("riscv: use vDSO common flow to reduce the latency of the time-related functions")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      26b6f927
    • YueHaibing's avatar
      net/mlx5: DR, Fix uninitialized var warning · 2b1d8f27
      YueHaibing authored
      [ Upstream commit 52f7cf70 ]
      
      Smatch warns this:
      
      drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c:81
       mlx5dr_table_set_miss_action() error: uninitialized symbol 'ret'.
      
      Initializing ret with -EOPNOTSUPP and fix missing action case.
      
      Fixes: 7838e172
      
       ("net/mlx5: DR, Expose steering table functionality")
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Reviewed-by: default avatarRoi Dayan <roid@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2b1d8f27
    • Yang Yingliang's avatar
      hwmon: (coretemp) fix pci device refcount leak in nv1a_ram_new() · c40db1e5
      Yang Yingliang authored
      [ Upstream commit 7dec1453 ]
      
      As comment of pci_get_domain_bus_and_slot() says, it returns
      a pci device with refcount increment, when finish using it,
      the caller must decrement the reference count by calling
      pci_dev_put(). So call it after using to avoid refcount leak.
      
      Fixes: 14513ee6
      
       ("hwmon: (coretemp) Use PCI host bridge ID to identify CPU if necessary")
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Link: https://lore.kernel.org/r/20221118093303.214163-1-yangyingliang@huawei.com
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c40db1e5
    • Phil Auld's avatar
      hwmon: (coretemp) Check for null before removing sysfs attrs · f06e0cd0
      Phil Auld authored
      [ Upstream commit a89ff5f5
      
       ]
      
      If coretemp_add_core() gets an error then pdata->core_data[indx]
      is already NULL and has been kfreed. Don't pass that to
      sysfs_remove_group() as that will crash in sysfs_remove_group().
      
      [Shortened for readability]
      [91854.020159] sysfs: cannot create duplicate filename '/devices/platform/coretemp.0/hwmon/hwmon2/temp20_label'
      <cpu offline>
      [91855.126115] BUG: kernel NULL pointer dereference, address: 0000000000000188
      [91855.165103] #PF: supervisor read access in kernel mode
      [91855.194506] #PF: error_code(0x0000) - not-present page
      [91855.224445] PGD 0 P4D 0
      [91855.238508] Oops: 0000 [#1] PREEMPT SMP PTI
      ...
      [91855.342716] RIP: 0010:sysfs_remove_group+0xc/0x80
      ...
      [91855.796571] Call Trace:
      [91855.810524]  coretemp_cpu_offline+0x12b/0x1dd [coretemp]
      [91855.841738]  ? coretemp_cpu_online+0x180/0x180 [coretemp]
      [91855.871107]  cpuhp_invoke_callback+0x105/0x4b0
      [91855.893432]  cpuhp_thread_fun+0x8e/0x150
      ...
      
      Fix this by checking for NULL first.
      
      Signed-off-by: default avatarPhil Auld <pauld@redhat.com>
      Cc: linux-hwmon@vger.kernel.org
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: Jean Delvare <jdelvare@suse.com>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Link: https://lore.kernel.org/r/20221117162313.3164803-1-pauld@redhat.com
      Fixes: 199e0de7
      
       ("hwmon: (coretemp) Merge pkgtemp with coretemp")
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f06e0cd0
    • Yoshihiro Shimoda's avatar
      net: ethernet: renesas: ravb: Fix promiscuous mode after system resumed · d93522d0
      Yoshihiro Shimoda authored
      [ Upstream commit d66233a3
      
       ]
      
      After system resumed on some environment board, the promiscuous mode
      is disabled because the SoC turned off. So, call ravb_set_rx_mode() in
      the ravb_resume() to fix the issue.
      
      Reported-by: default avatarTho Vu <tho.vu.wh@renesas.com>
      Fixes: 0184165b
      
       ("ravb: add sleep PM suspend/resume support")
      Signed-off-by: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Reviewed-by: default avatarPavan Chebbi <pavan.chebbi@broadcom.com>
      Reviewed-by: default avatarSergey Shtylyov <s.shtylyov@omp.ru>
      Link: https://lore.kernel.org/r/20221128065604.1864391-1-yoshihiro.shimoda.uh@renesas.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d93522d0
    • Zhengchao Shao's avatar
      sctp: fix memory leak in sctp_stream_outq_migrate() · 176ee6c6
      Zhengchao Shao authored
      [ Upstream commit 9ed7bfc7 ]
      
      When sctp_stream_outq_migrate() is called to release stream out resources,
      the memory pointed to by prio_head in stream out is not released.
      
      The memory leak information is as follows:
       unreferenced object 0xffff88801fe79f80 (size 64):
         comm "sctp_repo", pid 7957, jiffies 4294951704 (age 36.480s)
         hex dump (first 32 bytes):
           80 9f e7 1f 80 88 ff ff 80 9f e7 1f 80 88 ff ff  ................
           90 9f e7 1f 80 88 ff ff 90 9f e7 1f 80 88 ff ff  ................
         backtrace:
           [<ffffffff81b215c6>] kmalloc_trace+0x26/0x60
           [<ffffffff88ae517c>] sctp_sched_prio_set+0x4cc/0x770
           [<ffffffff88ad64f2>] sctp_stream_init_ext+0xd2/0x1b0
           [<ffffffff88aa2604>] sctp_sendmsg_to_asoc+0x1614/0x1a30
           [<ffffffff88ab7ff1>] sctp_sendmsg+0xda1/0x1ef0
           [<ffffffff87f765ed>] inet_sendmsg+0x9d/0xe0
           [<ffffffff8754b5b3>] sock_sendmsg+0xd3/0x120
           [<ffffffff8755446a>] __sys_sendto+0x23a/0x340
           [<ffffffff87554651>] __x64_sys_sendto+0xe1/0x1b0
           [<ffffffff89978b49>] do_syscall_64+0x39/0xb0
           [<ffffffff89a0008b>] entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      Link: https://syzkaller.appspot.com/bug?exrid=29c402e56c4760763cc0
      Fixes: 637784ad
      
       ("sctp: introduce priority based stream scheduler")
      Reported-by: default avatar <syzbot+29c402e56c4760763cc0@syzkaller.appspotmail.com>
      Signed-off-by: default avatarZhengchao Shao <shaozhengchao@huawei.com>
      Reviewed-by: default avatarXin Long <lucien.xin@gmail.com>
      Link: https://lore.kernel.org/r/20221126031720.378562-1-shaozhengchao@huawei.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      176ee6c6
    • Willem de Bruijn's avatar
      packet: do not set TP_STATUS_CSUM_VALID on CHECKSUM_COMPLETE · 1c38c88a
      Willem de Bruijn authored
      [ Upstream commit b85f628a ]
      
      CHECKSUM_COMPLETE signals that skb->csum stores the sum over the
      entire packet. It does not imply that an embedded l4 checksum
      field has been validated.
      
      Fixes: 682f048b
      
       ("af_packet: pass checksum validation status to the user")
      Signed-off-by: default avatarWillem de Bruijn <willemb@google.com>
      Link: https://lore.kernel.org/r/20221128161812.640098-1-willemdebruijn.kernel@gmail.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1c38c88a
    • Shigeru Yoshida's avatar
      net: tun: Fix use-after-free in tun_detach() · 5f442e1d
      Shigeru Yoshida authored
      [ Upstream commit 5daadc86 ]
      
      syzbot reported use-after-free in tun_detach() [1].  This causes call
      trace like below:
      
      ==================================================================
      BUG: KASAN: use-after-free in notifier_call_chain+0x1ee/0x200 kernel/notifier.c:75
      Read of size 8 at addr ffff88807324e2a8 by task syz-executor.0/3673
      
      CPU: 0 PID: 3673 Comm: syz-executor.0 Not tainted 6.1.0-rc5-syzkaller-00044-gcc675d22e422 #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
      Call Trace:
       <TASK>
       __dump_stack lib/dump_stack.c:88 [inline]
       dump_stack_lvl+0xd1/0x138 lib/dump_stack.c:106
       print_address_description mm/kasan/report.c:284 [inline]
       print_report+0x15e/0x461 mm/kasan/report.c:395
       kasan_report+0xbf/0x1f0 mm/kasan/report.c:495
       notifier_call_chain+0x1ee/0x200 kernel/notifier.c:75
       call_netdevice_notifiers_info+0x86/0x130 net/core/dev.c:1942
       call_netdevice_notifiers_extack net/core/dev.c:1983 [inline]
       call_netdevice_notifiers net/core/dev.c:1997 [inline]
       netdev_wait_allrefs_any net/core/dev.c:10237 [inline]
       netdev_run_todo+0xbc6/0x1100 net/core/dev.c:10351
       tun_detach drivers/net/tun.c:704 [inline]
       tun_chr_close+0xe4/0x190 drivers/net/tun.c:3467
       __fput+0x27c/0xa90 fs/file_table.c:320
       task_work_run+0x16f/0x270 kernel/task_work.c:179
       exit_task_work include/linux/task_work.h:38 [inline]
       do_exit+0xb3d/0x2a30 kernel/exit.c:820
       do_group_exit+0xd4/0x2a0 kernel/exit.c:950
       get_signal+0x21b1/0x2440 kernel/signal.c:2858
       arch_do_signal_or_restart+0x86/0x2300 arch/x86/kernel/signal.c:869
       exit_to_user_mode_loop kernel/entry/common.c:168 [inline]
       exit_to_user_mode_prepare+0x15f/0x250 kernel/entry/common.c:203
       __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
       syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:296
       do_syscall_64+0x46/0xb0 arch/x86/entry/common.c:86
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      The cause of the issue is that sock_put() from __tun_detach() drops
      last reference count for struct net, and then notifier_call_chain()
      from netdev_state_change() accesses that struct net.
      
      This patch fixes the issue by calling sock_put() from tun_detach()
      after all necessary accesses for the struct net has done.
      
      Fixes: 83c1f36f
      
       ("tun: send netlink notification when the device is modified")
      Reported-by: default avatar <syzbot+106f9b687cd64ee70cd1@syzkaller.appspotmail.com>
      Link: https://syzkaller.appspot.com/bug?id=96eb7f1ce75ef933697f24eeab928c4a716edefe [1]
      Signed-off-by: default avatarShigeru Yoshida <syoshida@redhat.com>
      Link: https://lore.kernel.org/r/20221124175134.1589053-1-syoshida@redhat.com
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5f442e1d
    • David Howells's avatar
      afs: Fix fileserver probe RTT handling · 5fa0fc58
      David Howells authored
      [ Upstream commit ca57f022 ]
      
      The fileserver probing code attempts to work out the best fileserver to
      use for a volume by retrieving the RTT calculated by AF_RXRPC for the
      probe call sent to each server and comparing them.  Sometimes, however,
      no RTT estimate is available and rxrpc_kernel_get_srtt() returns false,
      leading good fileservers to be given an RTT of UINT_MAX and thus causing
      the rotation algorithm to ignore them.
      
      Fix afs_select_fileserver() to ignore rxrpc_kernel_get_srtt()'s return
      value and just take the estimated RTT it provides - which will be capped
      at 1 second.
      
      Fixes: 1d4adfaf
      
       ("rxrpc: Make rxrpc_kernel_get_srtt() indicate validity")
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Reviewed-by: default avatarMarc Dionne <marc.dionne@auristor.com>
      Tested-by: default avatarMarc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      Link: https://lore.kernel.org/r/166965503999.3392585.13954054113218099395.stgit@warthog.procyon.org.uk/
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5fa0fc58
    • YueHaibing's avatar
      net: hsr: Fix potential use-after-free · 7ca81a16
      YueHaibing authored
      [ Upstream commit 7e177d32 ]
      
      The skb is delivered to netif_rx() which may free it, after calling this,
      dereferencing skb may trigger use-after-free.
      
      Fixes: f421436a
      
       ("net/hsr: Add support for the High-availability Seamless Redundancy protocol (HSRv0)")
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Link: https://lore.kernel.org/r/20221125075724.27912-1-yuehaibing@huawei.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7ca81a16
    • Xin Long's avatar
      tipc: re-fetch skb cb after tipc_msg_validate · a1ba595e
      Xin Long authored
      [ Upstream commit 3067bc61 ]
      
      As the call trace shows, the original skb was freed in tipc_msg_validate(),
      and dereferencing the old skb cb would cause an use-after-free crash.
      
        BUG: KASAN: use-after-free in tipc_crypto_rcv_complete+0x1835/0x2240 [tipc]
        Call Trace:
         <IRQ>
         tipc_crypto_rcv_complete+0x1835/0x2240 [tipc]
         tipc_crypto_rcv+0xd32/0x1ec0 [tipc]
         tipc_rcv+0x744/0x1150 [tipc]
        ...
        Allocated by task 47078:
         kmem_cache_alloc_node+0x158/0x4d0
         __alloc_skb+0x1c1/0x270
         tipc_buf_acquire+0x1e/0xe0 [tipc]
         tipc_msg_create+0x33/0x1c0 [tipc]
         tipc_link_build_proto_msg+0x38a/0x2100 [tipc]
         tipc_link_timeout+0x8b8/0xef0 [tipc]
         tipc_node_timeout+0x2a1/0x960 [tipc]
         call_timer_fn+0x2d/0x1c0
        ...
        Freed by task 47078:
         tipc_msg_validate+0x7b/0x440 [tipc]
         tipc_crypto_rcv_complete+0x4b5/0x2240 [tipc]
         tipc_crypto_rcv+0xd32/0x1ec0 [tipc]
         tipc_rcv+0x744/0x1150 [tipc]
      
      This patch fixes it by re-fetching the skb cb from the new allocated skb
      after calling tipc_msg_validate().
      
      Fixes: fc1b6d6d
      
       ("tipc: introduce TIPC encryption & authentication")
      Reported-by: default avatarShuang Li <shuali@redhat.com>
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Link: https://lore.kernel.org/r/1b1cdba762915325bd8ef9a98d0276eb673df2a5.1669398403.git.lucien.xin@gmail.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a1ba595e
    • Jerry Ray's avatar
      dsa: lan9303: Correct stat name · 4621bdff
      Jerry Ray authored
      [ Upstream commit 39f59bca ]
      
      This patch changes the reported ethtool statistics for the lan9303
      family of parts covered by this driver.
      
      The TxUnderRun statistic label is renamed to RxShort to accurately
      reflect what stat the device is reporting.  I did not reorder the
      statistics as that might cause problems with existing user code that
      are expecting the stats at a certain offset.
      
      Fixes: a1292595
      
       ("net: dsa: add new DSA switch driver for the SMSC-LAN9303")
      Signed-off-by: default avatarJerry Ray <jerry.ray@microchip.com>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Link: https://lore.kernel.org/r/20221128193559.6572-1-jerry.ray@microchip.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4621bdff
    • Yuri Karpov's avatar
      net: ethernet: nixge: fix NULL dereference · 45752af0
      Yuri Karpov authored
      [ Upstream commit 9256db4e ]
      
      In function nixge_hw_dma_bd_release() dereference of NULL pointer
      priv->rx_bd_v is possible for the case of its allocation failure in
      nixge_hw_dma_bd_init().
      
      Move for() loop with priv->rx_bd_v dereference under the check for
      its validity.
      
      Found by Linux Verification Center (linuxtesting.org) with SVACE.
      
      Fixes: 492caffa
      
       ("net: ethernet: nixge: Add support for National Instruments XGE netdev")
      Signed-off-by: default avatarYuri Karpov <YKarpov@ispras.ru>
      Reviewed-by: default avatarMaciej Fijalkowski <maciej.fijalkowski@intel.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      45752af0
    • Wang Hai's avatar
      net/9p: Fix a potential socket leak in p9_socket_open · e01c1542
      Wang Hai authored
      [ Upstream commit dcc14cfd ]
      
      Both p9_fd_create_tcp() and p9_fd_create_unix() will call
      p9_socket_open(). If the creation of p9_trans_fd fails,
      p9_fd_create_tcp() and p9_fd_create_unix() will return an
      error directly instead of releasing the cscoket, which will
      result in a socket leak.
      
      This patch adds sock_release() to fix the leak issue.
      
      Fixes: 6b18662e
      
       ("9p connect fixes")
      Signed-off-by: default avatarWang Hai <wanghai38@huawei.com>
      ACKed-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e01c1542
    • Yuan Can's avatar
      net: net_netdev: Fix error handling in ntb_netdev_init_module() · b080d466
      Yuan Can authored
      [ Upstream commit b8f79dcc ]
      
      The ntb_netdev_init_module() returns the ntb_transport_register_client()
      directly without checking its return value, if
      ntb_transport_register_client() failed, the NTB client device is not
      unregistered.
      
      Fix by unregister NTB client device when ntb_transport_register_client()
      failed.
      
      Fixes: 548c237c
      
       ("net: Add support for NTB virtual ethernet device")
      Signed-off-by: default avatarYuan Can <yuancan@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b080d466
    • Yang Yingliang's avatar
      net: phy: fix null-ptr-deref while probe() failed · fe6bc99c
      Yang Yingliang authored
      [ Upstream commit 369eb2c9 ]
      
      I got a null-ptr-deref report as following when doing fault injection test:
      
      BUG: kernel NULL pointer dereference, address: 0000000000000058
      Oops: 0000 [#1] PREEMPT SMP KASAN PTI
      CPU: 1 PID: 253 Comm: 507-spi-dm9051 Tainted: G    B            N 6.1.0-rc3+
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014
      RIP: 0010:klist_put+0x2d/0xd0
      Call Trace:
       <TASK>
       klist_remove+0xf1/0x1c0
       device_release_driver_internal+0x23e/0x2d0
       bus_remove_device+0x1bd/0x240
       device_del+0x357/0x770
       phy_device_remove+0x11/0x30
       mdiobus_unregister+0xa5/0x140
       release_nodes+0x6a/0xa0
       devres_release_all+0xf8/0x150
       device_unbind_cleanup+0x19/0xd0
      
      //probe path:
      phy_device_register()
        device_add()
      
      phy_connect
        phy_attach_direct() //set device driver
          probe() //it's failed, driver is not bound
          device_bind_driver() // probe failed, it's not called
      
      //remove path:
      phy_device_remove()
        device_del()
          device_release_driver_internal()
            __device_release_driver() //dev->drv is not NULL
              klist_remove() <- knode_driver is not added yet, cause null-ptr-deref
      
      In phy_attach_direct(), after setting the 'dev->driver', probe() fails,
      device_bind_driver() is not called, so the knode_driver->n_klist is not
      set, then it causes null-ptr-deref in __device_release_driver() while
      deleting device. Fix this by setting dev->driver to NULL in the error
      path in phy_attach_direct().
      
      Fixes: e1393456
      
       ("[PATCH] PHY Layer fixup")
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fe6bc99c
    • Lorenzo Bianconi's avatar
      wifi: mac8021: fix possible oob access in ieee80211_get_rate_duration · 0184ede0
      Lorenzo Bianconi authored
      [ Upstream commit 3e8f7abc ]
      
      Fix possible out-of-bound access in ieee80211_get_rate_duration routine
      as reported by the following UBSAN report:
      
      UBSAN: array-index-out-of-bounds in net/mac80211/airtime.c:455:47
      index 15 is out of range for type 'u16 [12]'
      CPU: 2 PID: 217 Comm: kworker/u32:10 Not tainted 6.1.0-060100rc3-generic
      Hardware name: Acer Aspire TC-281/Aspire TC-281, BIOS R01-A2 07/18/2017
      Workqueue: mt76 mt76u_tx_status_data [mt76_usb]
      Call Trace:
       <TASK>
       show_stack+0x4e/0x61
       dump_stack_lvl+0x4a/0x6f
       dump_stack+0x10/0x18
       ubsan_epilogue+0x9/0x43
       __ubsan_handle_out_of_bounds.cold+0x42/0x47
      ieee80211_get_rate_duration.constprop.0+0x22f/0x2a0 [mac80211]
       ? ieee80211_tx_status_ext+0x32e/0x640 [mac80211]
       ieee80211_calc_rx_airtime+0xda/0x120 [mac80211]
       ieee80211_calc_tx_airtime+0xb4/0x100 [mac80211]
       mt76x02_send_tx_status+0x266/0x480 [mt76x02_lib]
       mt76x02_tx_status_data+0x52/0x80 [mt76x02_lib]
       mt76u_tx_status_data+0x67/0xd0 [mt76_usb]
       process_one_work+0x225/0x400
       worker_thread+0x50/0x3e0
       ? process_one_work+0x400/0x400
       kthread+0xe9/0x110
       ? kthread_complete_and_exit+0x20/0x20
       ret_from_fork+0x22/0x30
      
      Fixes: db3e1c40
      
       ("mac80211: Import airtime calculation code from mt76")
      Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
      Acked-by: default avatarToke Høiland-Jørgensen <toke@toke.dk>
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0184ede0
    • Johannes Berg's avatar
      wifi: cfg80211: don't allow multi-BSSID in S1G · e2ed90fd
      Johannes Berg authored
      [ Upstream commit acd3c92a
      
       ]
      
      In S1G beacon frames there shouldn't be multi-BSSID elements
      since that's not supported, remove that to avoid a potential
      integer underflow and/or misparsing the frames due to the
      different length of the fixed part of the frame.
      
      While at it, initialize non_tx_data so we don't send garbage
      values to the user (even if it doesn't seem to matter now.)
      
      Reported-and-tested-by: default avatarSönke Huster <shuster@seemoo.tu-darmstadt.de>
      Fixes: 9eaffe50
      
       ("cfg80211: convert S1G beacon to scan results")
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e2ed90fd