1. 21 Dec, 2023 1 commit
    • Rafael J. Wysocki's avatar
      Merge tag 'devfreq-next-for-6.8' of... · bfd7b2d9
      Rafael J. Wysocki authored
      Merge tag 'devfreq-next-for-6.8' of git://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/linux into pm-devfreq
      
      Merge devfreq updates for v6.8 from Chanwoo Choi:
      
      "1. Fix buffer overflow of trans_stat_show sysfs node on devfreq core
      
          - Fix buffer overflow of trans_stat_show sysfs node to replace
            sprintf with scnprintf and then replace it with sysfs_emit
            according to the syfs guide.
      
       2. Fix the timer list corruption when frequent switching of governor
          by synchronizing the devfreq_moniotr_start and _stop function."
      
      * tag 'devfreq-next-for-6.8' of git://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/linux:
        PM / devfreq: Synchronize devfreq_monitor_[start/stop]
        PM / devfreq: Convert to use sysfs_emit_at() API
        PM / devfreq: Fix buffer overflow in trans_stat_show
      bfd7b2d9
  2. 18 Dec, 2023 1 commit
    • Mukesh Ojha's avatar
      PM / devfreq: Synchronize devfreq_monitor_[start/stop] · aed5ed59
      Mukesh Ojha authored
      There is a chance if a frequent switch of the governor
      done in a loop result in timer list corruption where
      timer cancel being done from two place one from
      cancel_delayed_work_sync() and followed by expire_timers()
      can be seen from the traces[1].
      
      while true
      do
              echo "simple_ondemand" > /sys/class/devfreq/1d84000.ufshc/governor
              echo "performance" > /sys/class/devfreq/1d84000.ufshc/governor
      done
      
      It looks to be issue with devfreq driver where
      device_monitor_[start/stop] need to synchronized so that
      delayed work should get corrupted while it is either
      being queued or running or being cancelled.
      
      Let's use polling flag and devfreq lock to synchronize the
      queueing the timer instance twice and work data being
      corrupted.
      
      [1]
      ...
      ..
      <idle>-0    [003]   9436.209662:  timer_cancel   timer=0xffffff80444f0428
      <idle>-0    [003]   9436.209664:  timer_expire_entry   timer=0xffffff80444f0428  now=0x10022da1c  function=__typeid__ZTSFvP10timer_listE_global_addr  baseclk=0x10022da1c
      <idle>-0    [003]   9436.209718:  timer_expire_exit   timer=0xffffff80444f0428
      kworker/u16:6-14217    [003]   9436.209863:  timer_start   timer=0xffffff80444f0428  function=__typeid__ZTSFvP10timer_listE_global_addr  expires=0x10022da2b  now=0x10022da1c  flags=182452227
      vendor.xxxyyy.ha-1593    [004]   9436.209888:  timer_cancel   timer=0xffffff80444f0428
      vendor.xxxyyy.ha-1593    [004]   9436.216390:  timer_init   timer=0xffffff80444f0428
      vendor.xxxyyy.ha-1593    [004]   9436.216392:  timer_start   timer=0xffffff80444f0428  function=__typeid__ZTSFvP10timer_listE_global_addr  expires=0x10022da2c  now=0x10022da1d  flags=186646532
      vendor.xxxyyy.ha-1593    [005]   9436.220992:  timer_cancel   timer=0xffffff80444f0428
      xxxyyyTraceManag-7795    [004]   9436.261641:  timer_cancel   timer=0xffffff80444f0428
      
      [2]
      
       9436.261653][    C4] Unable to handle kernel paging request at virtual address dead00000000012a
      [ 9436.261664][    C4] Mem abort info:
      [ 9436.261666][    C4]   ESR = 0x96000044
      [ 9436.261669][    C4]   EC = 0x25: DABT (current EL), IL = 32 bits
      [ 9436.261671][    C4]   SET = 0, FnV = 0
      [ 9436.261673][    C4]   EA = 0, S1PTW = 0
      [ 9436.261675][    C4] Data abort info:
      [ 9436.261677][    C4]   ISV = 0, ISS = 0x00000044
      [ 9436.261680][    C4]   CM = 0, WnR = 1
      [ 9436.261682][    C4] [dead00000000012a] address between user and kernel address ranges
      [ 9436.261685][    C4] Internal error: Oops: 96000044 [#1] PREEMPT SMP
      [ 9436.261701][    C4] Skip md ftrace buffer dump for: 0x3a982d0
      ...
      
      [ 9436.262138][    C4] CPU: 4 PID: 7795 Comm: TraceManag Tainted: G S      W  O      5.10.149-android12-9-o-g17f915d29d0c #1
      [ 9436.262141][    C4] Hardware name: Qualcomm Technologies, Inc.  (DT)
      [ 9436.262144][    C4] pstate: 22400085 (nzCv daIf +PAN -UAO +TCO BTYPE=--)
      [ 9436.262161][    C4] pc : expire_timers+0x9c/0x438
      [ 9436.262164][    C4] lr : expire_timers+0x2a4/0x438
      [ 9436.262168][    C4] sp : ffffffc010023dd0
      [ 9436.262171][    C4] x29: ffffffc010023df0 x28: ffffffd0636fdc18
      [ 9436.262178][    C4] x27: ffffffd063569dd0 x26: ffffffd063536008
      [ 9436.262182][    C4] x25: 0000000000000001 x24: ffffff88f7c69280
      [ 9436.262185][    C4] x23: 00000000000000e0 x22: dead000000000122
      [ 9436.262188][    C4] x21: 000000010022da29 x20: ffffff8af72b4e80
      [ 9436.262191][    C4] x19: ffffffc010023e50 x18: ffffffc010025038
      [ 9436.262195][    C4] x17: 0000000000000240 x16: 0000000000000201
      [ 9436.262199][    C4] x15: ffffffffffffffff x14: ffffff889f3c3100
      [ 9436.262203][    C4] x13: ffffff889f3c3100 x12: 00000000049f56b8
      [ 9436.262207][    C4] x11: 00000000049f56b8 x10: 00000000ffffffff
      [ 9436.262212][    C4] x9 : ffffffc010023e50 x8 : dead000000000122
      [ 9436.262216][    C4] x7 : ffffffffffffffff x6 : ffffffc0100239d8
      [ 9436.262220][    C4] x5 : 0000000000000000 x4 : 0000000000000101
      [ 9436.262223][    C4] x3 : 0000000000000080 x2 : ffffff889edc155c
      [ 9436.262227][    C4] x1 : ffffff8001005200 x0 : ffffff80444f0428
      [ 9436.262232][    C4] Call trace:
      [ 9436.262236][    C4]  expire_timers+0x9c/0x438
      [ 9436.262240][    C4]  __run_timers+0x1f0/0x330
      [ 9436.262245][    C4]  run_timer_softirq+0x28/0x58
      [ 9436.262255][    C4]  efi_header_end+0x168/0x5ec
      [ 9436.262265][    C4]  __irq_exit_rcu+0x108/0x124
      [ 9436.262274][    C4]  __handle_domain_irq+0x118/0x1e4
      [ 9436.262282][    C4]  gic_handle_irq.30369+0x6c/0x2bc
      [ 9436.262286][    C4]  el0_irq_naked+0x60/0x6c
      
      Link: https://lore.kernel.org/all/1700860318-4025-1-git-send-email-quic_mojha@quicinc.com/Reported-by: default avatarJoyyoung Huang <huangzaiyang@oppo.com>
      Acked-by: default avatarMyungJoo Ham <myungjoo.ham@samsung.com>
      Signed-off-by: default avatarMukesh Ojha <quic_mojha@quicinc.com>
      Signed-off-by: default avatarChanwoo Choi <cw00.choi@samsung.com>
      aed5ed59
  3. 17 Dec, 2023 10 commits
  4. 16 Dec, 2023 3 commits
    • Linus Torvalds's avatar
      Merge tag 'trace-v6.7-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace · 3b8a9b2e
      Linus Torvalds authored
      Pull tracing fixes from Steven Rostedt:
      
       - Fix eventfs to check creating new files for events with names greater
         than NAME_MAX. The eventfs lookup needs to check the return result of
         simple_lookup().
      
       - Fix the ring buffer to check the proper max data size. Events must be
         able to fit on the ring buffer sub-buffer, if it cannot, then it
         fails to be written and the logic to add the event is avoided. The
         code to check if an event can fit failed to add the possible absolute
         timestamp which may make the event not be able to fit. This causes
         the ring buffer to go into an infinite loop trying to find a
         sub-buffer that would fit the event. Luckily, there's a check that
         will bail out if it looped over a 1000 times and it also warns.
      
         The real fix is not to add the absolute timestamp to an event that is
         starting at the beginning of a sub-buffer because it uses the
         sub-buffer timestamp.
      
         By avoiding the timestamp at the start of the sub-buffer allows
         events that pass the first check to always find a sub-buffer that it
         can fit on.
      
       - Have large events that do not fit on a trace_seq to print "LINE TOO
         BIG" like it does for the trace_pipe instead of what it does now
         which is to silently drop the output.
      
       - Fix a memory leak of forgetting to free the spare page that is saved
         by a trace instance.
      
       - Update the size of the snapshot buffer when the main buffer is
         updated if the snapshot buffer is allocated.
      
       - Fix ring buffer timestamp logic by removing all the places that tried
         to put the before_stamp back to the write stamp so that the next
         event doesn't add an absolute timestamp. But each of these updates
         added a race where by making the two timestamp equal, it was
         validating the write_stamp so that it can be incorrectly used for
         calculating the delta of an event.
      
       - There's a temp buffer used for printing the event that was using the
         event data size for allocation when it needed to use the size of the
         entire event (meta-data and payload data)
      
       - For hardening, use "%.*s" for printing the trace_marker output, to
         limit the amount that is printed by the size of the event. This was
         discovered by development that added a bug that truncated the '\0'
         and caused a crash.
      
       - Fix a use-after-free bug in the use of the histogram files when an
         instance is being removed.
      
       - Remove a useless update in the rb_try_to_discard of the write_stamp.
         The before_stamp was already changed to force the next event to add
         an absolute timestamp that the write_stamp is not used. But the
         write_stamp is modified again using an unneeded 64-bit cmpxchg.
      
       - Fix several races in the 32-bit implementation of the
         rb_time_cmpxchg() that does a 64-bit cmpxchg.
      
       - While looking at fixing the 64-bit cmpxchg, I noticed that because
         the ring buffer uses normal cmpxchg, and this can be done in NMI
         context, there's some architectures that do not have a working
         cmpxchg in NMI context. For these architectures, fail recording
         events that happen in NMI context.
      
      * tag 'trace-v6.7-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
        ring-buffer: Do not record in NMI if the arch does not support cmpxchg in NMI
        ring-buffer: Have rb_time_cmpxchg() set the msb counter too
        ring-buffer: Fix 32-bit rb_time_read() race with rb_time_cmpxchg()
        ring-buffer: Fix a race in rb_time_cmpxchg() for 32 bit archs
        ring-buffer: Remove useless update to write_stamp in rb_try_to_discard()
        ring-buffer: Do not try to put back write_stamp
        tracing: Fix uaf issue when open the hist or hist_debug file
        tracing: Add size check when printing trace_marker output
        ring-buffer: Have saved event hold the entire event
        ring-buffer: Do not update before stamp when switching sub-buffers
        tracing: Update snapshot buffer on resize if it is allocated
        ring-buffer: Fix memory leak of free page
        eventfs: Fix events beyond NAME_MAX blocking tasks
        tracing: Have large events show up as '[LINE TOO BIG]' instead of nothing
        ring-buffer: Fix writing to the buffer with max_data_size
      3b8a9b2e
    • Linus Torvalds's avatar
      Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux · c8e97fc6
      Linus Torvalds authored
      Pull arm64 fixes from Catalin Marinas:
      
       - Arm CMN perf: fix the DTC allocation failure path which can end up
         erroneously clearing live counters
      
       - arm64/mm: fix hugetlb handling of the dirty page state leading to a
         continuous fault loop in user on hardware without dirty bit
         management (DBM). That's caused by the dirty+writeable information
         not being properly preserved across a series of mprotect(PROT_NONE),
         mprotect(PROT_READ|PROT_WRITE)
      
      * tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux:
        arm64: mm: Always make sw-dirty PTEs hw-dirty in pte_modify
        perf/arm-cmn: Fail DTC counter allocation correctly
      c8e97fc6
    • Linus Torvalds's avatar
      Merge tag 'pci-v6.7-fixes-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci · 2e3f280b
      Linus Torvalds authored
      Pull pci fixes from Bjorn Helgaas:
      
       - Limit Max_Read_Request_Size (MRRS) on some MIPS Loongson systems
         because they don't all support MRRS > 256, and firmware doesn't
         always initialize it correctly, which meant some PCIe devices didn't
         work (Jiaxun Yang)
      
       - Add and use pci_enable_link_state_locked() to prevent potential
         deadlocks in vmd and qcom drivers (Johan Hovold)
      
       - Revert recent (v6.5) acpiphp resource assignment changes that fixed
         issues with hot-adding devices on a root bus or with large BARs, but
         introduced new issues with GPU initialization and hot-adding SCSI
         disks in QEMU VMs and (Bjorn Helgaas)
      
      * tag 'pci-v6.7-fixes-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci:
        Revert "PCI: acpiphp: Reassign resources on bridge if necessary"
        PCI/ASPM: Add pci_disable_link_state_locked() lockdep assert
        PCI/ASPM: Clean up __pci_disable_link_state() 'sem' parameter
        PCI: qcom: Clean up ASPM comment
        PCI: qcom: Fix potential deadlock when enabling ASPM
        PCI: vmd: Fix potential deadlock when enabling ASPM
        PCI/ASPM: Add pci_enable_link_state_locked()
        PCI: loongson: Limit MRRS to 256
      2e3f280b
  5. 15 Dec, 2023 24 commits
  6. 14 Dec, 2023 1 commit
    • Al Viro's avatar
      io_uring/cmd: fix breakage in SOCKET_URING_OP_SIOC* implementation · 1ba0e9d6
      Al Viro authored
      	In 8e9fad0e "io_uring: Add io_uring command support for sockets"
      you've got an include of asm-generic/ioctls.h done in io_uring/uring_cmd.c.
      That had been done for the sake of this chunk -
      +               ret = prot->ioctl(sk, SIOCINQ, &arg);
      +               if (ret)
      +                       return ret;
      +               return arg;
      +       case SOCKET_URING_OP_SIOCOUTQ:
      +               ret = prot->ioctl(sk, SIOCOUTQ, &arg);
      
      SIOC{IN,OUT}Q are defined to symbols (FIONREAD and TIOCOUTQ) that come from
      ioctls.h, all right, but the values vary by the architecture.
      
      FIONREAD is
      	0x467F on mips
      	0x4004667F on alpha, powerpc and sparc
      	0x8004667F on sh and xtensa
      	0x541B everywhere else
      TIOCOUTQ is
      	0x7472 on mips
      	0x40047473 on alpha, powerpc and sparc
      	0x80047473 on sh and xtensa
      	0x5411 everywhere else
      
      ->ioctl() expects the same values it would've gotten from userland; all
      places where we compare with SIOC{IN,OUT}Q are using asm/ioctls.h, so
      they pick the correct values.  io_uring_cmd_sock(), OTOH, ends up
      passing the default ones.
      
      Fixes: 8e9fad0e ("io_uring: Add io_uring command support for sockets")
      Cc:  <stable@vger.kernel.org>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Link: https://lore.kernel.org/r/20231214213408.GT1674809@ZenIVSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
      1ba0e9d6