1. 22 Apr, 2022 4 commits
    • Josh Poimboeuf's avatar
      libsubcmd: Fix OPTION_GROUP sorting · aa3d60e0
      Josh Poimboeuf authored
      The OPTION_GROUP option type is a way of grouping certain options
      together in the printed usage text.  It happens to be completely broken,
      thanks to the fact that the subcmd option sorting just sorts everything,
      without regard for grouping.  Luckily, nobody uses this option anyway,
      though that will change shortly.
      
      Fix it by sorting each group individually.
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: default avatarMiroslav Benes <mbenes@suse.cz>
      Link: https://lkml.kernel.org/r/e167ea3a11e2a9800eb062c1fd0f13e9cd05140c.1650300597.git.jpoimboe@redhat.com
      aa3d60e0
    • Peter Zijlstra's avatar
      Merge branch 'tip/x86/urgent' · 3398b12d
      Peter Zijlstra authored
      Merge the x86/urgent objtool/IBT changes as a base
      Signed-off-by: default avatarPeter Zijlstra <peterz@infradead.org>
      3398b12d
    • Peter Zijlstra's avatar
      objtool: Fix code relocs vs weak symbols · 4abff6d4
      Peter Zijlstra authored
      Occasionally objtool driven code patching (think .static_call_sites
      .retpoline_sites etc..) goes sideways and it tries to patch an
      instruction that doesn't match.
      
      Much head-scatching and cursing later the problem is as outlined below
      and affects every section that objtool generates for us, very much
      including the ORC data. The below uses .static_call_sites because it's
      convenient for demonstration purposes, but as mentioned the ORC
      sections, .retpoline_sites and __mount_loc are all similarly affected.
      
      Consider:
      
      foo-weak.c:
      
        extern void __SCT__foo(void);
      
        __attribute__((weak)) void foo(void)
        {
      	  return __SCT__foo();
        }
      
      foo.c:
      
        extern void __SCT__foo(void);
        extern void my_foo(void);
      
        void foo(void)
        {
      	  my_foo();
      	  return __SCT__foo();
        }
      
      These generate the obvious code
      (gcc -O2 -fcf-protection=none -fno-asynchronous-unwind-tables -c foo*.c):
      
      foo-weak.o:
      0000000000000000 <foo>:
         0:   e9 00 00 00 00          jmpq   5 <foo+0x5>      1: R_X86_64_PLT32       __SCT__foo-0x4
      
      foo.o:
      0000000000000000 <foo>:
         0:   48 83 ec 08             sub    $0x8,%rsp
         4:   e8 00 00 00 00          callq  9 <foo+0x9>      5: R_X86_64_PLT32       my_foo-0x4
         9:   48 83 c4 08             add    $0x8,%rsp
         d:   e9 00 00 00 00          jmpq   12 <foo+0x12>    e: R_X86_64_PLT32       __SCT__foo-0x4
      
      Now, when we link these two files together, you get something like
      (ld -r -o foos.o foo-weak.o foo.o):
      
      foos.o:
      0000000000000000 <foo-0x10>:
         0:   e9 00 00 00 00          jmpq   5 <foo-0xb>      1: R_X86_64_PLT32       __SCT__foo-0x4
         5:   66 2e 0f 1f 84 00 00 00 00 00   nopw   %cs:0x0(%rax,%rax,1)
         f:   90                      nop
      
      0000000000000010 <foo>:
        10:   48 83 ec 08             sub    $0x8,%rsp
        14:   e8 00 00 00 00          callq  19 <foo+0x9>     15: R_X86_64_PLT32      my_foo-0x4
        19:   48 83 c4 08             add    $0x8,%rsp
        1d:   e9 00 00 00 00          jmpq   22 <foo+0x12>    1e: R_X86_64_PLT32      __SCT__foo-0x4
      
      Noting that ld preserves the weak function text, but strips the symbol
      off of it (hence objdump doing that funny negative offset thing). This
      does lead to 'interesting' unused code issues with objtool when ran on
      linked objects, but that seems to be working (fingers crossed).
      
      So far so good.. Now lets consider the objtool static_call output
      section (readelf output, old binutils):
      
      foo-weak.o:
      
      Relocation section '.rela.static_call_sites' at offset 0x2c8 contains 1 entry:
          Offset             Info             Type               Symbol's Value  Symbol's Name + Addend
      0000000000000000  0000000200000002 R_X86_64_PC32          0000000000000000 .text + 0
      0000000000000004  0000000d00000002 R_X86_64_PC32          0000000000000000 __SCT__foo + 1
      
      foo.o:
      
      Relocation section '.rela.static_call_sites' at offset 0x310 contains 2 entries:
          Offset             Info             Type               Symbol's Value  Symbol's Name + Addend
      0000000000000000  0000000200000002 R_X86_64_PC32          0000000000000000 .text + d
      0000000000000004  0000000d00000002 R_X86_64_PC32          0000000000000000 __SCT__foo + 1
      
      foos.o:
      
      Relocation section '.rela.static_call_sites' at offset 0x430 contains 4 entries:
          Offset             Info             Type               Symbol's Value  Symbol's Name + Addend
      0000000000000000  0000000100000002 R_X86_64_PC32          0000000000000000 .text + 0
      0000000000000004  0000000d00000002 R_X86_64_PC32          0000000000000000 __SCT__foo + 1
      0000000000000008  0000000100000002 R_X86_64_PC32          0000000000000000 .text + 1d
      000000000000000c  0000000d00000002 R_X86_64_PC32          0000000000000000 __SCT__foo + 1
      
      So we have two patch sites, one in the dead code of the weak foo and one
      in the real foo. All is well.
      
      *HOWEVER*, when the toolchain strips unused section symbols it
      generates things like this (using new enough binutils):
      
      foo-weak.o:
      
      Relocation section '.rela.static_call_sites' at offset 0x2c8 contains 1 entry:
          Offset             Info             Type               Symbol's Value  Symbol's Name + Addend
      0000000000000000  0000000200000002 R_X86_64_PC32          0000000000000000 foo + 0
      0000000000000004  0000000d00000002 R_X86_64_PC32          0000000000000000 __SCT__foo + 1
      
      foo.o:
      
      Relocation section '.rela.static_call_sites' at offset 0x310 contains 2 entries:
          Offset             Info             Type               Symbol's Value  Symbol's Name + Addend
      0000000000000000  0000000200000002 R_X86_64_PC32          0000000000000000 foo + d
      0000000000000004  0000000d00000002 R_X86_64_PC32          0000000000000000 __SCT__foo + 1
      
      foos.o:
      
      Relocation section '.rela.static_call_sites' at offset 0x430 contains 4 entries:
          Offset             Info             Type               Symbol's Value  Symbol's Name + Addend
      0000000000000000  0000000100000002 R_X86_64_PC32          0000000000000000 foo + 0
      0000000000000004  0000000d00000002 R_X86_64_PC32          0000000000000000 __SCT__foo + 1
      0000000000000008  0000000100000002 R_X86_64_PC32          0000000000000000 foo + d
      000000000000000c  0000000d00000002 R_X86_64_PC32          0000000000000000 __SCT__foo + 1
      
      And now we can see how that foos.o .static_call_sites goes side-ways, we
      now have _two_ patch sites in foo. One for the weak symbol at foo+0
      (which is no longer a static_call site!) and one at foo+d which is in
      fact the right location.
      
      This seems to happen when objtool cannot find a section symbol, in which
      case it falls back to any other symbol to key off of, however in this
      case that goes terribly wrong!
      
      As such, teach objtool to create a section symbol when there isn't
      one.
      
      Fixes: 44f6a7c0 ("objtool: Fix seg fault with Clang non-section symbols")
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Link: https://lkml.kernel.org/r/20220419203807.655552918@infradead.org
      4abff6d4
    • Peter Zijlstra's avatar
      objtool: Fix type of reloc::addend · c087c6e7
      Peter Zijlstra authored
      Elf{32,64}_Rela::r_addend is of type: Elf{32,64}_Sword, that means
      that our reloc::addend needs to be long or face tuncation issues when
      we do elf_rebuild_reloc_section():
      
        - 107:  48 b8 00 00 00 00 00 00 00 00   movabs $0x0,%rax        109: R_X86_64_64        level4_kernel_pgt+0x80000067
        + 107:  48 b8 00 00 00 00 00 00 00 00   movabs $0x0,%rax        109: R_X86_64_64        level4_kernel_pgt-0x7fffff99
      
      Fixes: 627fce14 ("objtool: Add ORC unwind table generation")
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Link: https://lkml.kernel.org/r/20220419203807.596871927@infradead.org
      c087c6e7
  2. 19 Apr, 2022 20 commits
  3. 17 Apr, 2022 10 commits
  4. 16 Apr, 2022 6 commits
    • Linus Torvalds's avatar
      Merge tag 'soc-fixes-5.18-2' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc · 70a0cec8
      Linus Torvalds authored
      Pull ARM SoC fixes from Arnd Bergmann:
       "There are a number of SoC bugfixes that came in since the merge
        window, and more of them are already pending.
      
        This batch includes:
      
         - A boot time regression fix for davinci that triggered on
           multi_v5_defconfig when booting any platform
      
         - Defconfig updates to address removed features, changed symbol names
           or dependencies, for gemini, ux500, and pxa
      
         - Email address changes for Krzysztof Kozlowski
      
         - Build warning fixes for ep93xx and iop32x
      
         - Devicetree warning fixes across many platforms
      
         - Minor bugfixes for the reset controller, memory controller and SCMI
           firmware subsystems plus the versatile-express board"
      
      * tag 'soc-fixes-5.18-2' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc: (34 commits)
        ARM: config: Update Gemini defconfig
        arm64: dts: qcom/sdm845-shift-axolotl: Fix boolean properties with values
        ARM: dts: align SPI NOR node name with dtschema
        ARM: dts: Fix more boolean properties with values
        arm/arm64: dts: qcom: Fix boolean properties with values
        arm64: dts: imx: Fix imx8*-var-som touchscreen property sizes
        arm: dts: imx: Fix boolean properties with values
        arm64: dts: tegra: Fix boolean properties with values
        arm: dts: at91: Fix boolean properties with values
        arm: configs: imote2: Drop defconfig as board support dropped.
        ep93xx: clock: Don't use plain integer as NULL pointer
        ep93xx: clock: Fix UAF in ep93xx_clk_register_gate()
        ARM: vexpress/spc: Fix all the kernel-doc build warnings
        ARM: vexpress/spc: Fix kernel-doc build warning for ve_spc_cpu_in_wfi
        ARM: config: u8500: Re-enable AB8500 battery charging
        ARM: config: u8500: Add some common hardware
        memory: fsl_ifc: populate child nodes of buses and mfd devices
        ARM: config: Refresh U8500 defconfig
        firmware: arm_scmi: Fix sparse warnings in OPTEE transport driver
        firmware: arm_scmi: Replace zero-length array with flexible-array member
        ...
      70a0cec8
    • Linus Torvalds's avatar
      Merge tag 'random-5.18-rc3-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/crng/random · 92edbe32
      Linus Torvalds authored
      Pull random number generator fixes from Jason Donenfeld:
      
       - Per your suggestion, random reads now won't fail if there's a page
         fault after some non-zero amount of data has been read, which makes
         the behavior consistent with all other reads in the kernel.
      
       - Rather than an inconsistent mix of random_get_entropy() returning an
         unsigned long or a cycles_t, now it just returns an unsigned long.
      
       - A memcpy() was replaced with an memmove(), because the addresses are
         sometimes overlapping. In practice the destination is always before
         the source, so not really an issue, but better to be correct than
         not.
      
      * tag 'random-5.18-rc3-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/crng/random:
        random: use memmove instead of memcpy for remaining 32 bytes
        random: make random_get_entropy() return an unsigned long
        random: allow partial reads if later user copies fail
      92edbe32
    • Linus Torvalds's avatar
      Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi · 90ea17a9
      Linus Torvalds authored
      Pull SCSI fixes from James Bottomley:
       "13 fixes, all in drivers.
      
        The most extensive changes are in the iscsi series (affecting drivers
        qedi, cxgbi and bnx2i), the next most is scsi_debug, but that's just a
        simple revert and then minor updates to pm80xx"
      
      * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
        scsi: iscsi: MAINTAINERS: Add Mike Christie as co-maintainer
        scsi: qedi: Fix failed disconnect handling
        scsi: iscsi: Fix NOP handling during conn recovery
        scsi: iscsi: Merge suspend fields
        scsi: iscsi: Fix unbound endpoint error handling
        scsi: iscsi: Fix conn cleanup and stop race during iscsid restart
        scsi: iscsi: Fix endpoint reuse regression
        scsi: iscsi: Release endpoint ID when its freed
        scsi: iscsi: Fix offload conn cleanup when iscsid restarts
        scsi: iscsi: Move iscsi_ep_disconnect()
        scsi: pm80xx: Enable upper inbound, outbound queues
        scsi: pm80xx: Mask and unmask upper interrupt vectors 32-63
        Revert "scsi: scsi_debug: Address races following module load"
      90ea17a9
    • Bartosz Golaszewski's avatar
      Merge tag 'intel-gpio-v5.18-2' of... · 0ebb4fbe
      Bartosz Golaszewski authored
      Merge tag 'intel-gpio-v5.18-2' of gitolite.kernel.org:pub/scm/linux/kernel/git/andy/linux-gpio-intel into gpio/for-current
      
      intel-gpio for v5.18-2
      
      * Couple of fixes related to handling unsigned value of the pin from ACPI
      
      gpiolib:
       -  acpi: Convert type for pin to be unsigned
       -  acpi: use correct format characters
      0ebb4fbe
    • Linus Torvalds's avatar
      Merge tag 'dma-mapping-5.18-2' of git://git.infradead.org/users/hch/dma-mapping · b0086839
      Linus Torvalds authored
      Pull dma-mapping fix from Christoph Hellwig:
      
       - avoid a double memory copy for swiotlb (Chao Gao)
      
      * tag 'dma-mapping-5.18-2' of git://git.infradead.org/users/hch/dma-mapping:
        dma-direct: avoid redundant memory sync for swiotlb
      b0086839
    • Jason A. Donenfeld's avatar
      random: use memmove instead of memcpy for remaining 32 bytes · 35a33ff3
      Jason A. Donenfeld authored
      In order to immediately overwrite the old key on the stack, before
      servicing a userspace request for bytes, we use the remaining 32 bytes
      of block 0 as the key. This means moving indices 8,9,a,b,c,d,e,f ->
      4,5,6,7,8,9,a,b. Since 4 < 8, for the kernel implementations of
      memcpy(), this doesn't actually appear to be a problem in practice. But
      relying on that characteristic seems a bit brittle. So let's change that
      to a proper memmove(), which is the by-the-books way of handling
      overlapping memory copies.
      Reviewed-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      35a33ff3