Skip to content
  1. Jan 18, 2023
    • Johan Hovold's avatar
      efi: fix NULL-deref in init error path · 585a0b2b
      Johan Hovold authored
      [ Upstream commit 703c13fe ]
      
      In cases where runtime services are not supported or have been disabled,
      the runtime services workqueue will never have been allocated.
      
      Do not try to destroy the workqueue unconditionally in the unlikely
      event that EFI initialisation fails to avoid dereferencing a NULL
      pointer.
      
      Fixes: 98086df8
      
       ("efi: add missed destroy_workqueue when efisubsys_init fails")
      Cc: stable@vger.kernel.org
      Cc: Li Heng <liheng40@huawei.com>
      Signed-off-by: default avatarJohan Hovold <johan+linaro@kernel.org>
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      585a0b2b
    • Mark Rutland's avatar
      arm64: cmpxchg_double*: hazard against entire exchange variable · 6ad3636b
      Mark Rutland authored
      [ Upstream commit 031af500 ]
      
      The inline assembly for arm64's cmpxchg_double*() implementations use a
      +Q constraint to hazard against other accesses to the memory location
      being exchanged. However, the pointer passed to the constraint is a
      pointer to unsigned long, and thus the hazard only applies to the first
      8 bytes of the location.
      
      GCC can take advantage of this, assuming that other portions of the
      location are unchanged, leading to a number of potential problems.
      
      This is similar to what we fixed back in commit:
      
        fee960be ("arm64: xchg: hazard against entire exchange variable")
      
      ... but we forgot to adjust cmpxchg_double*() similarly at the same
      time.
      
      The same problem applies, as demonstrated with the following test:
      
      | struct big {
      |         u64 lo, hi;
      | } __aligned(128);
      |
      | unsigned long foo(struct big *b)
      | {
      |         u64 hi_old, hi_new;
      |
      |         hi_old = b->hi;
      |         cmpxchg_double_local(&b->lo, &b->hi, 0x12, 0x34, 0x56, 0x78);
      |         hi_new = b->hi;
      |
      |         return hi_old ^ hi_new;
      | }
      
      ... which GCC 12.1.0 compiles as:
      
      | 0000000000000000 <foo>:
      |    0:   d503233f        paciasp
      |    4:   aa0003e4        mov     x4, x0
      |    8:   1400000e        b       40 <foo+0x40>
      |    c:   d2800240        mov     x0, #0x12                       // #18
      |   10:   d2800681        mov     x1, #0x34                       // #52
      |   14:   aa0003e5        mov     x5, x0
      |   18:   aa0103e6        mov     x6, x1
      |   1c:   d2800ac2        mov     x2, #0x56                       // #86
      |   20:   d2800f03        mov     x3, #0x78                       // #120
      |   24:   48207c82        casp    x0, x1, x2, x3, [x4]
      |   28:   ca050000        eor     x0, x0, x5
      |   2c:   ca060021        eor     x1, x1, x6
      |   30:   aa010000        orr     x0, x0, x1
      |   34:   d2800000        mov     x0, #0x0                        // #0    <--- BANG
      |   38:   d50323bf        autiasp
      |   3c:   d65f03c0        ret
      |   40:   d2800240        mov     x0, #0x12                       // #18
      |   44:   d2800681        mov     x1, #0x34                       // #52
      |   48:   d2800ac2        mov     x2, #0x56                       // #86
      |   4c:   d2800f03        mov     x3, #0x78                       // #120
      |   50:   f9800091        prfm    pstl1strm, [x4]
      |   54:   c87f1885        ldxp    x5, x6, [x4]
      |   58:   ca0000a5        eor     x5, x5, x0
      |   5c:   ca0100c6        eor     x6, x6, x1
      |   60:   aa0600a6        orr     x6, x5, x6
      |   64:   b5000066        cbnz    x6, 70 <foo+0x70>
      |   68:   c8250c82        stxp    w5, x2, x3, [x4]
      |   6c:   35ffff45        cbnz    w5, 54 <foo+0x54>
      |   70:   d2800000        mov     x0, #0x0                        // #0     <--- BANG
      |   74:   d50323bf        autiasp
      |   78:   d65f03c0        ret
      
      Notice that at the lines with "BANG" comments, GCC has assumed that the
      higher 8 bytes are unchanged by the cmpxchg_double() call, and that
      `hi_old ^ hi_new` can be reduced to a constant zero, for both LSE and
      LL/SC versions of cmpxchg_double().
      
      This patch fixes the issue by passing a pointer to __uint128_t into the
      +Q constraint, ensuring that the compiler hazards against the entire 16
      bytes being modified.
      
      With this change, GCC 12.1.0 compiles the above test as:
      
      | 0000000000000000 <foo>:
      |    0:   f9400407        ldr     x7, [x0, #8]
      |    4:   d503233f        paciasp
      |    8:   aa0003e4        mov     x4, x0
      |    c:   1400000f        b       48 <foo+0x48>
      |   10:   d2800240        mov     x0, #0x12                       // #18
      |   14:   d2800681        mov     x1, #0x34                       // #52
      |   18:   aa0003e5        mov     x5, x0
      |   1c:   aa0103e6        mov     x6, x1
      |   20:   d2800ac2        mov     x2, #0x56                       // #86
      |   24:   d2800f03        mov     x3, #0x78                       // #120
      |   28:   48207c82        casp    x0, x1, x2, x3, [x4]
      |   2c:   ca050000        eor     x0, x0, x5
      |   30:   ca060021        eor     x1, x1, x6
      |   34:   aa010000        orr     x0, x0, x1
      |   38:   f9400480        ldr     x0, [x4, #8]
      |   3c:   d50323bf        autiasp
      |   40:   ca0000e0        eor     x0, x7, x0
      |   44:   d65f03c0        ret
      |   48:   d2800240        mov     x0, #0x12                       // #18
      |   4c:   d2800681        mov     x1, #0x34                       // #52
      |   50:   d2800ac2        mov     x2, #0x56                       // #86
      |   54:   d2800f03        mov     x3, #0x78                       // #120
      |   58:   f9800091        prfm    pstl1strm, [x4]
      |   5c:   c87f1885        ldxp    x5, x6, [x4]
      |   60:   ca0000a5        eor     x5, x5, x0
      |   64:   ca0100c6        eor     x6, x6, x1
      |   68:   aa0600a6        orr     x6, x5, x6
      |   6c:   b5000066        cbnz    x6, 78 <foo+0x78>
      |   70:   c8250c82        stxp    w5, x2, x3, [x4]
      |   74:   35ffff45        cbnz    w5, 5c <foo+0x5c>
      |   78:   f9400480        ldr     x0, [x4, #8]
      |   7c:   d50323bf        autiasp
      |   80:   ca0000e0        eor     x0, x7, x0
      |   84:   d65f03c0        ret
      
      ... sampling the high 8 bytes before and after the cmpxchg, and
      performing an EOR, as we'd expect.
      
      For backporting, I've tested this atop linux-4.9.y with GCC 5.5.0. Note
      that linux-4.9.y is oldest currently supported stable release, and
      mandates GCC 5.1+. Unfortunately I couldn't get a GCC 5.1 binary to run
      on my machines due to library incompatibilities.
      
      I've also used a standalone test to check that we can use a __uint128_t
      pointer in a +Q constraint at least as far back as GCC 4.8.5 and LLVM
      3.9.1.
      
      Fixes: 5284e1b4 ("arm64: xchg: Implement cmpxchg_double")
      Fixes: e9a4b795
      
       ("arm64: cmpxchg_dbl: patch in lse instructions when supported by the CPU")
      Reported-by: default avatarBoqun Feng <boqun.feng@gmail.com>
      Link: https://lore.kernel.org/lkml/Y6DEfQXymYVgL3oJ@boqun-archlinux/
      Reported-by: default avatarPeter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/lkml/Y6GXoO4qmH9OIZ5Q@hirez.programming.kicks-ass.net/
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Cc: stable@vger.kernel.org
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Steve Capper <steve.capper@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Link: https://lore.kernel.org/r/20230104151626.3262137-1-mark.rutland@arm.com
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6ad3636b
    • Rob Clark's avatar
      drm/virtio: Fix GEM handle creation UAF · 19ec87d0
      Rob Clark authored
      [ Upstream commit 52531258
      
       ]
      
      Userspace can guess the handle value and try to race GEM object creation
      with handle close, resulting in a use-after-free if we dereference the
      object after dropping the handle's reference.  For that reason, dropping
      the handle's reference must be done *after* we are done dereferencing
      the object.
      
      Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
      Reviewed-by: default avatarChia-I Wu <olvaffe@gmail.com>
      Fixes: 62fb7a5e
      
       ("virtio-gpu: add 3d/virgl support")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDmitry Osipenko <dmitry.osipenko@collabora.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20221216233355.542197-2-robdclark@gmail.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      19ec87d0
    • Peter Newman's avatar
      x86/resctrl: Fix task CLOSID/RMID update race · 34606ad2
      Peter Newman authored
      [ Upstream commit fe1f0714 ]
      
      When the user moves a running task to a new rdtgroup using the task's
      file interface or by deleting its rdtgroup, the resulting change in
      CLOSID/RMID must be immediately propagated to the PQR_ASSOC MSR on the
      task(s) CPUs.
      
      x86 allows reordering loads with prior stores, so if the task starts
      running between a task_curr() check that the CPU hoisted before the
      stores in the CLOSID/RMID update then it can start running with the old
      CLOSID/RMID until it is switched again because __rdtgroup_move_task()
      failed to determine that it needs to be interrupted to obtain the new
      CLOSID/RMID.
      
      Refer to the diagram below:
      
      CPU 0                                   CPU 1
      -----                                   -----
      __rdtgroup_move_task():
        curr <- t1->cpu->rq->curr
                                              __schedule():
                                                rq->curr <- t1
                                              resctrl_sched_in():
                                                t1->{closid,rmid} -> {1,1}
        t1->{closid,rmid} <- {2,2}
        if (curr == t1) // false
         IPI(t1->cpu)
      
      A similar race impacts rdt_move_group_tasks(), which updates tasks in a
      deleted rdtgroup.
      
      In both cases, use smp_mb() to order the task_struct::{closid,rmid}
      stores before the loads in task_curr().  In particular, in the
      rdt_move_group_tasks() case, simply execute an smp_mb() on every
      iteration with a matching task.
      
      It is possible to use a single smp_mb() in rdt_move_group_tasks(), but
      this would require two passes and a means of remembering which
      task_structs were updated in the first loop. However, benchmarking
      results below showed too little performance impact in the simple
      approach to justify implementing the two-pass approach.
      
      Times below were collected using `perf stat` to measure the time to
      remove a group containing a 1600-task, parallel workload.
      
      CPU: Intel(R) Xeon(R) Platinum P-8136 CPU @ 2.00GHz (112 threads)
      
        # mkdir /sys/fs/resctrl/test
        # echo $$ > /sys/fs/resctrl/test/tasks
        # perf bench sched messaging -g 40 -l 100000
      
      task-clock time ranges collected using:
      
        # perf stat rmdir /sys/fs/resctrl/test
      
      Baseline:                     1.54 - 1.60 ms
      smp_mb() every matching task: 1.57 - 1.67 ms
      
        [ bp: Massage commit message. ]
      
      Fixes: ae28d1aa ("x86/resctrl: Use an IPI instead of task_work_add() to update PQR_ASSOC MSR")
      Fixes: 0efc89be
      
       ("x86/intel_rdt: Update task closid immediately on CPU in rmdir and unmount")
      Signed-off-by: default avatarPeter Newman <peternewman@google.com>
      Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
      Reviewed-by: default avatarReinette Chatre <reinette.chatre@intel.com>
      Reviewed-by: default avatarBabu Moger <babu.moger@amd.com>
      Cc: <stable@kernel.org>
      Link: https://lore.kernel.org/r/20221220161123.432120-1-peternewman@google.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      34606ad2
    • Reinette Chatre's avatar
      x86/resctrl: Use task_curr() instead of task_struct->on_cpu to prevent unnecessary IPI · 1192f214
      Reinette Chatre authored
      [ Upstream commit e0ad6dc8
      
       ]
      
      James reported in [1] that there could be two tasks running on the same CPU
      with task_struct->on_cpu set. Using task_struct->on_cpu as a test if a task
      is running on a CPU may thus match the old task for a CPU while the
      scheduler is running and IPI it unnecessarily.
      
      task_curr() is the correct helper to use. While doing so move the #ifdef
      check of the CONFIG_SMP symbol to be a C conditional used to determine
      if this helper should be used to ensure the code is always checked for
      correctness by the compiler.
      
      [1] https://lore.kernel.org/lkml/a782d2f3-d2f6-795f-f4b1-9462205fd581@arm.com
      
      Reported-by: default avatarJames Morse <james.morse@arm.com>
      Signed-off-by: default avatarReinette Chatre <reinette.chatre@intel.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Link: https://lkml.kernel.org/r/e9e68ce1441a73401e08b641cc3b9a3cf13fe6d4.1608243147.git.reinette.chatre@intel.com
      Stable-dep-of: fe1f0714
      
       ("x86/resctrl: Fix task CLOSID/RMID update race")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1192f214
    • Christophe JAILLET's avatar
      iommu/mediatek-v1: Fix an error handling path in mtk_iommu_v1_probe() · a086450e
      Christophe JAILLET authored
      [ Upstream commit 142e821f ]
      
      A clk, prepared and enabled in mtk_iommu_v1_hw_init(), is not released in
      the error handling path of mtk_iommu_v1_probe().
      
      Add the corresponding clk_disable_unprepare(), as already done in the
      remove function.
      
      Fixes: b17336c5
      
       ("iommu/mediatek: add support for mtk iommu generation one HW")
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Reviewed-by: default avatarYong Wu <yong.wu@mediatek.com>
      Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
      Reviewed-by: default avatarMatthias Brugger <matthias.bgg@gmail.com>
      Link: https://lore.kernel.org/r/593e7b7d97c6e064b29716b091a9d4fd122241fb.1671473163.git.christophe.jaillet@wanadoo.fr
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a086450e
    • Yong Wu's avatar
      iommu/mediatek-v1: Add error handle for mtk_iommu_probe · cb5084c4
      Yong Wu authored
      [ Upstream commit ac304c07
      
       ]
      
      In the original code, we lack the error handle. This patch adds them.
      
      Signed-off-by: default avatarYong Wu <yong.wu@mediatek.com>
      Link: https://lore.kernel.org/r/20210412064843.11614-2-yong.wu@mediatek.com
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      Stable-dep-of: 142e821f
      
       ("iommu/mediatek-v1: Fix an error handling path in mtk_iommu_v1_probe()")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cb5084c4
    • Rahul Rameshbabu's avatar
      net/mlx5: Fix ptp max frequency adjustment range · 6b37805d
      Rahul Rameshbabu authored
      [ Upstream commit fe91d572 ]
      
      .max_adj of ptp_clock_info acts as an absolute value for the amount in ppb
      that can be set for a single call of .adjfine. This means that a single
      call to .getfine cannot be greater than .max_adj or less than -(.max_adj).
      Provides correct value for max frequency adjustment value supported by
      devices.
      
      Fixes: 3d8c38af
      
       ("net/mlx5e: Add PTP Hardware Clock (PHC) support")
      Signed-off-by: default avatarRahul Rameshbabu <rrameshbabu@nvidia.com>
      Reviewed-by: default avatarGal Pressman <gal@nvidia.com>
      Reviewed-by: default avatarTariq Toukan <tariqt@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6b37805d
    • Eran Ben Elisha's avatar
      net/mlx5: Rename ptp clock info · be59f972
      Eran Ben Elisha authored
      [ Upstream commit aac2df7f
      
       ]
      
      Fix a typo in ptp_clock_info naming: mlx5_p2p -> mlx5_ptp.
      
      Signed-off-by: default avatarEran Ben Elisha <eranbe@mellanox.com>
      Stable-dep-of: fe91d572
      
       ("net/mlx5: Fix ptp max frequency adjustment range")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      be59f972
    • Minsuk Kang's avatar
      nfc: pn533: Wait for out_urb's completion in pn533_usb_send_frame() · 321db513
      Minsuk Kang authored
      [ Upstream commit 9dab880d ]
      
      Fix a use-after-free that occurs in hcd when in_urb sent from
      pn533_usb_send_frame() is completed earlier than out_urb. Its callback
      frees the skb data in pn533_send_async_complete() that is used as a
      transfer buffer of out_urb. Wait before sending in_urb until the
      callback of out_urb is called. To modify the callback of out_urb alone,
      separate the complete function of out_urb and ack_urb.
      
      Found by a modified version of syzkaller.
      
      BUG: KASAN: use-after-free in dummy_timer
      Call Trace:
       memcpy (mm/kasan/shadow.c:65)
       dummy_perform_transfer (drivers/usb/gadget/udc/dummy_hcd.c:1352)
       transfer (drivers/usb/gadget/udc/dummy_hcd.c:1453)
       dummy_timer (drivers/usb/gadget/udc/dummy_hcd.c:1972)
       arch_static_branch (arch/x86/include/asm/jump_label.h:27)
       static_key_false (include/linux/jump_label.h:207)
       timer_expire_exit (include/trace/events/timer.h:127)
       call_timer_fn (kernel/time/timer.c:1475)
       expire_timers (kernel/time/timer.c:1519)
       __run_timers (kernel/time/timer.c:1790)
       run_timer_softirq (kernel/time/timer.c:1803)
      
      Fixes: c46ee386
      
       ("NFC: pn533: add NXP pn533 nfc device driver")
      Signed-off-by: default avatarMinsuk Kang <linuxlovemin@yonsei.ac.kr>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      321db513
    • Roger Pau Monne's avatar
      hvc/xen: lock console list traversal · 2fda631d
      Roger Pau Monne authored
      [ Upstream commit c0dccad8 ]
      
      The currently lockless access to the xen console list in
      vtermno_to_xencons() is incorrect, as additions and removals from the
      list can happen anytime, and as such the traversal of the list to get
      the private console data for a given termno needs to happen with the
      lock held.  Note users that modify the list already do so with the
      lock taken.
      
      Adjust current lock takers to use the _irq{save,restore} helpers,
      since the context in which vtermno_to_xencons() is called can have
      interrupts disabled.  Use the _irq{save,restore} set of helpers to
      switch the current callers to disable interrupts in the locked region.
      I haven't checked if existing users could instead use the _irq
      variant, as I think it's safer to use _irq{save,restore} upfront.
      
      While there switch from using list_for_each_entry_safe to
      list_for_each_entry: the current entry cursor won't be removed as
      part of the code in the loop body, so using the _safe variant is
      pointless.
      
      Fixes: 02e19f9c
      
       ('hvc_xen: implement multiconsole support')
      Signed-off-by: default avatarRoger Pau Monné <roger.pau@citrix.com>
      Reviewed-by: default avatarStefano Stabellini <sstabellini@kernel.org>
      Link: https://lore.kernel.org/r/20221130163611.14686-1-roger.pau@citrix.com
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2fda631d
    • Ricardo Ribalda's avatar
      regulator: da9211: Use irq handler when ready · f75cde71
      Ricardo Ribalda authored
      [ Upstream commit 02228f6a
      
       ]
      
      If the system does not come from reset (like when it is kexec()), the
      regulator might have an IRQ waiting for us.
      
      If we enable the IRQ handler before its structures are ready, we crash.
      
      This patch fixes:
      
      [    1.141839] Unable to handle kernel read from unreadable memory at virtual address 0000000000000078
      [    1.316096] Call trace:
      [    1.316101]  blocking_notifier_call_chain+0x20/0xa8
      [    1.322757] cpu cpu0: dummy supplies not allowed for exclusive requests
      [    1.327823]  regulator_notifier_call_chain+0x1c/0x2c
      [    1.327825]  da9211_irq_handler+0x68/0xf8
      [    1.327829]  irq_thread+0x11c/0x234
      [    1.327833]  kthread+0x13c/0x154
      
      Signed-off-by: default avatarRicardo Ribalda <ribalda@chromium.org>
      Reviewed-by: default avatarAdam Ward <DLG-Adam.Ward.opensource@dm.renesas.com>
      Link: https://lore.kernel.org/r/20221124-da9211-v2-0-1779e3c5d491@chromium.org
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f75cde71
    • Eliav Farber's avatar
      EDAC/device: Fix period calculation in edac_device_reset_delay_period() · 135e5815
      Eliav Farber authored
      commit e8407743 upstream.
      
      Fix period calculation in case user sets a value of 1000.  The input of
      round_jiffies_relative() should be in jiffies and not in milli-seconds.
      
        [ bp: Use the same code pattern as in edac_device_workq_setup() for
          clarity. ]
      
      Fixes: c4cf3b45
      
       ("EDAC: Rework workqueue handling")
      Signed-off-by: default avatarEliav Farber <farbere@amazon.com>
      Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
      Cc: <stable@kernel.org>
      Link: https://lore.kernel.org/r/20221020124458.22153-1-farbere@amazon.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      135e5815
    • Peter Zijlstra's avatar
      x86/boot: Avoid using Intel mnemonics in AT&T syntax asm · 11c57a12
      Peter Zijlstra authored
      commit 7c6dd961 upstream.
      
      With 'GNU assembler (GNU Binutils for Debian) 2.39.90.20221231' the
      build now reports:
      
        arch/x86/realmode/rm/../../boot/bioscall.S: Assembler messages:
        arch/x86/realmode/rm/../../boot/bioscall.S:35: Warning: found `movsd'; assuming `movsl' was meant
        arch/x86/realmode/rm/../../boot/bioscall.S:70: Warning: found `movsd'; assuming `movsl' was meant
      
        arch/x86/boot/bioscall.S: Assembler messages:
        arch/x86/boot/bioscall.S:35: Warning: found `movsd'; assuming `movsl' was meant
        arch/x86/boot/bioscall.S:70: Warning: found `movsd'; assuming `movsl' was meant
      
      Which is due to:
      
        PR gas/29525
      
        Note that with the dropped CMPSD and MOVSD Intel Syntax string insn
        templates taking operands, mixed IsString/non-IsString template groups
        (with memory operands) cannot occur anymore. With that
        maybe_adjust_templates() becomes unnecessary (and is hence being
        removed).
      
      More details: https://sourceware.org/bugzilla/show_bug.cgi?id=29525
      
      Borislav Petkov further explains:
      
        " the particular problem here is is that the 'd' suffix is
          "conflicting" in the sense that you can have SSE mnemonics like movsD %xmm...
          and the same thing also for string ops (which is the case here) so apparently
          the agreement in binutils land is to use the always accepted suffixes 'l' or 'q'
          and phase out 'd' slowly... "
      
      Fixes: 7a734e7d
      
       ("x86, setup: "glove box" BIOS calls -- infrastructure")
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Acked-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
      Link: https://lore.kernel.org/r/Y71I3Ex2pvIxMpsP@hirez.programming.kicks-ass.net
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      11c57a12
    • Gavrilov Ilia's avatar
      netfilter: ipset: Fix overflow before widen in the bitmap_ip_create() function. · dfd834cc
      Gavrilov Ilia authored
      commit 9ea4b476 upstream.
      
      When first_ip is 0, last_ip is 0xFFFFFFFF, and netmask is 31, the value of
      an arithmetic expression 2 << (netmask - mask_bits - 1) is subject
      to overflow due to a failure casting operands to a larger data type
      before performing the arithmetic.
      
      Note that it's harmless since the value will be checked at the next step.
      
      Found by InfoTeCS on behalf of Linux Verification Center
      (linuxtesting.org) with SVACE.
      
      Fixes: b9fed748
      
       ("netfilter: ipset: Check and reject crazy /0 input parameters")
      Signed-off-by: default avatarIlia.Gavrilov <Ilia.Gavrilov@infotecs.ru>
      Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dfd834cc
    • Eric Whitney's avatar
      ext4: fix delayed allocation bug in ext4_clu_mapped for bigalloc + inline · 1ed1eef0
      Eric Whitney authored
      [ Upstream commit 131294c3
      
       ]
      
      When converting files with inline data to extents, delayed allocations
      made on a file system created with both the bigalloc and inline options
      can result in invalid extent status cache content, incorrect reserved
      cluster counts, kernel memory leaks, and potential kernel panics.
      
      With bigalloc, the code that determines whether a block must be
      delayed allocated searches the extent tree to see if that block maps
      to a previously allocated cluster.  If not, the block is delayed
      allocated, and otherwise, it isn't.  However, if the inline option is
      also used, and if the file containing the block is marked as able to
      store data inline, there isn't a valid extent tree associated with
      the file.  The current code in ext4_clu_mapped() calls
      ext4_find_extent() to search the non-existent tree for a previously
      allocated cluster anyway, which typically finds nothing, as desired.
      However, a side effect of the search can be to cache invalid content
      from the non-existent tree (garbage) in the extent status tree,
      including bogus entries in the pending reservation tree.
      
      To fix this, avoid searching the extent tree when allocating blocks
      for bigalloc + inline files that are being converted from inline to
      extent mapped.
      
      Signed-off-by: default avatarEric Whitney <enwlinux@gmail.com>
      Link: https://lore.kernel.org/r/20221117152207.2424-1-enwlinux@gmail.com
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Cc: stable@kernel.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1ed1eef0
    • Eric Whitney's avatar
      ext4: fix reserved cluster accounting at delayed write time · d40e09f7
      Eric Whitney authored
      [ Upstream commit 0b02f4c0
      
       ]
      
      The code in ext4_da_map_blocks sometimes reserves space for more
      delayed allocated clusters than it should, resulting in premature
      ENOSPC, exceeded quota, and inaccurate free space reporting.
      
      Fix this by checking for written and unwritten blocks shared in the
      same cluster with the newly delayed allocated block.  A cluster
      reservation should not be made for a cluster for which physical space
      has already been allocated.
      
      Signed-off-by: default avatarEric Whitney <enwlinux@gmail.com>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Stable-dep-of: 131294c3
      
       ("ext4: fix delayed allocation bug in ext4_clu_mapped for bigalloc + inline")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d40e09f7
    • Eric Whitney's avatar
      ext4: add new pending reservation mechanism · 9bacbb4c
      Eric Whitney authored
      [ Upstream commit 1dc0aa46
      
       ]
      
      Add new pending reservation mechanism to help manage reserved cluster
      accounting.  Its primary function is to avoid the need to read extents
      from the disk when invalidating pages as a result of a truncate, punch
      hole, or collapse range operation.
      
      Signed-off-by: default avatarEric Whitney <enwlinux@gmail.com>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Stable-dep-of: 131294c3
      
       ("ext4: fix delayed allocation bug in ext4_clu_mapped for bigalloc + inline")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9bacbb4c
    • Eric Whitney's avatar
      ext4: generalize extents status tree search functions · cca8671f
      Eric Whitney authored
      [ Upstream commit ad431025
      
       ]
      
      Ext4 contains a few functions that are used to search for delayed
      extents or blocks in the extents status tree.  Rather than duplicate
      code to add new functions to search for extents with different status
      values, such as written or a combination of delayed and unwritten,
      generalize the existing code to search for caller-specified extents
      status values.  Also, move this code into extents_status.c where it
      is better associated with the data structures it operates upon, and
      where it can be more readily used to implement new extents status tree
      functions that might want a broader scope for i_es_lock.
      
      Three missing static specifiers in RFC version of patch reported and
      fixed by Fengguang Wu <fengguang.wu@intel.com>.
      
      Signed-off-by: default avatarEric Whitney <enwlinux@gmail.com>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Stable-dep-of: 131294c3
      
       ("ext4: fix delayed allocation bug in ext4_clu_mapped for bigalloc + inline")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cca8671f
    • Ye Bin's avatar
      ext4: fix uninititialized value in 'ext4_evict_inode' · f0bffdcc
      Ye Bin authored
      [ Upstream commit 7ea71af9 ]
      
      Syzbot found the following issue:
      =====================================================
      BUG: KMSAN: uninit-value in ext4_evict_inode+0xdd/0x26b0 fs/ext4/inode.c:180
       ext4_evict_inode+0xdd/0x26b0 fs/ext4/inode.c:180
       evict+0x365/0x9a0 fs/inode.c:664
       iput_final fs/inode.c:1747 [inline]
       iput+0x985/0xdd0 fs/inode.c:1773
       __ext4_new_inode+0xe54/0x7ec0 fs/ext4/ialloc.c:1361
       ext4_mknod+0x376/0x840 fs/ext4/namei.c:2844
       vfs_mknod+0x79d/0x830 fs/namei.c:3914
       do_mknodat+0x47d/0xaa0
       __do_sys_mknodat fs/namei.c:3992 [inline]
       __se_sys_mknodat fs/namei.c:3989 [inline]
       __ia32_sys_mknodat+0xeb/0x150 fs/namei.c:3989
       do_syscall_32_irqs_on arch/x86/entry/common.c:112 [inline]
       __do_fast_syscall_32+0xa2/0x100 arch/x86/entry/common.c:178
       do_fast_syscall_32+0x33/0x70 arch/x86/entry/common.c:203
       do_SYSENTER_32+0x1b/0x20 arch/x86/entry/common.c:246
       entry_SYSENTER_compat_after_hwframe+0x70/0x82
      
      Uninit was created at:
       __alloc_pages+0x9f1/0xe80 mm/page_alloc.c:5578
       alloc_pages+0xaae/0xd80 mm/mempolicy.c:2285
       alloc_slab_page mm/slub.c:1794 [inline]
       allocate_slab+0x1b5/0x1010 mm/slub.c:1939
       new_slab mm/slub.c:1992 [inline]
       ___slab_alloc+0x10c3/0x2d60 mm/slub.c:3180
       __slab_alloc mm/slub.c:3279 [inline]
       slab_alloc_node mm/slub.c:3364 [inline]
       slab_alloc mm/slub.c:3406 [inline]
       __kmem_cache_alloc_lru mm/slub.c:3413 [inline]
       kmem_cache_alloc_lru+0x6f3/0xb30 mm/slub.c:3429
       alloc_inode_sb include/linux/fs.h:3117 [inline]
       ext4_alloc_inode+0x5f/0x860 fs/ext4/super.c:1321
       alloc_inode+0x83/0x440 fs/inode.c:259
       new_inode_pseudo fs/inode.c:1018 [inline]
       new_inode+0x3b/0x430 fs/inode.c:1046
       __ext4_new_inode+0x2a7/0x7ec0 fs/ext4/ialloc.c:959
       ext4_mkdir+0x4d5/0x1560 fs/ext4/namei.c:2992
       vfs_mkdir+0x62a/0x870 fs/namei.c:4035
       do_mkdirat+0x466/0x7b0 fs/namei.c:4060
       __do_sys_mkdirat fs/namei.c:4075 [inline]
       __se_sys_mkdirat fs/namei.c:4073 [inline]
       __ia32_sys_mkdirat+0xc4/0x120 fs/namei.c:4073
       do_syscall_32_irqs_on arch/x86/entry/common.c:112 [inline]
       __do_fast_syscall_32+0xa2/0x100 arch/x86/entry/common.c:178
       do_fast_syscall_32+0x33/0x70 arch/x86/entry/common.c:203
       do_SYSENTER_32+0x1b/0x20 arch/x86/entry/common.c:246
       entry_SYSENTER_compat_after_hwframe+0x70/0x82
      
      CPU: 1 PID: 4625 Comm: syz-executor.2 Not tainted 6.1.0-rc4-syzkaller-62821-gcb231e2f67ec #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
      =====================================================
      
      Now, 'ext4_alloc_inode()' didn't init 'ei->i_flags'. If new inode failed
      before set 'ei->i_flags' in '__ext4_new_inode()', then do 'iput()'. As after
      6bc0d63d
      
       commit will access 'ei->i_flags' in 'ext4_evict_inode()' which
      will lead to access uninit-value.
      To solve above issue just init 'ei->i_flags' in 'ext4_alloc_inode()'.
      
      Reported-by: default avatar <syzbot+57b25da729eb0b88177d@syzkaller.appspotmail.com>
      Signed-off-by: default avatarYe Bin <yebin10@huawei.com>
      Fixes: 6bc0d63d
      
       ("ext4: remove EA inode entry from mbcache on inode eviction")
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Reviewed-by: default avatarEric Biggers <ebiggers@google.com>
      Link: https://lore.kernel.org/r/20221117073603.2598882-1-yebin@huaweicloud.com
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Cc: stable@kernel.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f0bffdcc
    • Baokun Li's avatar
      ext4: fix use-after-free in ext4_orphan_cleanup · 7f801a15
      Baokun Li authored
      [ Upstream commit a71248b1
      
       ]
      
      I caught a issue as follows:
      ==================================================================
       BUG: KASAN: use-after-free in __list_add_valid+0x28/0x1a0
       Read of size 8 at addr ffff88814b13f378 by task mount/710
      
       CPU: 1 PID: 710 Comm: mount Not tainted 6.1.0-rc3-next #370
       Call Trace:
        <TASK>
        dump_stack_lvl+0x73/0x9f
        print_report+0x25d/0x759
        kasan_report+0xc0/0x120
        __asan_load8+0x99/0x140
        __list_add_valid+0x28/0x1a0
        ext4_orphan_cleanup+0x564/0x9d0 [ext4]
        __ext4_fill_super+0x48e2/0x5300 [ext4]
        ext4_fill_super+0x19f/0x3a0 [ext4]
        get_tree_bdev+0x27b/0x450
        ext4_get_tree+0x19/0x30 [ext4]
        vfs_get_tree+0x49/0x150
        path_mount+0xaae/0x1350
        do_mount+0xe2/0x110
        __x64_sys_mount+0xf0/0x190
        do_syscall_64+0x35/0x80
        entry_SYSCALL_64_after_hwframe+0x63/0xcd
        </TASK>
       [...]
      ==================================================================
      
      Above issue may happen as follows:
      -------------------------------------
      ext4_fill_super
        ext4_orphan_cleanup
         --- loop1: assume last_orphan is 12 ---
          list_add(&EXT4_I(inode)->i_orphan, &EXT4_SB(sb)->s_orphan)
          ext4_truncate --> return 0
            ext4_inode_attach_jinode --> return -ENOMEM
          iput(inode) --> free inode<12>
         --- loop2: last_orphan is still 12 ---
          list_add(&EXT4_I(inode)->i_orphan, &EXT4_SB(sb)->s_orphan);
          // use inode<12> and trigger UAF
      
      To solve this issue, we need to propagate the return value of
      ext4_inode_attach_jinode() appropriately.
      
      Signed-off-by: default avatarBaokun Li <libaokun1@huawei.com>
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Link: https://lore.kernel.org/r/20221102080633.1630225-1-libaokun1@huawei.com
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Cc: stable@kernel.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7f801a15
    • zhengliang's avatar
      ext4: lost matching-pair of trace in ext4_truncate · 87cf27e5
      zhengliang authored
      [ Upstream commit 9a5d265f
      
       ]
      
      It should call trace exit in all return path for ext4_truncate.
      
      Signed-off-by: default avatarzhengliang <zhengliang6@huawei.com>
      Reviewed-by: default avatarAndreas Dilger <adilger@dilger.ca>
      Reviewed-by: default avatarRitesh Harjani <riteshh@linux.ibm.com>
      Link: https://lore.kernel.org/r/20200701083027.45996-1-zhengliang6@huawei.com
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Stable-dep-of: a71248b1
      
       ("ext4: fix use-after-free in ext4_orphan_cleanup")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      87cf27e5
    • Baokun Li's avatar
      ext4: fix bug_on in __es_tree_search caused by bad quota inode · fb1d3b41
      Baokun Li authored
      [ Upstream commit d3238774
      
       ]
      
      We got a issue as fllows:
      ==================================================================
       kernel BUG at fs/ext4/extents_status.c:202!
       invalid opcode: 0000 [#1] PREEMPT SMP
       CPU: 1 PID: 810 Comm: mount Not tainted 6.1.0-rc1-next-g9631525255e3 #352
       RIP: 0010:__es_tree_search.isra.0+0xb8/0xe0
       RSP: 0018:ffffc90001227900 EFLAGS: 00010202
       RAX: 0000000000000000 RBX: 0000000077512a0f RCX: 0000000000000000
       RDX: 0000000000000002 RSI: 0000000000002a10 RDI: ffff8881004cd0c8
       RBP: ffff888177512ac8 R08: 47ffffffffffffff R09: 0000000000000001
       R10: 0000000000000001 R11: 00000000000679af R12: 0000000000002a10
       R13: ffff888177512d88 R14: 0000000077512a10 R15: 0000000000000000
       FS: 00007f4bd76dbc40(0000)GS:ffff88842fd00000(0000)knlGS:0000000000000000
       CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
       CR2: 00005653bf993cf8 CR3: 000000017bfdf000 CR4: 00000000000006e0
       DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
       DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
       Call Trace:
        <TASK>
        ext4_es_cache_extent+0xe2/0x210
        ext4_cache_extents+0xd2/0x110
        ext4_find_extent+0x5d5/0x8c0
        ext4_ext_map_blocks+0x9c/0x1d30
        ext4_map_blocks+0x431/0xa50
        ext4_getblk+0x82/0x340
        ext4_bread+0x14/0x110
        ext4_quota_read+0xf0/0x180
        v2_read_header+0x24/0x90
        v2_check_quota_file+0x2f/0xa0
        dquot_load_quota_sb+0x26c/0x760
        dquot_load_quota_inode+0xa5/0x190
        ext4_enable_quotas+0x14c/0x300
        __ext4_fill_super+0x31cc/0x32c0
        ext4_fill_super+0x115/0x2d0
        get_tree_bdev+0x1d2/0x360
        ext4_get_tree+0x19/0x30
        vfs_get_tree+0x26/0xe0
        path_mount+0x81d/0xfc0
        do_mount+0x8d/0xc0
        __x64_sys_mount+0xc0/0x160
        do_syscall_64+0x35/0x80
        entry_SYSCALL_64_after_hwframe+0x63/0xcd
        </TASK>
      ==================================================================
      
      Above issue may happen as follows:
      -------------------------------------
      ext4_fill_super
       ext4_orphan_cleanup
        ext4_enable_quotas
         ext4_quota_enable
          ext4_iget --> get error inode <5>
           ext4_ext_check_inode --> Wrong imode makes it escape inspection
           make_bad_inode(inode) --> EXT4_BOOT_LOADER_INO set imode
          dquot_load_quota_inode
           vfs_setup_quota_inode --> check pass
           dquot_load_quota_sb
            v2_check_quota_file
             v2_read_header
              ext4_quota_read
               ext4_bread
                ext4_getblk
                 ext4_map_blocks
                  ext4_ext_map_blocks
                   ext4_find_extent
                    ext4_cache_extents
                     ext4_es_cache_extent
                      __es_tree_search.isra.0
                       ext4_es_end --> Wrong extents trigger BUG_ON
      
      In the above issue, s_usr_quota_inum is set to 5, but inode<5> contains
      incorrect imode and disordered extents. Because 5 is EXT4_BOOT_LOADER_INO,
      the ext4_ext_check_inode check in the ext4_iget function can be bypassed,
      finally, the extents that are not checked trigger the BUG_ON in the
      __es_tree_search function. To solve this issue, check whether the inode is
      bad_inode in vfs_setup_quota_inode().
      
      Signed-off-by: default avatarBaokun Li <libaokun1@huawei.com>
      Reviewed-by: default avatarChaitanya Kulkarni <kch@nvidia.com>
      Reviewed-by: default avatarJason Yan <yanaijie@huawei.com>
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Link: https://lore.kernel.org/r/20221026042310.3839669-2-libaokun1@huawei.com
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Cc: stable@kernel.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fb1d3b41
    • Jan Kara's avatar
      quota: Factor out setup of quota inode · 7e362ae4
      Jan Kara authored
      [ Upstream commit c7d3d283
      
       ]
      
      Factor out setting up of quota inode and eventual error cleanup from
      vfs_load_quota_inode(). This will simplify situation for filesystems
      that don't have any quota inodes.
      
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Stable-dep-of: d3238774
      
       ("ext4: fix bug_on in __es_tree_search caused by bad quota inode")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7e362ae4
    • Ferry Toth's avatar
      usb: ulpi: defer ulpi_register on ulpi_read_id timeout · 288ae57f
      Ferry Toth authored
      [ Upstream commit 8a7b31d5 ]
      
      Since commit 0f010171 ("usb: dwc3: Don't switch OTG -> peripheral
      if extcon is present") Dual Role support on Intel Merrifield platform
      broke due to rearranging the call to dwc3_get_extcon().
      
      It appears to be caused by ulpi_read_id() on the first test write failing
      with -ETIMEDOUT. Currently ulpi_read_id() expects to discover the phy via
      DT when the test write fails and returns 0 in that case, even if DT does not
      provide the phy. As a result usb probe completes without phy.
      
      Make ulpi_read_id() return -ETIMEDOUT to its user if the first test write
      fails. The user should then handle it appropriately. A follow up patch
      will make dwc3_core_init() set -EPROBE_DEFER in this case and bail out.
      
      Fixes: ef6a7bcf
      
       ("usb: ulpi: Support device discovery via DT")
      Cc: stable@vger.kernel.org
      Acked-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
      Signed-off-by: default avatarFerry Toth <ftoth@exalondelft.nl>
      Link: https://lore.kernel.org/r/20221205201527.13525-2-ftoth@exalondelft.nl
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      288ae57f
    • Steven Rostedt's avatar
      kest.pl: Fix grub2 menu handling for rebooting · 69af0e61
      Steven Rostedt authored
      [ Upstream commit 26df05a8 ]
      
      grub2 has submenus where to use grub-reboot, it requires:
      
        grub-reboot X>Y
      
      where X is the main index and Y is the submenu. Thus if you have:
      
      menuentry 'Debian GNU/Linux' --class debian --class gnu-linux ...
      	[...]
      }
      submenu 'Advanced options for Debian GNU/Linux' $menuentry_id_option ...
              menuentry 'Debian GNU/Linux, with Linux 6.0.0-4-amd64' --class debian --class gnu-linux ...
                      [...]
              }
              menuentry 'Debian GNU/Linux, with Linux 6.0.0-4-amd64 (recovery mode)' --class debian --class gnu-linux ...
      		[...]
              }
              menuentry 'Debian GNU/Linux, with Linux test' --class debian --class gnu-linux ...
                      [...]
              }
      
      And wanted to boot to the "Linux test" kernel, you need to run:
      
       # grub-reboot 1>2
      
      As 1 is the second top menu (the submenu) and 2 is the third of the sub
      menu entries.
      
      Have the grub.cfg parsing for grub2 handle such cases.
      
      Cc: stable@vger.kernel.org
      Fixes: a15ba913
      
       ("ktest: Add support for grub2")
      Reviewed-by: default avatarJohn 'Warthog9' Hawley (VMware) <warthog9@eaglescrag.net>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      69af0e61
    • Libo Chen's avatar
      ktest.pl: Fix incorrect reboot for grub2bls · fbbbbb88
      Libo Chen authored
      [ Upstream commit 271e0c9d ]
      
      This issue was first noticed when I was testing different kernels on
      Oracle Linux 8 which as Fedora 30+ adopts BLS as default. Even though a
      kernel entry was added successfully and the index of that kernel entry was
      retrieved correctly, ktest still wouldn't reboot the system into
      user-specified kernel.
      
      The bug was spotted in subroutine reboot_to where the if-statement never
      checks for REBOOT_TYPE "grub2bls", therefore the desired entry will not be
      set for the next boot.
      
      Add a check for "grub2bls" so that $grub_reboot $grub_number can
      be run before a reboot if REBOOT_TYPE is "grub2bls" then we can boot to
      the correct kernel.
      
      Link: https://lkml.kernel.org/r/20201121021243.1532477-1-libo.chen@oracle.com
      
      Cc: stable@vger.kernel.org
      Fixes: ac246645
      
       ("ktest: introduce grub2bls REBOOT_TYPE option")
      Signed-off-by: default avatarLibo Chen <libo.chen@oracle.com>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Stable-dep-of: 26df05a8
      
       ("kest.pl: Fix grub2 menu handling for rebooting")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fbbbbb88
    • Masayoshi Mizuma's avatar
      ktest: introduce grub2bls REBOOT_TYPE option · c58383a2
      Masayoshi Mizuma authored
      [ Upstream commit ac246645
      
       ]
      
      Fedora 30 introduces Boot Loader Specification (BLS),
      it changes around grub entry configuration.
      
      kernel entries aren't in grub.cfg. We can get the entries
      by "grubby --info=ALL" command.
      
      Introduce grub2bls as REBOOT_TYPE option for BLS.
      
      Link: http://lkml.kernel.org/r/20190509213647.6276-4-msys.mizuma@gmail.com
      
      Signed-off-by: default avatarMasayoshi Mizuma <m.mizuma@jp.fujitsu.com>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Stable-dep-of: 26df05a8
      
       ("kest.pl: Fix grub2 menu handling for rebooting")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c58383a2
    • Masayoshi Mizuma's avatar
      ktest: cleanup get_grub_index · 42fe7856
      Masayoshi Mizuma authored
      [ Upstream commit 38891392
      
       ]
      
      Cleanup get_grub_index().
      
      Link: http://lkml.kernel.org/r/20190509213647.6276-3-msys.mizuma@gmail.com
      
      Signed-off-by: default avatarMasayoshi Mizuma <m.mizuma@jp.fujitsu.com>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Stable-dep-of: 26df05a8
      
       ("kest.pl: Fix grub2 menu handling for rebooting")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      42fe7856
    • Masayoshi Mizuma's avatar
      ktest: introduce _get_grub_index · 5f2956dc
      Masayoshi Mizuma authored
      [ Upstream commit f824b686
      
       ]
      
      Introduce _get_grub_index() to deal with Boot Loader
      Specification (BLS) and cleanup.
      
      Link: http://lkml.kernel.org/r/20190509213647.6276-2-msys.mizuma@gmail.com
      
      Signed-off-by: default avatarMasayoshi Mizuma <m.mizuma@jp.fujitsu.com>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Stable-dep-of: 26df05a8
      
       ("kest.pl: Fix grub2 menu handling for rebooting")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5f2956dc
    • Masayoshi Mizuma's avatar
      ktest: Add support for meta characters in GRUB_MENU · 80295824
      Masayoshi Mizuma authored
      [ Upstream commit 68911069
      
       ]
      
      ktest fails if meta characters are in GRUB_MENU, for example
      GRUB_MENU = 'Fedora (test)'
      
      The failure happens because the meta characters are not escaped,
      so the menu doesn't match in any entries in GRUB_FILE.
      
      Use quotemeta() to escape the meta characters.
      
      Link: http://lkml.kernel.org/r/20190417235823.18176-1-msys.mizuma@gmail.com
      
      Signed-off-by: default avatarMasayoshi Mizuma <m.mizuma@jp.fujitsu.com>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Stable-dep-of: 26df05a8
      
       ("kest.pl: Fix grub2 menu handling for rebooting")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      80295824
    • Kai Vehmanen's avatar
      ALSA: hda/hdmi: fix failures at PCM open on Intel ICL and later · 7795d8f1
      Kai Vehmanen authored
      [ Upstream commit 56275036
      
       ]
      
      When HDMI PCM devices are opened in a specific order, with at least one
      HDMI/DP receiver connected, ALSA PCM open fails to -EBUSY on the
      connected monitor, on recent Intel platforms (ICL/JSL and newer). While
      this is not a typical sequence, at least Pulseaudio does this every time
      when it is started, to discover the available PCMs.
      
      The rootcause is an invalid assumption in hdmi_add_pin(), where the
      total number of converters is assumed to be known at the time the
      function is called. On older Intel platforms this held true, but after
      ICL/JSL, the order how pins and converters are in the subnode list as
      returned by snd_hda_get_sub_nodes(), was changed. As a result,
      information for some converters was not stored to per_pin->mux_nids.
      And this means some pins cannot be connected to all converters, and
      application instead gets -EBUSY instead at open.
      
      The assumption that converters are always before pins in the subnode
      list, is not really a valid one. Fix the problem in hdmi_parse_codec()
      by introducing separate loops for discovering converters and pins.
      
      BugLink: https://github.com/thesofproject/linux/issues/1978
      BugLink: https://github.com/thesofproject/linux/issues/2216
      BugLink: https://github.com/thesofproject/linux/issues/2217
      Reviewed-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
      Reviewed-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
      Signed-off-by: default avatarKai Vehmanen <kai.vehmanen@linux.intel.com>
      Link: https://lore.kernel.org/r/20200703153818.2808592-1-kai.vehmanen@linux.intel.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7795d8f1
    • Michael Walle's avatar
      wifi: wilc1000: sdio: fix module autoloading · f782e0ab
      Michael Walle authored
      [ Upstream commit 57d545b5
      
       ]
      
      There are no SDIO module aliases included in the driver, therefore,
      module autoloading isn't working. Add the proper MODULE_DEVICE_TABLE().
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMichael Walle <michael@walle.cc>
      Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
      Link: https://lore.kernel.org/r/20221027171221.491937-1-michael@walle.cc
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f782e0ab
    • Herbert Xu's avatar
      ipv6: raw: Deduct extension header length in rawv6_push_pending_frames · f487d636
      Herbert Xu authored
      commit cb3e9864
      
       upstream.
      
      The total cork length created by ip6_append_data includes extension
      headers, so we must exclude them when comparing them against the
      IPV6_CHECKSUM offset which does not include extension headers.
      
      Reported-by: default avatarKyle Zeng <zengyhkyle@gmail.com>
      Fixes: 357b40a1
      
       ("[IPV6]: IPV6_CHECKSUM socket option can corrupt kernel memory")
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f487d636
    • Hans de Goede's avatar
      platform/x86: sony-laptop: Don't turn off 0x153 keyboard backlight during probe · 08ac1d9e
      Hans de Goede authored
      commit ad75bd85 upstream.
      
      The 0x153 version of the kbd backlight control SNC handle has no separate
      address to probe if the backlight is there.
      
      This turns the probe call into a set keyboard backlight call with a value
      of 0 turning off the keyboard backlight.
      
      Skip probing when there is no separate probe address to avoid this.
      
      Link: https://bugzilla.redhat.com/show_bug.cgi?id=1583752
      Fixes: 800f2017
      
       ("Keyboard backlight control for some Vaio Fit models")
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Reviewed-by: default avatarMattia Dongili <malattia@linux.it>
      Link: https://lore.kernel.org/r/20221213122943.11123-1-hdegoede@redhat.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      08ac1d9e
    • Volker Lendecke's avatar
      cifs: Fix uninitialized memory read for smb311 posix symlink create · 707682db
      Volker Lendecke authored
      commit a152d05a upstream.
      
      If smb311 posix is enabled, we send the intended mode for file
      creation in the posix create context. Instead of using what's there on
      the stack, create the mfsymlink file with 0644.
      
      Fixes: ce558b0e
      
       ("smb3: Add posix create context for smb3.11 posix mounts")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarVolker Lendecke <vl@samba.org>
      Reviewed-by: default avatarTom Talpey <tom@talpey.com>
      Reviewed-by: default avatarPaulo Alcantara (SUSE) <pc@cjr.nz>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      707682db
    • Clement Lecigne's avatar
      ALSA: pcm: Move rwsem lock inside snd_ctl_elem_read to prevent UAF · 5b2ea7e9
      Clement Lecigne authored
      [ Note: this is a fix that works around the bug equivalently as the
        two upstream commits:
         1fa4445f ("ALSA: control - introduce snd_ctl_notify_one() helper")
         56b88b50
      
       ("ALSA: pcm: Move rwsem lock inside snd_ctl_elem_read to prevent UAF")
        but in a simpler way to fit with older stable trees -- tiwai ]
      
      Add missing locking in ctl_elem_read_user/ctl_elem_write_user which can be
      easily triggered and turned into an use-after-free.
      
      Example code paths with SNDRV_CTL_IOCTL_ELEM_READ:
      
      64-bits:
      snd_ctl_ioctl
        snd_ctl_elem_read_user
          [takes controls_rwsem]
          snd_ctl_elem_read [lock properly held, all good]
          [drops controls_rwsem]
      
      32-bits (compat):
      snd_ctl_ioctl_compat
        snd_ctl_elem_write_read_compat
          ctl_elem_write_read
            snd_ctl_elem_read [missing lock, not good]
      
      CVE-2023-0266 was assigned for this issue.
      
      Signed-off-by: default avatarClement Lecigne <clecigne@google.com>
      Cc: stable@kernel.org # 5.12 and older
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Reviewed-by: default avatarJaroslav Kysela <perex@perex.cz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5b2ea7e9
    • Paolo Abeni's avatar
      net/ulp: prevent ULP without clone op from entering the LISTEN status · 755193f2
      Paolo Abeni authored
      commit 2c02d41d upstream.
      
      When an ULP-enabled socket enters the LISTEN status, the listener ULP data
      pointer is copied inside the child/accepted sockets by sk_clone_lock().
      
      The relevant ULP can take care of de-duplicating the context pointer via
      the clone() operation, but only MPTCP and SMC implement such op.
      
      Other ULPs may end-up with a double-free at socket disposal time.
      
      We can't simply clear the ULP data at clone time, as TLS replaces the
      socket ops with custom ones assuming a valid TLS ULP context is
      available.
      
      Instead completely prevent clone-less ULP sockets from entering the
      LISTEN status.
      
      Fixes: 734942cc
      
       ("tcp: ULP infrastructure")
      Reported-by: default avatarslipper <slipper.alive@gmail.com>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Link: https://lore.kernel.org/r/4b80c3d1dbe3d0ab072f80450c202d9bc88b4b03.1672740602.git.pabeni@redhat.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      755193f2
    • Heiko Carstens's avatar
      s390/percpu: add READ_ONCE() to arch_this_cpu_to_op_simple() · 5a56f7cd
      Heiko Carstens authored
      commit e3f360db
      
       upstream.
      
      Make sure that *ptr__ within arch_this_cpu_to_op_simple() is only
      dereferenced once by using READ_ONCE(). Otherwise the compiler could
      generate incorrect code.
      
      Cc: <stable@vger.kernel.org>
      Reviewed-by: default avatarAlexander Gordeev <agordeev@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5a56f7cd
    • Adrian Hunter's avatar
      perf auxtrace: Fix address filter duplicate symbol selection · 58cee3aa
      Adrian Hunter authored
      commit cf129830 upstream.
      
      When a match has been made to the nth duplicate symbol, return
      success not error.
      
      Example:
      
        Before:
      
          $ cat file.c
          cat: file.c: No such file or directory
          $ cat file1.c
          #include <stdio.h>
      
          static void func(void)
          {
                  printf("First func\n");
          }
      
          void other(void);
      
          int main()
          {
                  func();
                  other();
                  return 0;
          }
          $ cat file2.c
          #include <stdio.h>
      
          static void func(void)
          {
                  printf("Second func\n");
          }
      
          void other(void)
          {
                  func();
          }
      
          $ gcc -Wall -Wextra -o test file1.c file2.c
          $ perf record -e intel_pt//u --filter 'filter func @ ./test' -- ./test
          Multiple symbols with name 'func'
          #1      0x1149  l       func
                          which is near           main
          #2      0x1179  l       func
                          which is near           other
          Disambiguate symbol name by inserting #n after the name e.g. func #2
          Or select a global symbol by inserting #0 or #g or #G
          Failed to parse address filter: 'filter func @ ./test'
          Filter format is: filter|start|stop|tracestop <start symbol or address> [/ <end symbol or size>] [@<file name>]
          Where multiple filters are separated by space or comma.
          $ perf record -e intel_pt//u --filter 'filter func #2 @ ./test' -- ./test
          Failed to parse address filter: 'filter func #2 @ ./test'
          Filter format is: filter|start|stop|tracestop <start symbol or address> [/ <end symbol or size>] [@<file name>]
          Where multiple filters are separated by space or comma.
      
        After:
      
          $ perf record -e intel_pt//u --filter 'filter func #2 @ ./test' -- ./test
          First func
          Second func
          [ perf record: Woken up 1 times to write data ]
          [ perf record: Captured and wrote 0.016 MB perf.data ]
          $ perf script --itrace=b -Ftime,flags,ip,sym,addr --ns
          1231062.526977619:   tr strt                               0 [unknown] =>     558495708179 func
          1231062.526977619:   tr end  call               558495708188 func =>     558495708050 _init
          1231062.526979286:   tr strt                               0 [unknown] =>     55849570818d func
          1231062.526979286:   tr end  return             55849570818f func =>     55849570819d other
      
      Fixes: 1b36c03e
      
       ("perf record: Add support for using symbols in address filters")
      Reported-by: default avatarDmitrii Dolgov <9erthalion6@gmail.com>
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Tested-by: default avatarDmitry Dolgov <9erthalion6@gmail.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20230110185659.15979-1-adrian.hunter@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      58cee3aa