1. 11 Jul, 2022 1 commit
    • Nick Desaulniers's avatar
      coresight: etm4x: avoid build failure with unrolled loops · 4d45bc82
      Nick Desaulniers authored
      When the following configs are enabled:
      * CORESIGHT
      * CORESIGHT_SOURCE_ETM4X
      * UBSAN
      * UBSAN_TRAP
      
      Clang fails assemble the kernel with the error:
      <instantiation>:1:7: error: expected constant expression in '.inst' directive
      .inst (0xd5200000|((((2) << 19) | ((1) << 16) | (((((((((((0x160 + (i * 4))))) >> 2))) >> 7) & 0x7)) << 12) | ((((((((((0x160 + (i * 4))))) >> 2))) & 0xf)) << 8) | (((((((((((0x160 + (i * 4))))) >> 2))) >> 4) & 0x7)) << 5)))|(.L__reg_num_x8))
            ^
      drivers/hwtracing/coresight/coresight-etm4x-core.c:702:4: note: while in
      macro instantiation
      etm4x_relaxed_read32(csa, TRCCNTVRn(i));
      ^
      drivers/hwtracing/coresight/coresight-etm4x.h:403:4: note: expanded from
      macro 'etm4x_relaxed_read32'
      read_etm4x_sysreg_offset((offset), false)))
      ^
      drivers/hwtracing/coresight/coresight-etm4x.h:383:12: note: expanded
      from macro 'read_etm4x_sysreg_offset'
      __val = read_etm4x_sysreg_const_offset((offset));       \
              ^
      drivers/hwtracing/coresight/coresight-etm4x.h:149:2: note: expanded from
      macro 'read_etm4x_sysreg_const_offset'
      READ_ETM4x_REG(ETM4x_OFFSET_TO_REG(offset))
      ^
      drivers/hwtracing/coresight/coresight-etm4x.h:144:2: note: expanded from
      macro 'READ_ETM4x_REG'
      read_sysreg_s(ETM4x_REG_NUM_TO_SYSREG((reg)))
      ^
      arch/arm64/include/asm/sysreg.h:1108:15: note: expanded from macro
      'read_sysreg_s'
      asm volatile(__mrs_s("%0", r) : "=r" (__val));                  \
                   ^
      arch/arm64/include/asm/sysreg.h:1074:2: note: expanded from macro '__mrs_s'
      "       mrs_s " v ", " __stringify(r) "\n"                      \
       ^
      
      Consider the definitions of TRCSSCSRn and TRCCNTVRn:
      drivers/hwtracing/coresight/coresight-etm4x.h:56
       #define TRCCNTVRn(n)      (0x160 + (n * 4))
      drivers/hwtracing/coresight/coresight-etm4x.h:81
       #define TRCSSCSRn(n)      (0x2A0 + (n * 4))
      
      Where the macro parameter is expanded to i; a loop induction variable
      from etm4_disable_hw.
      
      When any compiler can determine that loops may be unrolled, then the
      __builtin_constant_p check in read_etm4x_sysreg_offset() defined in
      drivers/hwtracing/coresight/coresight-etm4x.h may evaluate to true. This
      can lead to the expression `(0x160 + (i * 4))` being passed to
      read_etm4x_sysreg_const_offset. Via the trace above, this is passed
      through READ_ETM4x_REG, read_sysreg_s, and finally to __mrs_s where it
      is string-ified and used directly in inline asm.
      
      Regardless of which compiler or compiler options determine whether a
      loop can or can't be unrolled, which determines whether
      __builtin_constant_p evaluates to true when passed an expression using a
      loop induction variable, it is NEVER safe to allow the preprocessor to
      construct inline asm like:
        asm volatile (".inst (0x160 + (i * 4))" : "=r"(__val));
                                       ^ expected constant expression
      
      Instead of read_etm4x_sysreg_offset() using __builtin_constant_p(), use
      __is_constexpr from include/linux/const.h instead to ensure only
      expressions that are valid integer constant expressions get passed
      through to read_sysreg_s().
      
      This is not a bug in clang; it's a potentially unsafe use of the macro
      arguments in read_etm4x_sysreg_offset dependent on __builtin_constant_p.
      
      Link: https://github.com/ClangBuiltLinux/linux/issues/1310Reported-by: default avatarArnd Bergmann <arnd@kernel.org>
      Reported-by: default avatarTao Zhang <quic_taozha@quicinc.com>
      Signed-off-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
      Link: https://lore.kernel.org/r/20220708231520.3958391-1-ndesaulniers@google.com
      4d45bc82
  2. 06 Jul, 2022 4 commits
  3. 30 Jun, 2022 1 commit
  4. 29 Jun, 2022 5 commits
  5. 22 Jun, 2022 1 commit
    • Suzuki K Poulose's avatar
      coresight: Clear the connection field properly · 2af89eba
      Suzuki K Poulose authored
      coresight devices track their connections (output connections) and
      hold a reference to the fwnode. When a device goes away, we walk through
      the devices on the coresight bus and make sure that the references
      are dropped. This happens both ways:
       a) For all output connections from the device, drop the reference to
          the target device via coresight_release_platform_data()
      
      b) Iterate over all the devices on the coresight bus and drop the
         reference to fwnode if *this* device is the target of the output
         connection, via coresight_remove_conns()->coresight_remove_match().
      
      However, the coresight_remove_match() doesn't clear the fwnode field,
      after dropping the reference, this causes use-after-free and
      additional refcount drops on the fwnode.
      
      e.g., if we have two devices, A and B, with a connection, A -> B.
      If we remove B first, B would clear the reference on B, from A
      via coresight_remove_match(). But when A is removed, it still has
      a connection with fwnode still pointing to B. Thus it tries to  drops
      the reference in coresight_release_platform_data(), raising the bells
      like :
      
      [   91.990153] ------------[ cut here ]------------
      [   91.990163] refcount_t: addition on 0; use-after-free.
      [   91.990212] WARNING: CPU: 0 PID: 461 at lib/refcount.c:25 refcount_warn_saturate+0xa0/0x144
      [   91.990260] Modules linked in: coresight_funnel coresight_replicator coresight_etm4x(-)
       crct10dif_ce coresight ip_tables x_tables ipv6 [last unloaded: coresight_cpu_debug]
      [   91.990398] CPU: 0 PID: 461 Comm: rmmod Tainted: G        W       T 5.19.0-rc2+ #53
      [   91.990418] Hardware name: ARM LTD ARM Juno Development Platform/ARM Juno Development Platform, BIOS EDK II Feb  1 2019
      [   91.990434] pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
      [   91.990454] pc : refcount_warn_saturate+0xa0/0x144
      [   91.990476] lr : refcount_warn_saturate+0xa0/0x144
      [   91.990496] sp : ffff80000c843640
      [   91.990509] x29: ffff80000c843640 x28: ffff800009957c28 x27: ffff80000c8439a8
      [   91.990560] x26: ffff00097eff1990 x25: ffff8000092b6ad8 x24: ffff00097eff19a8
      [   91.990610] x23: ffff80000c8439a8 x22: 0000000000000000 x21: ffff80000c8439c2
      [   91.990659] x20: 0000000000000000 x19: ffff00097eff1a10 x18: ffff80000ab99c40
      [   91.990708] x17: 0000000000000000 x16: 0000000000000000 x15: ffff80000abf6fa0
      [   91.990756] x14: 000000000000001d x13: 0a2e656572662d72 x12: 657466612d657375
      [   91.990805] x11: 203b30206e6f206e x10: 6f69746964646120 x9 : ffff8000081aba28
      [   91.990854] x8 : 206e6f206e6f6974 x7 : 69646461203a745f x6 : 746e756f63666572
      [   91.990903] x5 : ffff00097648ec58 x4 : 0000000000000000 x3 : 0000000000000027
      [   91.990952] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff00080260ba00
      [   91.991000] Call trace:
      [   91.991012]  refcount_warn_saturate+0xa0/0x144
      [   91.991034]  kobject_get+0xac/0xb0
      [   91.991055]  of_node_get+0x2c/0x40
      [   91.991076]  of_fwnode_get+0x40/0x60
      [   91.991094]  fwnode_handle_get+0x3c/0x60
      [   91.991116]  fwnode_get_nth_parent+0xf4/0x110
      [   91.991137]  fwnode_full_name_string+0x48/0xc0
      [   91.991158]  device_node_string+0x41c/0x530
      [   91.991178]  pointer+0x320/0x3ec
      [   91.991198]  vsnprintf+0x23c/0x750
      [   91.991217]  vprintk_store+0x104/0x4b0
      [   91.991238]  vprintk_emit+0x8c/0x360
      [   91.991257]  vprintk_default+0x44/0x50
      [   91.991276]  vprintk+0xcc/0xf0
      [   91.991295]  _printk+0x68/0x90
      [   91.991315]  of_node_release+0x13c/0x14c
      [   91.991334]  kobject_put+0x98/0x114
      [   91.991354]  of_node_put+0x24/0x34
      [   91.991372]  of_fwnode_put+0x40/0x5c
      [   91.991390]  fwnode_handle_put+0x38/0x50
      [   91.991411]  coresight_release_platform_data+0x74/0xb0 [coresight]
      [   91.991472]  coresight_unregister+0x64/0xcc [coresight]
      [   91.991525]  etm4_remove_dev+0x64/0x78 [coresight_etm4x]
      [   91.991563]  etm4_remove_amba+0x1c/0x2c [coresight_etm4x]
      [   91.991598]  amba_remove+0x3c/0x19c
      
      Reproducible by: (Build all coresight components as modules):
      
        #!/bin/sh
        while true
        do
           for m in tmc stm cpu_debug etm4x replicator funnel
           do
           	modprobe coresight_${m}
           done
      
           for m in tmc stm cpu_debug etm4x replicator funnel
           do
           	rmmode coresight_${m}
           done
        done
      
      Cc: stable@vger.kernel.org
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
      Fixes: 37ea1ffd ("coresight: Use fwnode handle instead of device names")
      Link: https://lore.kernel.org/r/20220614214024.3005275-1-suzuki.poulose@arm.comSigned-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      2af89eba
  6. 19 Jun, 2022 11 commits
    • Linus Torvalds's avatar
      Linux 5.19-rc3 · a111daf0
      Linus Torvalds authored
      a111daf0
    • Linus Torvalds's avatar
      Merge tag 'x86-urgent-2022-06-19' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 05c6ca85
      Linus Torvalds authored
      Pull x86 fixes from Thomas Gleixner:
      
       - Make RESERVE_BRK() work again with older binutils. The recent
         'simplification' broke that.
      
       - Make early #VE handling increment RIP when successful.
      
       - Make the #VE code consistent vs. the RIP adjustments and add
         comments.
      
       - Handle load_unaligned_zeropad() across page boundaries correctly in
         #VE when the second page is shared.
      
      * tag 'x86-urgent-2022-06-19' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        x86/tdx: Handle load_unaligned_zeropad() page-cross to a shared page
        x86/tdx: Clarify RIP adjustments in #VE handler
        x86/tdx: Fix early #VE handling
        x86/mm: Fix RESERVE_BRK() for older binutils
      05c6ca85
    • Linus Torvalds's avatar
      Merge tag 'objtool-urgent-2022-06-19' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 5d770f11
      Linus Torvalds authored
      Pull build tooling updates from Thomas Gleixner:
      
       - Remove obsolete CONFIG_X86_SMAP reference from objtool
      
       - Fix overlapping text section failures in faddr2line for real
      
       - Remove OBJECT_FILES_NON_STANDARD usage from x86 ftrace and replace it
         with finegrained annotations so objtool can validate that code
         correctly.
      
      * tag 'objtool-urgent-2022-06-19' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        x86/ftrace: Remove OBJECT_FILES_NON_STANDARD usage
        faddr2line: Fix overlapping text section failures, the sequel
        objtool: Fix obsolete reference to CONFIG_X86_SMAP
      5d770f11
    • Linus Torvalds's avatar
      Merge tag 'sched-urgent-2022-06-19' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 727c3991
      Linus Torvalds authored
      Pull scheduler fix from Thomas Gleixner:
       "A single scheduler fix plugging a race between sched_setscheduler()
        and balance_push().
      
        sched_setscheduler() spliced the balance callbacks accross a lock
        break which makes it possible for an interleaving schedule() to
        observe an empty list"
      
      * tag 'sched-urgent-2022-06-19' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        sched: Fix balance_push() vs __sched_setscheduler()
      727c3991
    • Linus Torvalds's avatar
      Merge tag 'locking-urgent-2022-06-19' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 4afb6515
      Linus Torvalds authored
      Pull lockdep fix from Thomas Gleixner:
       "A RT fix for lockdep.
      
        lockdep invokes prandom_u32() to create cookies. This worked until
        prandom_u32() was switched to the real random generator, which takes a
        spinlock for extraction, which does not work on RT when invoked from
        atomic contexts.
      
        lockdep has no requirement for real random numbers and it turns out
        sched_clock() is good enough to create the cookie. That works
        everywhere and is faster"
      
      * tag 'locking-urgent-2022-06-19' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        locking/lockdep: Use sched_clock() for random numbers
      4afb6515
    • Linus Torvalds's avatar
      Merge tag 'irq-urgent-2022-06-19' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 36da9f5f
      Linus Torvalds authored
      Pull irq fixes from Thomas Gleixner:
       "A set of interrupt subsystem updates:
      
        Core:
      
         - Ensure runtime power management for chained interrupts
      
        Drivers:
      
         - A collection of OF node refcount fixes
      
         - Unbreak MIPS uniprocessor builds
      
         - Fix xilinx interrupt controller Kconfig dependencies
      
         - Add a missing compatible string to the Uniphier driver"
      
      * tag 'irq-urgent-2022-06-19' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        irqchip/loongson-liointc: Use architecture register to get coreid
        irqchip/uniphier-aidet: Add compatible string for NX1 SoC
        dt-bindings: interrupt-controller/uniphier-aidet: Add bindings for NX1 SoC
        irqchip/realtek-rtl: Fix refcount leak in map_interrupts
        irqchip/gic-v3: Fix refcount leak in gic_populate_ppi_partitions
        irqchip/gic-v3: Fix error handling in gic_populate_ppi_partitions
        irqchip/apple-aic: Fix refcount leak in aic_of_ic_init
        irqchip/apple-aic: Fix refcount leak in build_fiq_affinity
        irqchip/gic/realview: Fix refcount leak in realview_gic_of_init
        irqchip/xilinx: Remove microblaze+zynq dependency
        genirq: PM: Use runtime PM for chained interrupts
      36da9f5f
    • Linus Torvalds's avatar
      Merge tag 'char-misc-5.19-rc3-take2' of... · bc94632c
      Linus Torvalds authored
      Merge tag 'char-misc-5.19-rc3-take2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
      
      Pull char/misc driver fixes for real from Greg KH:
       "Let's tag the proper branch this time...
      
        Here are some small char/misc driver fixes for 5.19-rc3 that resolve
        some reported issues.
      
        They include:
      
         - mei driver fixes
      
         - comedi driver fix
      
         - rtsx build warning fix
      
         - fsl-mc-bus driver fix
      
        All of these have been in linux-next for a while with no reported
        issues"
      
      This is what the merge in commit f0ec9c65 _should_ have merged, but
      Greg fat-fingered the pull request and I got some small changes from
      linux-next instead there. Credit to Nathan Chancellor for eagle-eyes.
      
      Link: https://lore.kernel.org/all/Yqywy+Md2AfGDu8v@dev-arch.thelio-3990X/
      
      * tag 'char-misc-5.19-rc3-take2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc:
        bus: fsl-mc-bus: fix KASAN use-after-free in fsl_mc_bus_remove()
        mei: me: add raptor lake point S DID
        mei: hbm: drop capability response on early shutdown
        mei: me: set internal pg flag to off on hardware reset
        misc: rtsx: Fix clang -Wsometimes-uninitialized in rts5261_init_from_hw()
        comedi: vmk80xx: fix expression for tx buffer size
      bc94632c
    • Linus Torvalds's avatar
      Merge tag 'i2c-for-5.19-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux · ee4eb6ee
      Linus Torvalds authored
      Pull i2c fixes from Wolfram Sang:
       "MAINTAINERS rectifications and a few minor driver fixes"
      
      * tag 'i2c-for-5.19-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
        i2c: mediatek: Fix an error handling path in mtk_i2c_probe()
        i2c: designware: Use standard optional ref clock implementation
        MAINTAINERS: core DT include belongs to core
        MAINTAINERS: add include/dt-bindings/i2c to I2C SUBSYSTEM HOST DRIVERS
        i2c: npcm7xx: Add check for platform_driver_register
        MAINTAINERS: Update Synopsys DesignWare I2C to Supported
      ee4eb6ee
    • Linus Torvalds's avatar
      Merge tag 'xfs-5.19-fixes-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux · 063232b6
      Linus Torvalds authored
      Pull xfs fixes from Darrick Wong:
       "There's not a whole lot this time around (I'm still on vacation) but
        here are some important fixes for new features merged in -rc1:
      
         - Fix a bug where inode flag changes would accidentally drop nrext64
      
         - Fix a race condition when toggling LARP mode"
      
      * tag 'xfs-5.19-fixes-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
        xfs: preserve DIFLAG2_NREXT64 when setting other inode attributes
        xfs: fix variable state usage
        xfs: fix TOCTOU race involving the new logged xattrs control knob
      063232b6
    • Linus Torvalds's avatar
      Merge tag 'ext4_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4 · 354c6e07
      Linus Torvalds authored
      Pull ext4 fixes from Ted Ts'o:
       "Fix a variety of bugs, many of which were found by folks using fuzzing
        or error injection.
      
        Also fix up how test_dummy_encryption mount option is handled for the
        new mount API.
      
        Finally, fix/cleanup a number of comments and ext4 Documentation
        files"
      
      * tag 'ext4_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4:
        ext4: fix a doubled word "need" in a comment
        ext4: add reserved GDT blocks check
        ext4: make variable "count" signed
        ext4: correct the judgment of BUG in ext4_mb_normalize_request
        ext4: fix bug_on ext4_mb_use_inode_pa
        ext4: fix up test_dummy_encryption handling for new mount API
        ext4: use kmemdup() to replace kmalloc + memcpy
        ext4: fix super block checksum incorrect after mount
        ext4: improve write performance with disabled delalloc
        ext4: fix warning when submitting superblock in ext4_commit_super()
        ext4, doc: remove unnecessary escaping
        ext4: fix incorrect comment in ext4_bio_write_page()
        fs: fix jbd2_journal_try_to_free_buffers() kernel-doc comment
      354c6e07
    • Linus Torvalds's avatar
      Merge tag '5.19-rc2-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6 · ace2045e
      Linus Torvalds authored
      Pull cifs client fixes from Steve French:
       "Two cifs debugging improvements - one found to deal with debugging a
        multichannel problem and one for a recent fallocate issue
      
        This does include the two larger multichannel reconnect (dynamically
        adjusting interfaces on reconnect) patches, because we recently found
        an additional problem with multichannel to one server type that I want
        to include at the same time"
      
      * tag '5.19-rc2-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6:
        cifs: when a channel is not found for server, log its connection id
        smb3: add trace point for SMB2_set_eof
      ace2045e
  7. 18 Jun, 2022 9 commits
  8. 17 Jun, 2022 8 commits