1. 30 Aug, 2024 14 commits
    • Christophe Leroy's avatar
      selftests: vDSO: use parse_vdso.h in vdso_test_abi · f0d0dbbc
      Christophe Leroy authored
      Don't duplicate parse_vdso function prototypes, include
      the header instead.
      
      Fixes: 693f5ca0 ("kselftest: Extend vDSO selftest")
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Acked-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      f0d0dbbc
    • Christophe Leroy's avatar
      selftests: vDSO: fix the way vDSO functions are called for powerpc · 6eda706a
      Christophe Leroy authored
      vdso_test_correctness test fails on powerpc:
      
      ~ # ./vdso_test_correctness
      ...
      [RUN]	Testing clock_gettime for clock CLOCK_REALTIME_ALARM (8)...
      [FAIL]	No such clock, but __vdso_clock_gettime returned 22
      [RUN]	Testing clock_gettime for clock CLOCK_BOOTTIME_ALARM (9)...
      [FAIL]	No such clock, but __vdso_clock_gettime returned 22
      [RUN]	Testing clock_gettime for clock CLOCK_SGI_CYCLE (10)...
      [FAIL]	No such clock, but __vdso_clock_gettime returned 22
      ...
      [RUN]	Testing clock_gettime for clock invalid (-1)...
      [FAIL]	No such clock, but __vdso_clock_gettime returned 22
      [RUN]	Testing clock_gettime for clock invalid (-2147483648)...
      [FAIL]	No such clock, but __vdso_clock_gettime returned 22
      [RUN]	Testing clock_gettime for clock invalid (2147483647)...
      [FAIL]	No such clock, but __vdso_clock_gettime returned 22
      
      On powerpc, a call to a VDSO function is not an ordinary C function
      call. Unlike several architectures which returns a negative error code
      in case of an error, powerpc sets CR[SO] and returns the error code
      as a positive value.
      
      Define and use a macro called VDSO_CALL() which takes a pointer
      to the function to call, the number of arguments and the arguments.
      
      Also update ABI vdso documentation to reflect this subtlety.
      
      Provide a specific version of VDSO_CALL() for powerpc that negates
      the error code on return when CR[SO] is set.
      
      Fixes: c7e5789b ("kselftest: Move test_vdso to the vDSO test suite")
      Fixes: 2e9a9725 ("selftests: vdso: Add a selftest for vDSO getcpu()")
      Fixes: 693f5ca0 ("kselftest: Extend vDSO selftest")
      Fixes: b2f1c3db ("kselftest: Extend vdso correctness test to clock_gettime64")
      Fixes: 4920a259 ("selftests/vDSO: add tests for vgetrandom")
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Acked-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      6eda706a
    • Christophe Leroy's avatar
      selftests: vDSO: fix vDSO symbols lookup for powerpc64 · ba83b323
      Christophe Leroy authored
      On powerpc64, following tests fail locating vDSO functions:
      
        ~ # ./vdso_test_abi
        TAP version 13
        1..16
        # [vDSO kselftest] VDSO_VERSION: LINUX_2.6.15
        # Couldn't find __kernel_gettimeofday
        ok 1 # SKIP __kernel_gettimeofday
        # clock_id: CLOCK_REALTIME
        # Couldn't find __kernel_clock_gettime
        ok 2 # SKIP __kernel_clock_gettime CLOCK_REALTIME
        # Couldn't find __kernel_clock_getres
        ok 3 # SKIP __kernel_clock_getres CLOCK_REALTIME
        ...
        # Couldn't find __kernel_time
        ok 16 # SKIP __kernel_time
        # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:16 error:0
      
        ~ # ./vdso_test_getrandom
        __kernel_getrandom is missing!
      
        ~ # ./vdso_test_gettimeofday
        Could not find __kernel_gettimeofday
      
        ~ # ./vdso_test_getcpu
        Could not find __kernel_getcpu
      
      On powerpc64, as shown below by readelf, vDSO functions symbols have
      type NOTYPE, so also accept that type when looking for symbols.
      
      $ powerpc64-linux-gnu-readelf -a arch/powerpc/kernel/vdso/vdso64.so.dbg
      ELF Header:
        Magic:   7f 45 4c 46 02 02 01 00 00 00 00 00 00 00 00 00
        Class:                             ELF64
        Data:                              2's complement, big endian
        Version:                           1 (current)
        OS/ABI:                            UNIX - System V
        ABI Version:                       0
        Type:                              DYN (Shared object file)
        Machine:                           PowerPC64
        Version:                           0x1
      ...
      
      Symbol table '.dynsym' contains 12 entries:
         Num:    Value          Size Type    Bind   Vis      Ndx Name
           0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
           1: 0000000000000524    84 NOTYPE  GLOBAL DEFAULT    8 __[...]@@LINUX_2.6.15
           2: 00000000000005f0    36 NOTYPE  GLOBAL DEFAULT    8 __[...]@@LINUX_2.6.15
           3: 0000000000000578    68 NOTYPE  GLOBAL DEFAULT    8 __[...]@@LINUX_2.6.15
           4: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  ABS LINUX_2.6.15
           5: 00000000000006c0    48 NOTYPE  GLOBAL DEFAULT    8 __[...]@@LINUX_2.6.15
           6: 0000000000000614   172 NOTYPE  GLOBAL DEFAULT    8 __[...]@@LINUX_2.6.15
           7: 00000000000006f0    84 NOTYPE  GLOBAL DEFAULT    8 __[...]@@LINUX_2.6.15
           8: 000000000000047c    84 NOTYPE  GLOBAL DEFAULT    8 __[...]@@LINUX_2.6.15
           9: 0000000000000454    12 NOTYPE  GLOBAL DEFAULT    8 __[...]@@LINUX_2.6.15
          10: 00000000000004d0    84 NOTYPE  GLOBAL DEFAULT    8 __[...]@@LINUX_2.6.15
          11: 00000000000005bc    52 NOTYPE  GLOBAL DEFAULT    8 __[...]@@LINUX_2.6.15
      
      Symbol table '.symtab' contains 56 entries:
         Num:    Value          Size Type    Bind   Vis      Ndx Name
      ...
          45: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  ABS LINUX_2.6.15
          46: 00000000000006c0    48 NOTYPE  GLOBAL DEFAULT    8 __kernel_getcpu
          47: 0000000000000524    84 NOTYPE  GLOBAL DEFAULT    8 __kernel_clock_getres
          48: 00000000000005f0    36 NOTYPE  GLOBAL DEFAULT    8 __kernel_get_tbfreq
          49: 000000000000047c    84 NOTYPE  GLOBAL DEFAULT    8 __kernel_gettimeofday
          50: 0000000000000614   172 NOTYPE  GLOBAL DEFAULT    8 __kernel_sync_dicache
          51: 00000000000006f0    84 NOTYPE  GLOBAL DEFAULT    8 __kernel_getrandom
          52: 0000000000000454    12 NOTYPE  GLOBAL DEFAULT    8 __kernel_sigtram[...]
          53: 0000000000000578    68 NOTYPE  GLOBAL DEFAULT    8 __kernel_time
          54: 00000000000004d0    84 NOTYPE  GLOBAL DEFAULT    8 __kernel_clock_g[...]
          55: 00000000000005bc    52 NOTYPE  GLOBAL DEFAULT    8 __kernel_get_sys[...]
      
      Fixes: 98eedc3a ("Document the vDSO and add a reference parser")
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Acked-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      ba83b323
    • Christophe Leroy's avatar
      selftests: vDSO: fix vdso_config for powerpc · 7d297c41
      Christophe Leroy authored
      Running vdso_test_correctness on powerpc64 gives the following warning:
      
        ~ # ./vdso_test_correctness
        Warning: failed to find clock_gettime64 in vDSO
      
      This is because vdso_test_correctness was built with VDSO_32BIT defined.
      
      __powerpc__ macro is defined on both powerpc32 and powerpc64 so
      __powerpc64__ needs to be checked first in vdso_config.h
      
      Fixes: 693f5ca0 ("kselftest: Extend vDSO selftest")
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Acked-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      7d297c41
    • Christophe Leroy's avatar
      selftests: vDSO: fix vDSO name for powerpc · 59eb856c
      Christophe Leroy authored
      Following error occurs when running vdso_test_correctness on powerpc:
      
      ~ # ./vdso_test_correctness
      [WARN]	failed to find vDSO
      [SKIP]	No vDSO, so skipping clock_gettime() tests
      [SKIP]	No vDSO, so skipping clock_gettime64() tests
      [RUN]	Testing getcpu...
      [OK]	CPU 0: syscall: cpu 0, node 0
      
      On powerpc, vDSO is neither called linux-vdso.so.1 nor linux-gate.so.1
      but linux-vdso32.so.1 or linux-vdso64.so.1.
      
      Also search those two names before giving up.
      
      Fixes: c7e5789b ("kselftest: Move test_vdso to the vDSO test suite")
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Acked-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      59eb856c
    • Jason A. Donenfeld's avatar
      selftests: vDSO: skip getrandom test if architecture is unsupported · f78280b1
      Jason A. Donenfeld authored
      If the getrandom test compiles for an arch, don't exit fatally if the
      actual cpu it's running on is unsupported.
      Suggested-by: default avatarAdhemerval Zanella Netto <adhemerval.zanella@linaro.org>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      f78280b1
    • Xi Ruoyao's avatar
      selftests: vDSO: use KHDR_INCLUDES for UAPI headers for getrandom test · b90eeff1
      Xi Ruoyao authored
      Building test_vdso_getrandom currently leads to following issue:
      
          In file included from /home/xry111/git-repos/linux/tools/include/linux/compiler_types.h:36,
                           from /home/xry111/git-repos/linux/include/uapi/linux/stddef.h:5,
                           from /home/xry111/git-repos/linux/include/uapi/linux/posix_types.h:5,
                           from /usr/include/asm/sigcontext.h:12,
                           from /usr/include/bits/sigcontext.h:30,
                           from /usr/include/signal.h:301,
                           from vdso_test_getrandom.c:14:
          /home/xry111/git-repos/linux/tools/include/linux/compiler-gcc.h:3:2: error: #error "Please don't include <linux/compiler-gcc.h> directly, include <linux/compiler.h> instead."
              3 | #error "Please don't include <linux/compiler-gcc.h> directly, include <linux/compiler.h> instead."
                |  ^~~~~
      
      It's because the compiler_types.h inclusion in
      include/uapi/linux/stddef.h is expected to be removed by the
      header_install.sh script, as compiler_types.h shouldn't be used from
      user space.
      
      Add KHDR_INCLUDES before the existing include/uapi inclusion so that
      usr/include takes precedence if it's populated.
      Signed-off-by: default avatarXi Ruoyao <xry111@xry111.site>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      b90eeff1
    • Jason A. Donenfeld's avatar
      selftests: vDSO: remove unnecessary command line defs from chacha test · be915515
      Jason A. Donenfeld authored
      CONFIG_FUNCTION_ALIGNMENT=0 is no longer necessary and BULID_VDSO wasn't
      spelled right while BUILD_VDSO isn't necessary, so just remove these.
      Reported-by: default avatarAdhemerval Zanella Netto <adhemerval.zanella@linaro.org>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      be915515
    • Jason A. Donenfeld's avatar
      selftests: vDSO: separate LDLIBS from CFLAGS for libsodium · a5330eb3
      Jason A. Donenfeld authored
      On systems that set -Wl,--as-needed, putting the -lsodium in the wrong
      place on the command line means we get a linker error:
      
            CC       vdso_test_chacha
          /usr/bin/ld: /tmp/ccKpjnSM.o: in function `main':
          vdso_test_chacha.c:(.text+0x276): undefined reference to `crypto_stream_chacha20'
          collect2: error: ld returned 1 exit status
      
      Fix this by passing pkg-config's --libs output to the LDFLAGS field
      instead of the CFLAGS field, as is customary.
      Reported-by: default avatarAdhemerval Zanella Netto <adhemerval.zanella@linaro.org>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      a5330eb3
    • Xi Ruoyao's avatar
      selftests: vDSO: add --cflags for pkg-config command querying libsodium · 1e661b34
      Xi Ruoyao authored
      When libsodium is installed into its own prefix, the --cflags output is
      needed for the compiler to find libsodium headers.
      Signed-off-by: default avatarXi Ruoyao <xry111@xry111.site>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      1e661b34
    • Christophe Leroy's avatar
      selftests: vDSO: look for arch-specific function name in getrandom test · e1bbcab4
      Christophe Leroy authored
      Don't hard-code x86 specific names. Rather, use vdso_config definitions
      to find the correct function matching the architecture.
      
      Add random VDSO function names in names[][]. Remove the #ifdef
      CONFIG_VDSO32, as having the name there all the time is harmless and
      guaranties a steady index for following strings.
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      [Jason: add [6] to variable declaration rather than each usage site.]
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      e1bbcab4
    • Christophe Leroy's avatar
      selftests: vDSO: fix include order in build of test_vdso_chacha · f8d92fc5
      Christophe Leroy authored
      Building test_vdso_chacha currently leads to following issue:
      
        In file included from /home/chleroy/linux-powerpc/include/linux/limits.h:7,
                         from /opt/powerpc64-e5500--glibc--stable-2024.02-1/powerpc64-buildroot-linux-gnu/sysroot/usr/include/bits/local_lim.h:38,
                         from /opt/powerpc64-e5500--glibc--stable-2024.02-1/powerpc64-buildroot-linux-gnu/sysroot/usr/include/bits/posix1_lim.h:161,
                         from /opt/powerpc64-e5500--glibc--stable-2024.02-1/powerpc64-buildroot-linux-gnu/sysroot/usr/include/limits.h:195,
                         from /opt/powerpc64-e5500--glibc--stable-2024.02-1/lib/gcc/powerpc64-buildroot-linux-gnu/12.3.0/include-fixed/limits.h:203,
                         from /opt/powerpc64-e5500--glibc--stable-2024.02-1/lib/gcc/powerpc64-buildroot-linux-gnu/12.3.0/include-fixed/syslimits.h:7,
                         from /opt/powerpc64-e5500--glibc--stable-2024.02-1/lib/gcc/powerpc64-buildroot-linux-gnu/12.3.0/include-fixed/limits.h:34,
                         from /tmp/sodium/usr/local/include/sodium/export.h:7,
                         from /tmp/sodium/usr/local/include/sodium/crypto_stream_chacha20.h:14,
                         from vdso_test_chacha.c:6:
        /opt/powerpc64-e5500--glibc--stable-2024.02-1/powerpc64-buildroot-linux-gnu/sysroot/usr/include/bits/xopen_lim.h:99:6: error: missing binary operator before token "("
           99 | # if INT_MAX == 32767
              |      ^~~~~~~
        /opt/powerpc64-e5500--glibc--stable-2024.02-1/powerpc64-buildroot-linux-gnu/sysroot/usr/include/bits/xopen_lim.h:102:7: error: missing binary operator before token "("
          102 | #  if INT_MAX == 2147483647
              |       ^~~~~~~
        /opt/powerpc64-e5500--glibc--stable-2024.02-1/powerpc64-buildroot-linux-gnu/sysroot/usr/include/bits/xopen_lim.h:126:6: error: missing binary operator before token "("
          126 | # if LONG_MAX == 2147483647
              |      ^~~~~~~~
      
      This is due to kernel include/linux/limits.h being included instead of
      libc's limits.h.
      
      This is because directory include/ is added through option -isystem so
      it goes prior to glibc's include directory.
      
      Replace -isystem by -idirafter.
      
      But this implies that now tools/include/linux/linkage.h is included
      instead of include/linux/linkage.h, so define a stub for
      SYM_FUNC_START() and SYM_FUNC_END().
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      f8d92fc5
    • Christophe Leroy's avatar
      selftests: vDSO: don't hard-code location of vDSO sources · 20a9af05
      Christophe Leroy authored
      Architectures use different location for vDSO sources:
      
      	arch/mips/vdso
      	arch/sparc/vdso
      	arch/arm64/kernel/vdso
      	arch/riscv/kernel/vdso
      	arch/csky/kernel/vdso
      	arch/x86/um/vdso
      	arch/x86/entry/vdso
      	arch/powerpc/kernel/vdso
      	arch/arm/vdso
      	arch/loongarch/vdso
      
      Don't hard-code vdso sources location in selftest Makefile. Instead
      create a vdso/ symbolic link in tools/arch/$arch/ and update Makefile
      accordingly.
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      20a9af05
    • Jason A. Donenfeld's avatar
      selftests: vDSO: simplify getrandom thread local storage and structs · 01b52f01
      Jason A. Donenfeld authored
      Rather than using pthread_get/set_specific, just use gcc's __thread
      annotation, which is noticeably faster and makes the code more obvious.
      
      Also, just have one simplified struct called vgrnd, instead of trying to
      split things up semantically. Those divisions were useful when this code
      was split across several commit *messages*, but doesn't make as much
      sense within a single file. This should make the code more clear and
      provide a better example for implementers.
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      01b52f01
  2. 29 Aug, 2024 1 commit
    • Linus Torvalds's avatar
      Merge tag 'random-6.11-rc6-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/crng/random · d5d547aa
      Linus Torvalds authored
      Pull random number generator fix from Jason Donenfeld:
       "Reject invalid flags passed to vgetrandom() in the same way that
        getrandom() does, so that the behavior is the same, from Yann.
      
        The flags argument to getrandom() only has a behavioral effect on the
        function if the RNG isn't initialized yet, so vgetrandom() falls back
        to the syscall in that case. But if the RNG is initialized, all of the
        flags behave the same way, so vgetrandom() didn't bother checking
        them, and just ignored them entirely.
      
        But that doesn't account for invalid flags passed in, which need to be
        rejected so we can use them later"
      
      * tag 'random-6.11-rc6-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/crng/random:
        random: vDSO: reject unknown getrandom() flags
      d5d547aa
  3. 28 Aug, 2024 6 commits
  4. 27 Aug, 2024 6 commits
    • Linus Torvalds's avatar
      Merge tag 'livepatching-for-6.11-rc6' of... · 3ec3f5fc
      Linus Torvalds authored
      Merge tag 'livepatching-for-6.11-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/livepatching/livepatching
      
      Pull livepatching fix from Petr Mladek:
       "Selftest regression fix"
      
      * tag 'livepatching-for-6.11-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/livepatching/livepatching:
        selftests/livepatch: wait for atomic replace to occur
      3ec3f5fc
    • Linus Torvalds's avatar
      Merge tag 'pinctrl-v6.11-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl · 41594663
      Linus Torvalds authored
      Pull pin control fixes from Linus Walleij:
      
       - Fix the hwirq map and pin offsets in the Qualcomm X1E80100 driver
      
       - Fix the pin range handling in the AT91 driver so it works again
      
       - Fix a NULL-dereference risk in pinctrl single
      
       - Fix a serious biasing bug in the Mediatek driver
      
       - Fix the level trigged IRQ in the StarFive JH7110
      
       - Fix the iomux width in the Rockchip GPIO2-B pin handling
      
      * tag 'pinctrl-v6.11-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl:
        pinctrl: rockchip: correct RK3328 iomux width flag for GPIO2-B pins
        pinctrl: starfive: jh7110: Correct the level trigger configuration of iev register
        pinctrl: qcom: x1e80100: Fix special pin offsets
        pinctrl: mediatek: common-v2: Fix broken bias-disable for PULL_PU_PD_RSEL_TYPE
        pinctrl: single: fix potential NULL dereference in pcs_get_function()
        pinctrl: at91: make it work with current gpiolib
        pinctrl: qcom: x1e80100: Update PDC hwirq map
      41594663
    • Linus Torvalds's avatar
      Merge tag 'sound-6.11-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound · 6ace1c7e
      Linus Torvalds authored
      Pull sound fixes from Takashi Iwai:
       "It became a bit larger collection of fixes than wished at this time,
        but all changes are small and mostly device-specific fixes that should
        be fairly safe to apply.
      
        Majority of fixes are about ASoC for AMD SOF, Cirrus codecs, lpass,
        etc, in addition to the usual HD-audio quirks / fixes"
      
      * tag 'sound-6.11-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: (22 commits)
        ALSA: hda: hda_component: Fix mutex crash if nothing ever binds
        ALSA: hda/realtek: support HP Pavilion Aero 13-bg0xxx Mute LED
        ALSA: hda/realtek: Fix the speaker output on Samsung Galaxy Book3 Ultra
        ASoC: cs-amp-lib: Ignore empty UEFI calibration entries
        ASoC: cs-amp-lib-test: Force test calibration blob entries to be valid
        ALSA: hda/realtek - FIxed ALC285 headphone no sound
        ALSA: hda/realtek - Fixed ALC256 headphone no sound
        ASoC: allow module autoloading for table board_ids
        ASoC: allow module autoloading for table db1200_pids
        ALSA: hda: cs35l56: Don't use the device index as a calibration index
        ALSA: seq: Skip event type filtering for UMP events
        ALSA: hda/realtek: Enable mute/micmute LEDs on HP Laptop 14-ey0xxx
        ASoC: SOF: amd: Fix for acp init sequence
        ASoC: amd: acp: fix module autoloading
        ASoC: mediatek: mt8188: Mark AFE_DAC_CON0 register as volatile
        ASoC: codecs: wcd937x: Fix missing de-assert of reset GPIO
        ASoC: SOF: mediatek: Add missing board compatible
        ASoC: MAINTAINERS: Drop Banajit Goswami from Qualcomm sound drivers
        ASoC: SOF: amd: Fix for incorrect acp error register offsets
        ASoC: SOF: amd: move iram-dram fence register programming sequence
        ...
      6ace1c7e
    • Stefan Berger's avatar
      tpm: ibmvtpm: Call tpm2_sessions_init() to initialize session support · 08d08e2e
      Stefan Berger authored
      Commit d2add27c ("tpm: Add NULL primary creation") introduced
      CONFIG_TCG_TPM2_HMAC. When this option is enabled on ppc64 then the
      following message appears in the kernel log due to a missing call to
      tpm2_sessions_init().
      
      [    2.654549] tpm tpm0: auth session is not active
      
      Add the missing call to tpm2_session_init() to the ibmvtpm driver to
      resolve this issue.
      
      Cc: stable@vger.kernel.org # v6.10+
      Fixes: d2add27c ("tpm: Add NULL primary creation")
      Signed-off-by: default avatarStefan Berger <stefanb@linux.ibm.com>
      Reviewed-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
      Signed-off-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
      08d08e2e
    • Filipe Manana's avatar
      btrfs: fix uninitialized return value from btrfs_reclaim_sweep() · ecb54277
      Filipe Manana authored
      The return variable 'ret' at btrfs_reclaim_sweep() is never assigned if
      none of the space infos is reclaimable (for example if periodic reclaim
      is disabled, which is the default), so we return an undefined value.
      
      This can be fixed my making btrfs_reclaim_sweep() not return any value
      as well as do_reclaim_sweep() because:
      
      1) do_reclaim_sweep() always returns 0, so we can make it return void;
      
      2) The only caller of btrfs_reclaim_sweep() (btrfs_reclaim_bgs()) doesn't
         care about its return value, and in its context there's nothing to do
         about any errors anyway.
      
      Therefore remove the return value from btrfs_reclaim_sweep() and
      do_reclaim_sweep().
      
      Fixes: e4ca3932 ("btrfs: periodic block_group reclaim")
      Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
      Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      ecb54277
    • Linus Torvalds's avatar
      Merge tag 'vfs-6.11-rc6.fixes' of gitolite.kernel.org:pub/scm/linux/kernel/git/vfs/vfs · 3e9bff3b
      Linus Torvalds authored
      Pull vfs fixes from Christian Brauner:
       "VFS:
      
         - Ensure that backing files uses file->f_ops->splice_write() for
           splice
      
        netfs:
      
         - Revert the removal of PG_private_2 from netfs_release_folio() as
           cephfs still relies on this
      
         - When AS_RELEASE_ALWAYS is set on a mapping the folio needs to
           always be invalidated during truncation
      
         - Fix losing untruncated data in a folio by making letting
           netfs_release_folio() return false if the folio is dirty
      
         - Fix trimming of streaming-write folios in netfs_inval_folio()
      
         - Reset iterator before retrying a short read
      
         - Fix interaction of streaming writes with zero-point tracker
      
        afs:
      
         - During truncation afs currently calls truncate_setsize() which sets
           i_size, expands the pagecache and truncates it. The first two
           operations aren't needed because they will have already been done.
           So call truncate_pagecache() instead and skip the redundant parts
      
        overlayfs:
      
         - Fix checking of the number of allowed lower layers so 500 layers
           can actually be used instead of just 499
      
         - Add missing '\n' to pr_err() output
      
         - Pass string to ovl_parse_layer() and thus allow it to be used for
           Opt_lowerdir as well
      
        pidfd:
      
         - Revert blocking the creation of pidfds for kthread as apparently
           userspace relies on this. Specifically, it breaks systemd during
           shutdown
      
        romfs:
      
         - Fix romfs_read_folio() to use the correct offset with
           folio_zero_tail()"
      
      * tag 'vfs-6.11-rc6.fixes' of gitolite.kernel.org:pub/scm/linux/kernel/git/vfs/vfs:
        netfs: Fix interaction of streaming writes with zero-point tracker
        netfs: Fix missing iterator reset on retry of short read
        netfs: Fix trimming of streaming-write folios in netfs_inval_folio()
        netfs: Fix netfs_release_folio() to say no if folio dirty
        afs: Fix post-setattr file edit to do truncation correctly
        mm: Fix missing folio invalidation calls during truncation
        ovl: ovl_parse_param_lowerdir: Add missed '\n' for pr_err
        ovl: fix wrong lowerdir number check for parameter Opt_lowerdir
        ovl: pass string to ovl_parse_layer()
        backing-file: convert to using fops->splice_write
        Revert "pidfd: prevent creation of pidfds for kthreads"
        romfs: fix romfs_read_folio()
        netfs, ceph: Partially revert "netfs: Replace PG_fscache by setting folio->private and marking dirty"
      3e9bff3b
  5. 26 Aug, 2024 13 commits
    • Qu Wenruo's avatar
      btrfs: fix a use-after-free when hitting errors inside btrfs_submit_chunk() · 10d9d8c3
      Qu Wenruo authored
      [BUG]
      There is an internal report that KASAN is reporting use-after-free, with
      the following backtrace:
      
        BUG: KASAN: slab-use-after-free in btrfs_check_read_bio+0xa68/0xb70 [btrfs]
        Read of size 4 at addr ffff8881117cec28 by task kworker/u16:2/45
        CPU: 1 UID: 0 PID: 45 Comm: kworker/u16:2 Not tainted 6.11.0-rc2-next-20240805-default+ #76
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.2-3-gd478f380-rebuilt.opensuse.org 04/01/2014
        Workqueue: btrfs-endio btrfs_end_bio_work [btrfs]
        Call Trace:
         dump_stack_lvl+0x61/0x80
         print_address_description.constprop.0+0x5e/0x2f0
         print_report+0x118/0x216
         kasan_report+0x11d/0x1f0
         btrfs_check_read_bio+0xa68/0xb70 [btrfs]
         process_one_work+0xce0/0x12a0
         worker_thread+0x717/0x1250
         kthread+0x2e3/0x3c0
         ret_from_fork+0x2d/0x70
         ret_from_fork_asm+0x11/0x20
      
        Allocated by task 20917:
         kasan_save_stack+0x37/0x60
         kasan_save_track+0x10/0x30
         __kasan_slab_alloc+0x7d/0x80
         kmem_cache_alloc_noprof+0x16e/0x3e0
         mempool_alloc_noprof+0x12e/0x310
         bio_alloc_bioset+0x3f0/0x7a0
         btrfs_bio_alloc+0x2e/0x50 [btrfs]
         submit_extent_page+0x4d1/0xdb0 [btrfs]
         btrfs_do_readpage+0x8b4/0x12a0 [btrfs]
         btrfs_readahead+0x29a/0x430 [btrfs]
         read_pages+0x1a7/0xc60
         page_cache_ra_unbounded+0x2ad/0x560
         filemap_get_pages+0x629/0xa20
         filemap_read+0x335/0xbf0
         vfs_read+0x790/0xcb0
         ksys_read+0xfd/0x1d0
         do_syscall_64+0x6d/0x140
         entry_SYSCALL_64_after_hwframe+0x4b/0x53
      
        Freed by task 20917:
         kasan_save_stack+0x37/0x60
         kasan_save_track+0x10/0x30
         kasan_save_free_info+0x37/0x50
         __kasan_slab_free+0x4b/0x60
         kmem_cache_free+0x214/0x5d0
         bio_free+0xed/0x180
         end_bbio_data_read+0x1cc/0x580 [btrfs]
         btrfs_submit_chunk+0x98d/0x1880 [btrfs]
         btrfs_submit_bio+0x33/0x70 [btrfs]
         submit_one_bio+0xd4/0x130 [btrfs]
         submit_extent_page+0x3ea/0xdb0 [btrfs]
         btrfs_do_readpage+0x8b4/0x12a0 [btrfs]
         btrfs_readahead+0x29a/0x430 [btrfs]
         read_pages+0x1a7/0xc60
         page_cache_ra_unbounded+0x2ad/0x560
         filemap_get_pages+0x629/0xa20
         filemap_read+0x335/0xbf0
         vfs_read+0x790/0xcb0
         ksys_read+0xfd/0x1d0
         do_syscall_64+0x6d/0x140
         entry_SYSCALL_64_after_hwframe+0x4b/0x53
      
      [CAUSE]
      Although I cannot reproduce the error, the report itself is good enough
      to pin down the cause.
      
      The call trace is the regular endio workqueue context, but the
      free-by-task trace is showing that during btrfs_submit_chunk() we
      already hit a critical error, and is calling btrfs_bio_end_io() to error
      out.  And the original endio function called bio_put() to free the whole
      bio.
      
      This means a double freeing thus causing use-after-free, e.g.:
      
      1. Enter btrfs_submit_bio() with a read bio
         The read bio length is 128K, crossing two 64K stripes.
      
      2. The first run of btrfs_submit_chunk()
      
      2.1 Call btrfs_map_block(), which returns 64K
      2.2 Call btrfs_split_bio()
          Now there are two bios, one referring to the first 64K, the other
          referring to the second 64K.
      2.3 The first half is submitted.
      
      3. The second run of btrfs_submit_chunk()
      
      3.1 Call btrfs_map_block(), which by somehow failed
          Now we call btrfs_bio_end_io() to handle the error
      
      3.2 btrfs_bio_end_io() calls the original endio function
          Which is end_bbio_data_read(), and it calls bio_put() for the
          original bio.
      
          Now the original bio is freed.
      
      4. The submitted first 64K bio finished
         Now we call into btrfs_check_read_bio() and tries to advance the bio
         iter.
         But since the original bio (thus its iter) is already freed, we
         trigger the above use-after free.
      
         And even if the memory is not poisoned/corrupted, we will later call
         the original endio function, causing a double freeing.
      
      [FIX]
      Instead of calling btrfs_bio_end_io(), call btrfs_orig_bbio_end_io(),
      which has the extra check on split bios and do the proper refcounting
      for cloned bios.
      
      Furthermore there is already one extra btrfs_cleanup_bio() call, but
      that is duplicated to btrfs_orig_bbio_end_io() call, so remove that
      label completely.
      Reported-by: default avatarDavid Sterba <dsterba@suse.com>
      Fixes: 852eee62 ("btrfs: allow btrfs_submit_bio to split bios")
      CC: stable@vger.kernel.org # 6.6+
      Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
      Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      10d9d8c3
    • Jeff Layton's avatar
      fs/nfsd: fix update of inode attrs in CB_GETATTR · 7e8ae848
      Jeff Layton authored
      Currently, we copy the mtime and ctime to the in-core inode and then
      mark the inode dirty. This is fine for certain types of filesystems, but
      not all. Some require a real setattr to properly change these values
      (e.g. ceph or reexported NFS).
      
      Fix this code to call notify_change() instead, which is the proper way
      to effect a setattr. There is one problem though:
      
      In this case, the client is holding a write delegation and has sent us
      attributes to update our cache. We don't want to break the delegation
      for this since that would defeat the purpose. Add a new ATTR_DELEG flag
      that makes notify_change bypass the try_break_deleg call.
      
      Fixes: c5967721 ("NFSD: handle GETATTR conflict with write delegation")
      Reviewed-by: default avatarChristian Brauner <brauner@kernel.org>
      Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      7e8ae848
    • Jeff Layton's avatar
      nfsd: fix potential UAF in nfsd4_cb_getattr_release · 1116e0e3
      Jeff Layton authored
      Once we drop the delegation reference, the fields embedded in it are no
      longer safe to access. Do that last.
      
      Fixes: c5967721 ("NFSD: handle GETATTR conflict with write delegation")
      Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      1116e0e3
    • Jeff Layton's avatar
      nfsd: hold reference to delegation when updating it for cb_getattr · da05ba23
      Jeff Layton authored
      Once we've dropped the flc_lock, there is nothing that ensures that the
      delegation that was found will still be around later. Take a reference
      to it while holding the lock and then drop it when we've finished with
      the delegation.
      
      Fixes: c5967721 ("NFSD: handle GETATTR conflict with write delegation")
      Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      da05ba23
    • Chuck Lever's avatar
      f25d1b5f
    • Bibo Mao's avatar
      LoongArch: KVM: Invalidate guest steal time address on vCPU reset · 4956e07f
      Bibo Mao authored
      If ParaVirt steal time feature is enabled, there is a percpu gpa address
      passed from guest vCPU and host modifies guest memory space with this gpa
      address. When vCPU is reset normally, it will notify host and invalidate
      gpa address.
      
      However if VM is crashed and VMM reboots VM forcely, the vCPU reboot
      notification callback will not be called in VM. Host needs invalidate
      the gpa address, else host will modify guest memory during VM reboots.
      Here it is invalidated from the vCPU KVM_REG_LOONGARCH_VCPU_RESET ioctl
      interface.
      
      Also funciton kvm_reset_timer() is removed at vCPU reset stage, since SW
      emulated timer is only used in vCPU block state. When a vCPU is removed
      from the block waiting queue, kvm_restore_timer() is called and SW timer
      is cancelled. And the timer register is also cleared at VMM when a vCPU
      is reset.
      Signed-off-by: default avatarBibo Mao <maobibo@loongson.cn>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      4956e07f
    • Tiezhu Yang's avatar
      LoongArch: Add ifdefs to fix LSX and LASX related warnings · 80376323
      Tiezhu Yang authored
      There exist some warnings when building kernel if CONFIG_CPU_HAS_LBT is
      set but CONFIG_CPU_HAS_LSX and CONFIG_CPU_HAS_LASX are not set. In this
      case, there are no definitions of _restore_lsx & _restore_lasx and there
      are also no definitions of kvm_restore_lsx & kvm_restore_lasx in fpu.S
      and switch.S respectively, just add some ifdefs to fix these warnings.
      
        AS      arch/loongarch/kernel/fpu.o
      arch/loongarch/kernel/fpu.o: warning: objtool: unexpected relocation symbol type in .rela.discard.func_stack_frame_non_standard: 0
      arch/loongarch/kernel/fpu.o: warning: objtool: unexpected relocation symbol type in .rela.discard.func_stack_frame_non_standard: 0
      
        AS [M]  arch/loongarch/kvm/switch.o
      arch/loongarch/kvm/switch.o: warning: objtool: unexpected relocation symbol type in .rela.discard.func_stack_frame_non_standard: 0
      arch/loongarch/kvm/switch.o: warning: objtool: unexpected relocation symbol type in .rela.discard.func_stack_frame_non_standard: 0
      
        MODPOST Module.symvers
      ERROR: modpost: "kvm_restore_lsx" [arch/loongarch/kvm/kvm.ko] undefined!
      ERROR: modpost: "kvm_restore_lasx" [arch/loongarch/kvm/kvm.ko] undefined!
      
      Cc: stable@vger.kernel.org # 6.9+
      Fixes: cb8a2ef0 ("LoongArch: Add ORC stack unwinder support")
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Closes: https://lore.kernel.org/oe-kbuild-all/202408120955.qls5oNQY-lkp@intel.com/Signed-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      80376323
    • Huacai Chen's avatar
      LoongArch: Define ARCH_IRQ_INIT_FLAGS as IRQ_NOPROBE · 274ea356
      Huacai Chen authored
      Currently we call irq_set_noprobe() in a loop for all IRQs, but indeed
      it only works for IRQs below NR_IRQS_LEGACY because at init_IRQ() only
      legacy interrupts have been allocated.
      
      Instead, we can define ARCH_IRQ_INIT_FLAGS as IRQ_NOPROBE in asm/hwirq.h
      and the core will automatically set the flag for all interrupts.
      Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      Signed-off-by: default avatarTianyang Zhang <zhangtianyang@loongson.cn>
      274ea356
    • David Sterba's avatar
      btrfs: initialize last_extent_end to fix -Wmaybe-uninitialized warning in extent_fiemap() · 33f58a04
      David Sterba authored
      There's a warning (probably on some older compiler version):
      
      fs/btrfs/fiemap.c: warning: 'last_extent_end' may be used uninitialized in this function [-Wmaybe-uninitialized]:  => 822:19
      
      Initialize the variable to 0 although it's not necessary as it's either
      properly set or not used after an error. The called function is in the
      same file so this is a false alert but we want to fix all
      -Wmaybe-uninitialized reports.
      
      Link: https://lore.kernel.org/all/20240819070639.2558629-1-geert@linux-m68k.org/Reported-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      33f58a04
    • Ryan Sullivan's avatar
      selftests/livepatch: wait for atomic replace to occur · 052f3951
      Ryan Sullivan authored
      On some machines with a large number of CPUs there is a sizable delay
      between an atomic replace occurring and when sysfs updates accordingly.
      This fix uses 'loop_until' to wait for the atomic replace to unload all
      previous livepatches.
      Reported-by: default avatarCKI Project <cki-project@redhat.com>
      Closes: https://datawarehouse.cki-project.org/kcidb/tests/redhat:1413102084-x86_64-kernel_upt_28Signed-off-by: default avatarRyan Sullivan <rysulliv@redhat.com>
      Reviewed-by: default avatarPetr Mladek <pmladek@suse.com>
      Acked-by: default avatarJoe Lawrence <joe.lawrence@redhat.com>
      Link: https://lore.kernel.org/r/20240822173122.14760-1-rysulliv@redhat.comSigned-off-by: default avatarPetr Mladek <pmladek@suse.com>
      052f3951
    • Hans de Goede's avatar
      platform/x86: x86-android-tablets: Make Lenovo Yoga Tab 3 X90F DMI match less strict · a3379eca
      Hans de Goede authored
      There are 2G and 4G RAM versions of the Lenovo Yoga Tab 3 X90F and it
      turns out that the 2G version has a DMI product name of
      "CHERRYVIEW D1 PLATFORM" where as the 4G version has
      "CHERRYVIEW C0 PLATFORM". The sys-vendor + product-version check are
      unique enough that the product-name check is not necessary.
      
      Drop the product-name check so that the existing DMI match for the 4G
      RAM version also matches the 2G RAM version.
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Link: https://lore.kernel.org/r/20240825132415.8307-1-hdegoede@redhat.comReviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
      Signed-off-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
      a3379eca
    • Mathieu Fenniak's avatar
      platform/x86: asus-wmi: Fix spurious rfkill on UX8406MA · 9286dfd5
      Mathieu Fenniak authored
      The Asus Zenbook Duo (UX8406MA) has a keyboard which can be
      placed on the laptop to connect it via USB, or can be removed from the
      laptop to reveal a hidden secondary display in which case the keyboard
      operates via Bluetooth.
      
      When it is placed on the secondary display to connect via USB, it emits
      a keypress for a wireless disable. This causes the rfkill system to be
      activated disconnecting the current wifi connection, which doesn't
      reflect the user's true intention.
      
      Detect this hardware and suppress any wireless switches from the
      keyboard; this keyboard does not have a wireless toggle capability so
      these presses are always spurious.
      Signed-off-by: default avatarMathieu Fenniak <mathieu@fenniak.net>
      Reviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
      Link: https://lore.kernel.org/r/20240823135630.128447-1-mathieu@fenniak.netSigned-off-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
      9286dfd5
    • Richard Fitzgerald's avatar
      ALSA: hda: hda_component: Fix mutex crash if nothing ever binds · 28b329f4
      Richard Fitzgerald authored
      Move the initialization of parent->mutex into
      hda_component_manager_init() so that it is always valid.
      
      In hda_component_manager_bind() do not clear the parent information.
      Only zero-fill the per-component data ready for it to be filled in
      by the components as they bind.
      
      Previously parent->mutex was being initialized only in
      hda_component_manager_bind(). This meant that it was only
      initialized if all components appeared and there was a bind callback.
      If there wasn't a bind the mutex object was not valid when the
      Realtek driver called any of the other functions.
      Signed-off-by: default avatarRichard Fitzgerald <rf@opensource.cirrus.com>
      Fixes: 047b9cbb ("ALSA: hda: hda_component: Protect shared data with a mutex")
      Link: https://patch.msgid.link/20240826094940.45563-1-rf@opensource.cirrus.comSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      28b329f4