1. 11 Jul, 2022 5 commits
    • Helge Deller's avatar
      modules: Ensure natural alignment for .altinstructions and __bug_table sections · 87c482bd
      Helge Deller authored
      In the kernel image vmlinux.lds.S linker scripts the .altinstructions
      and __bug_table sections are 4- or 8-byte aligned because they hold 32-
      and/or 64-bit values.
      
      Most architectures use altinstructions and BUG() or WARN() in modules as
      well, but in the module linker script (module.lds.S) those sections are
      currently missing. As consequence the linker will store their content
      byte-aligned by default, which then can lead to unnecessary unaligned
      memory accesses by the CPU when those tables are processed at runtime.
      
      Usually unaligned memory accesses are unnoticed, because either the
      hardware (as on x86 CPUs) or in-kernel exception handlers (e.g. on
      parisc or sparc) emulate and fix them up at runtime. Nevertheless, such
      unaligned accesses introduce a performance penalty and can even crash
      the kernel if there is a bug in the unalignment exception handlers
      (which happened once to me on the parisc architecture and which is why I
      noticed that issue at all).
      
      This patch fixes a non-critical issue and might be backported at any time.
      It's trivial and shouldn't introduce any regression because it simply
      tells the linker to use a different (8-byte alignment) for those
      sections by default.
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Link: https://lore.kernel.org/all/Yr8%2Fgr8e8I7tVX4d@p100/Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      87c482bd
    • Christophe Leroy's avatar
      module: Increase readability of module_kallsyms_lookup_name() · 07ade45a
      Christophe Leroy authored
      module_kallsyms_lookup_name() has several exit conditions but
      can't return immediately due to preempt_disable().
      
      Refactor module_kallsyms_lookup_name() to allow returning from
      anywhere, and reduce depth.
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      07ade45a
    • Christophe Leroy's avatar
      module: Fix ERRORs reported by checkpatch.pl · ecc726f1
      Christophe Leroy authored
      Checkpatch reports following errors:
      
      ERROR: do not use assignment in if condition
      +	if ((colon = strnchr(name, MODULE_NAME_LEN, ':')) != NULL) {
      
      ERROR: do not use assignment in if condition
      +		if ((mod = find_module_all(name, colon - name, false)) != NULL)
      
      ERROR: do not use assignment in if condition
      +			if ((ret = find_kallsyms_symbol_value(mod, name)) != 0)
      
      ERROR: do not initialise globals to 0
      +int modules_disabled = 0;
      
      Fix them.
      
      The following one has to remain, because the condition has to be evaluated
      multiple times by the macro wait_event_interruptible_timeout().
      
      ERROR: do not use assignment in if condition
      +	if (wait_event_interruptible_timeout(module_wq,
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      ecc726f1
    • Saravana Kannan's avatar
      module: Add support for default value for module async_probe · ae39e9ed
      Saravana Kannan authored
      Add a module.async_probe kernel command line option that allows enabling
      async probing for all modules. When this command line option is used,
      there might still be some modules for which we want to explicitly force
      synchronous probing, so extend <modulename>.async_probe to take an
      optional bool input so that async probing can be disabled for a specific
      module.
      Signed-off-by: default avatarSaravana Kannan <saravanak@google.com>
      Reviewed-by: default avatarAaron Tomlin <atomlin@redhat.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      ae39e9ed
    • Aaron Tomlin's avatar
      module: kallsyms: Ensure preemption in add_kallsyms() with PREEMPT_RT · e69a6614
      Aaron Tomlin authored
      The commit 08126db5 ("module: kallsyms: Fix suspicious rcu usage")
      under PREEMPT_RT=y, disabling preemption introduced an unbounded
      latency since the loop is not fixed. This change caused a regression
      since previously preemption was not disabled and we would dereference
      RCU-protected pointers explicitly. That being said, these pointers
      cannot change.
      
      Before kallsyms-specific data is prepared/or set-up, we ensure that
      the unformed module is known to be unique i.e. does not already exist
      (see load_module()). Therefore, we can fix this by using the common and
      more appropriate RCU flavour as this section of code can be safely
      preempted.
      Reported-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Fixes: 08126db5 ("module: kallsyms: Fix suspicious rcu usage")
      Signed-off-by: default avatarAaron Tomlin <atomlin@redhat.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      e69a6614
  2. 01 Jul, 2022 4 commits
    • Masahiro Yamada's avatar
      doc: module: update file references · 2cc39179
      Masahiro Yamada authored
      Adjust documents to the file moves made by commit cfc1d277 ("module:
      Move all into module/").
      
      Thanks to Yanteng Si for helping me to update
      Documentation/translations/zh_CN/core-api/kernel-api.rst
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Acked-by: default avatarYanteng Si <siyanteng@loongson.cn>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      2cc39179
    • Christophe Leroy's avatar
      module: Fix "warning: variable 'exit' set but not used" · f963ef12
      Christophe Leroy authored
      When CONFIG_MODULE_UNLOAD is not selected, 'exit' is
      set but never used.
      
      It is not possible to replace the #ifdef CONFIG_MODULE_UNLOAD by
      IS_ENABLED(CONFIG_MODULE_UNLOAD) because mod->exit doesn't exist
      when CONFIG_MODULE_UNLOAD is not selected.
      
      And because of the rcu_read_lock_sched() section it is not easy
      to regroup everything in a single #ifdef. Let's regroup partially
      and add missing #ifdef to completely opt out the use of
      'exit' when CONFIG_MODULE_UNLOAD is not selected.
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      f963ef12
    • Christophe Leroy's avatar
      module: Fix selfAssignment cppcheck warning · cfa94c53
      Christophe Leroy authored
      cppcheck reports the following warnings:
      
      kernel/module/main.c:1455:26: warning: Redundant assignment of 'mod->core_layout.size' to itself. [selfAssignment]
         mod->core_layout.size = strict_align(mod->core_layout.size);
                               ^
      kernel/module/main.c:1489:26: warning: Redundant assignment of 'mod->init_layout.size' to itself. [selfAssignment]
         mod->init_layout.size = strict_align(mod->init_layout.size);
                               ^
      kernel/module/main.c:1493:26: warning: Redundant assignment of 'mod->init_layout.size' to itself. [selfAssignment]
         mod->init_layout.size = strict_align(mod->init_layout.size);
                               ^
      kernel/module/main.c:1504:26: warning: Redundant assignment of 'mod->init_layout.size' to itself. [selfAssignment]
         mod->init_layout.size = strict_align(mod->init_layout.size);
                               ^
      kernel/module/main.c:1459:26: warning: Redundant assignment of 'mod->data_layout.size' to itself. [selfAssignment]
         mod->data_layout.size = strict_align(mod->data_layout.size);
                               ^
      kernel/module/main.c:1463:26: warning: Redundant assignment of 'mod->data_layout.size' to itself. [selfAssignment]
         mod->data_layout.size = strict_align(mod->data_layout.size);
                               ^
      kernel/module/main.c:1467:26: warning: Redundant assignment of 'mod->data_layout.size' to itself. [selfAssignment]
         mod->data_layout.size = strict_align(mod->data_layout.size);
                               ^
      
      This is due to strict_align() being a no-op when
      CONFIG_STRICT_MODULE_RWX is not selected.
      
      Transform strict_align() macro into an inline function. It will
      allow type checking and avoid the selfAssignment warning.
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      cfa94c53
    • Adrian Hunter's avatar
      modules: Fix corruption of /proc/kallsyms · 35adf9a4
      Adrian Hunter authored
      The commit 91fb02f3 ("module: Move kallsyms support into a separate
      file") changed from using strlcpy() to using strscpy() which created a
      buffer overflow. That happened because:
       1) an incorrect value was passed as the buffer length
       2) strscpy() (unlike strlcpy()) may copy beyond the length of the
          input string when copying word-by-word.
      The assumption was that because it was already known that the strings
      being copied would fit in the space available, it was not necessary
      to correctly set the buffer length.  strscpy() breaks that assumption
      because although it will not touch bytes beyond the given buffer length
      it may write bytes beyond the input string length when writing
      word-by-word.
      
      The result of the buffer overflow is to corrupt the symbol type
      information that follows. e.g.
      
       $ sudo cat -v /proc/kallsyms | grep '\^' | head
       ffffffffc0615000 ^@ rfcomm_session_get  [rfcomm]
       ffffffffc061c060 ^@ session_list        [rfcomm]
       ffffffffc06150d0 ^@ rfcomm_send_frame   [rfcomm]
       ffffffffc0615130 ^@ rfcomm_make_uih     [rfcomm]
       ffffffffc07ed58d ^@ bnep_exit   [bnep]
       ffffffffc07ec000 ^@ bnep_rx_control     [bnep]
       ffffffffc07ec1a0 ^@ bnep_session        [bnep]
       ffffffffc07e7000 ^@ input_leds_event    [input_leds]
       ffffffffc07e9000 ^@ input_leds_handler  [input_leds]
       ffffffffc07e7010 ^@ input_leds_disconnect       [input_leds]
      
      Notably, the null bytes (represented above by ^@) can confuse tools.
      
      Fix by correcting the buffer length.
      
      Fixes: 91fb02f3 ("module: Move kallsyms support into a separate file")
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      35adf9a4
  3. 30 Jun, 2022 3 commits
  4. 29 Jun, 2022 2 commits
    • Linus Torvalds's avatar
      Merge tag 'platform-drivers-x86-v5.19-3' of... · d9b2ba67
      Linus Torvalds authored
      Merge tag 'platform-drivers-x86-v5.19-3' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86
      
      Pull x86 platform driver fixes from Hans de Goede:
      
       - thinkpad_acpi/ideapad-laptop: mem-leak and platform-profile fixes
      
       - panasonic-laptop: missing hotkey presses regression fix
      
       - some hardware-id additions
      
       - some other small fixes
      
      * tag 'platform-drivers-x86-v5.19-3' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86:
        platform/x86: hp-wmi: Ignore Sanitization Mode event
        platform/x86: thinkpad_acpi: do not use PSC mode on Intel platforms
        platform/x86: thinkpad-acpi: profile capabilities as integer
        platform/x86: panasonic-laptop: filter out duplicate volume up/down/mute keypresses
        platform/x86: panasonic-laptop: don't report duplicate brightness key-presses
        platform/x86: panasonic-laptop: revert "Resolve hotkey double trigger bug"
        platform/x86: panasonic-laptop: sort includes alphabetically
        platform/x86: panasonic-laptop: de-obfuscate button codes
        ACPI: video: Change how we determine if brightness key-presses are handled
        platform/x86: ideapad-laptop: Add Ideapad 5 15ITL05 to ideapad_dytc_v4_allow_table[]
        platform/x86: ideapad-laptop: Add allow_v4_dytc module parameter
        platform/x86: thinkpad_acpi: Fix a memory leak of EFCH MMIO resource
        platform/mellanox: nvsw-sn2201: fix error code in nvsw_sn2201_create_static_devices()
        platform/x86: intel/pmc: Add Alder Lake N support to PMC core driver
      d9b2ba67
    • Linus Torvalds's avatar
      Merge tag '5.19-rc4-ksmbd-server-fixes' of git://git.samba.org/ksmbd · 732f3069
      Linus Torvalds authored
      Pull ksmbd server fixes from Steve French:
      
       - seek null check (don't use f_seek op directly and blindly)
      
       - offset validation in FSCTL_SET_ZERO_DATA
      
       - fallocate fix (relates e.g. to xfstests generic/091 and 263)
      
       - two cleanup fixes
      
       - fix socket settings on some arch
      
      * tag '5.19-rc4-ksmbd-server-fixes' of git://git.samba.org/ksmbd:
        ksmbd: use vfs_llseek instead of dereferencing NULL
        ksmbd: check invalid FileOffset and BeyondFinalZero in FSCTL_ZERO_DATA
        ksmbd: set the range of bytes to zero without extending file size in FSCTL_ZERO_DATA
        ksmbd: remove duplicate flag set in smb2_write
        ksmbd: smbd: Remove useless license text when SPDX-License-Identifier is already used
        ksmbd: use SOCK_NONBLOCK type for kernel_accept()
      732f3069
  5. 28 Jun, 2022 11 commits
  6. 27 Jun, 2022 13 commits
  7. 26 Jun, 2022 2 commits
    • Linus Torvalds's avatar
      Linux 5.19-rc4 · 03c765b0
      Linus Torvalds authored
      03c765b0
    • Linus Torvalds's avatar
      Merge tag 'soc-fixes-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc · 1709b887
      Linus Torvalds authored
      Pull ARM SoC fixes from Arnd Bergmann:
       "A number of fixes have accumulated, but they are largely for harmless
        issues:
      
         - Several OF node leak fixes
      
         - A fix to the Exynos7885 UART clock description
      
         - DTS fixes to prevent boot failures on TI AM64 and J721s2
      
         - Bus probe error handling fixes for Baikal-T1
      
         - A fixup to the way STM32 SoCs use separate dts files for different
           firmware stacks
      
         - Multiple code fixes for Arm SCMI firmware, all dealing with
           robustness of the implementation
      
         - Multiple NXP i.MX devicetree fixes, addressing incorrect data in DT
           nodes
      
         - Three updates to the MAINTAINERS file, including Florian Fainelli
           taking over BCM283x/BCM2711 (Raspberry Pi) from Nicolas Saenz
           Julienne"
      
      * tag 'soc-fixes-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc: (29 commits)
        ARM: dts: aspeed: nuvia: rename vendor nuvia to qcom
        arm: mach-spear: Add missing of_node_put() in time.c
        ARM: cns3xxx: Fix refcount leak in cns3xxx_init
        MAINTAINERS: Update email address
        arm64: dts: ti: k3-am64-main: Remove support for HS400 speed mode
        arm64: dts: ti: k3-j721s2: Fix overlapping GICD memory region
        ARM: dts: bcm2711-rpi-400: Fix GPIO line names
        bus: bt1-axi: Don't print error on -EPROBE_DEFER
        bus: bt1-apb: Don't print error on -EPROBE_DEFER
        ARM: Fix refcount leak in axxia_boot_secondary
        ARM: dts: stm32: move SCMI related nodes in a dedicated file for stm32mp15
        soc: imx: imx8m-blk-ctrl: fix display clock for LCDIF2 power domain
        ARM: dts: imx6qdl-colibri: Fix capacitive touch reset polarity
        ARM: dts: imx6qdl: correct PU regulator ramp delay
        firmware: arm_scmi: Fix incorrect error propagation in scmi_voltage_descriptors_get
        firmware: arm_scmi: Avoid using extended string-buffers sizes if not necessary
        firmware: arm_scmi: Fix SENSOR_AXIS_NAME_GET behaviour when unsupported
        ARM: dts: imx7: Move hsic_phy power domain to HSIC PHY node
        soc: bcm: brcmstb: pm: pm-arm: Fix refcount leak in brcmstb_pm_probe
        MAINTAINERS: Update BCM2711/BCM2835 maintainer
        ...
      1709b887