31 Aug, 2019

1 commit

  • Commit dfe2a77fd243 ("kfifo: fix kfifo_alloc() and kfifo_init()") made
    the kfifo code round the number of elements up. That was good for
    __kfifo_alloc(), but it's actually wrong for __kfifo_init().

    The difference? __kfifo_alloc() will allocate the rounded-up number of
    elements, but __kfifo_init() uses an allocation done by the caller. We
    can't just say "use more elements than the caller allocated", and have
    to round down.

    The good news? All the normal cases will be using power-of-two arrays
    anyway, and most users of kfifo's don't use kfifo_init() at all, but one
    of the helper macros to declare a KFIFO that enforce the proper
    power-of-two behavior. But it looks like at least ibmvscsis might be
    affected.

    The bad news? Will Deacon refers to an old thread and points points out
    that the memory ordering in kfifo's is questionable. See

    https://lore.kernel.org/lkml/20181211034032.32338-1-yuleixzhang@tencent.com/

    for more.

    Fixes: dfe2a77fd243 ("kfifo: fix kfifo_alloc() and kfifo_init()")
    Reported-by: laokz
    Cc: Stefani Seibold
    Cc: Andrew Morton
    Cc: Dan Carpenter
    Cc: Greg KH
    Cc: Kees Cook
    Cc: Will Deacon
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

29 Aug, 2019

1 commit

  • Hisilicon fixes for v5.3-rc

    - Fixed RCU usage in logical PIO
    - Added a function to unregister a logical PIO range in logical PIO
    to support the fixes in the hisi-lpc driver
    - Fixed and optimized hisi-lpc driver to avoid potential use-after-free
    and driver unbind crash

    * tag 'hisi-fixes-for-5.3' of git://github.com/hisilicon/linux-hisi:
    bus: hisi_lpc: Add .remove method to avoid driver unbind crash
    bus: hisi_lpc: Unregister logical PIO range to avoid potential use-after-free
    lib: logic_pio: Add logic_pio_unregister_range()
    lib: logic_pio: Avoid possible overlap for unregistering regions
    lib: logic_pio: Fix RCU usage

    Link: https://lore.kernel.org/r/5D562335.7000902@hisilicon.com
    Signed-off-by: Arnd Bergmann

    Arnd Bergmann
     

13 Aug, 2019

3 commits

  • Add a function to unregister a logical PIO range.

    Logical PIO space can still be leaked when unregistering certain
    LOGIC_PIO_CPU_MMIO regions, but this acceptable for now since there are no
    callers to unregister LOGIC_PIO_CPU_MMIO regions, and the logical PIO
    region allocation scheme would need significant work to improve this.

    Cc: stable@vger.kernel.org
    Signed-off-by: John Garry
    Signed-off-by: Wei Xu

    John Garry
     
  • The code was originally written to not support unregistering logical PIO
    regions.

    To accommodate supporting unregistering logical PIO regions, subtly modify
    LOGIC_PIO_CPU_MMIO region registration code, such that the "end" of the
    registered regions is the "end" of the last region, and not the sum of
    the sizes of all the registered regions.

    Cc: stable@vger.kernel.org
    Signed-off-by: John Garry
    Signed-off-by: Wei Xu

    John Garry
     
  • The traversing of io_range_list with list_for_each_entry_rcu()
    is not properly protected by rcu_read_lock() and rcu_read_unlock(),
    so add them.

    These functions mark the critical section scope where the list is
    protected for the reader, it cannot be "reclaimed". Any updater - in
    this case, the logical PIO registration functions - cannot update the
    list until the reader exits this critical section.

    In addition, the list traversing used in logic_pio_register_range()
    does not need to use the rcu variant.

    This is because we are already using io_range_mutex to guarantee mutual
    exclusion from mutating the list.

    Cc: stable@vger.kernel.org
    Fixes: 031e3601869c ("lib: Add generic PIO mapping method")
    Signed-off-by: John Garry
    Signed-off-by: Wei Xu

    John Garry
     

07 Aug, 2019

1 commit

  • Pull networking fixes from David Miller:
    "Yeah I should have sent a pull request last week, so there is a lot
    more here than usual:

    1) Fix memory leak in ebtables compat code, from Wenwen Wang.

    2) Several kTLS bug fixes from Jakub Kicinski (circular close on
    disconnect etc.)

    3) Force slave speed check on link state recovery in bonding 802.3ad
    mode, from Thomas Falcon.

    4) Clear RX descriptor bits before assigning buffers to them in
    stmmac, from Jose Abreu.

    5) Several missing of_node_put() calls, mostly wrt. for_each_*() OF
    loops, from Nishka Dasgupta.

    6) Double kfree_skb() in peak_usb can driver, from Stephane Grosjean.

    7) Need to hold sock across skb->destructor invocation, from Cong
    Wang.

    8) IP header length needs to be validated in ipip tunnel xmit, from
    Haishuang Yan.

    9) Use after free in ip6 tunnel driver, also from Haishuang Yan.

    10) Do not use MSI interrupts on r8169 chips before RTL8168d, from
    Heiner Kallweit.

    11) Upon bridge device init failure, we need to delete the local fdb.
    From Nikolay Aleksandrov.

    12) Handle erros from of_get_mac_address() properly in stmmac, from
    Martin Blumenstingl.

    13) Handle concurrent rename vs. dump in netfilter ipset, from Jozsef
    Kadlecsik.

    14) Setting NETIF_F_LLTX on mac80211 causes complete breakage with
    some devices, so revert. From Johannes Berg.

    15) Fix deadlock in rxrpc, from David Howells.

    16) Fix Kconfig deps of enetc driver, we must have PHYLIB. From Yue
    Haibing.

    17) Fix mvpp2 crash on module removal, from Matteo Croce.

    18) Fix race in genphy_update_link, from Heiner Kallweit.

    19) bpf_xdp_adjust_head() stopped working with generic XDP when we
    fixes generic XDP to support stacked devices properly, fix from
    Jesper Dangaard Brouer.

    20) Unbalanced RCU locking in rt6_update_exception_stamp_rt(), from
    David Ahern.

    21) Several memory leaks in new sja1105 driver, from Vladimir Oltean"

    * git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (214 commits)
    net: dsa: sja1105: Fix memory leak on meta state machine error path
    net: dsa: sja1105: Fix memory leak on meta state machine normal path
    net: dsa: sja1105: Really fix panic on unregistering PTP clock
    net: dsa: sja1105: Use the LOCKEDS bit for SJA1105 E/T as well
    net: dsa: sja1105: Fix broken learning with vlan_filtering disabled
    net: dsa: qca8k: Add of_node_put() in qca8k_setup_mdio_bus()
    net: sched: sample: allow accessing psample_group with rtnl
    net: sched: police: allow accessing police->params with rtnl
    net: hisilicon: Fix dma_map_single failed on arm64
    net: hisilicon: fix hip04-xmit never return TX_BUSY
    net: hisilicon: make hip04_tx_reclaim non-reentrant
    tc-testing: updated vlan action tests with batch create/delete
    net sched: update vlan action for batched events operations
    net: stmmac: tc: Do not return a fragment entry
    net: stmmac: Fix issues when number of Queues >= 4
    net: stmmac: xgmac: Fix XGMAC selftests
    be2net: disable bh with spin_lock in be_process_mcc
    net: cxgb3_main: Fix a resource leak in a error path in 'init_one()'
    net: ethernet: sun4i-emac: Support phy-handle property for finding PHYs
    net: bridge: move default pvid init/deinit to NETDEV_REGISTER/UNREGISTER
    ...

    Linus Torvalds
     

05 Aug, 2019

1 commit

  • …/masahiroy/linux-kbuild

    Pull Kbuild fixes from Masahiro Yamada:

    - detect missing missing "WITH Linux-syscall-note" for uapi headers

    - fix needless rebuild when using Clang

    - fix false-positive cc-option in Kconfig when using Clang

    - avoid including corrupted .*.cmd files in the modpost stage

    - fix warning of 'make vmlinux'

    - fix {m,n,x,g}config to not generate the broken .config on the second
    save operation.

    - some trivial Makefile fixes

    * tag 'kbuild-fixes-v5.3-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
    kconfig: Clear "written" flag to avoid data loss
    kbuild: Check for unknown options with cc-option usage in Kconfig and clang
    lib/raid6: fix unnecessary rebuild of vpermxor*.c
    kbuild: modpost: do not parse unnecessary rules for vmlinux modpost
    kbuild: modpost: remove unnecessary dependency for __modpost
    kbuild: modpost: handle KBUILD_EXTRA_SYMBOLS only for external modules
    kbuild: modpost: include .*.cmd files only when targets exist
    kbuild: initialize CLANG_FLAGS correctly in the top Makefile
    kbuild: detect missing "WITH Linux-syscall-note" for uapi headers

    Linus Torvalds
     

04 Aug, 2019

1 commit

  • Pull vdso timer fixes from Thomas Gleixner:
    "A series of commits to deal with the regression caused by the generic
    VDSO implementation.

    The usage of clock_gettime64() for 32bit compat fallback syscalls
    caused seccomp filters to kill innocent processes because they only
    allow clock_gettime().

    Handle the compat syscalls with clock_gettime() as before, which is
    not a functional problem for the VDSO as the legacy compat application
    interface is not y2038 safe anyway. It's just extra fallback code
    which needs to be implemented on every architecture.

    It's opt in for now so that it does not break the compile of already
    converted architectures in linux-next. Once these are fixed, the
    #ifdeffery goes away.

    So much for trying to be smart and reuse code..."

    * 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
    arm64: compat: vdso: Use legacy syscalls as fallback
    x86/vdso/32: Use 32bit syscall fallback
    lib/vdso/32: Provide legacy syscall fallbacks
    lib/vdso: Move fallback invocation to the callers
    lib/vdso/32: Remove inconsistent NULL pointer checks

    Linus Torvalds
     

03 Aug, 2019

3 commits

  • kmalloc() shouldn't sleep while in RCU critical section, therefore use
    GFP_ATOMIC instead of GFP_KERNEL.

    The bug was spotted by the 0day kernel testing robot.

    Link: http://lkml.kernel.org/r/20190725121703.210874-1-glider@google.com
    Fixes: 7e659650cbda ("lib: introduce test_meminit module")
    Signed-off-by: Alexander Potapenko
    Reviewed-by: Andrew Morton
    Reported-by: kernel test robot
    Cc: Kees Cook
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexander Potapenko
     
  • objtool points out several conditions that it does not like, depending
    on the combination with other configuration options and compiler
    variants:

    stack protector:
    lib/ubsan.o: warning: objtool: __ubsan_handle_type_mismatch()+0xbf: call to __stack_chk_fail() with UACCESS enabled
    lib/ubsan.o: warning: objtool: __ubsan_handle_type_mismatch_v1()+0xbe: call to __stack_chk_fail() with UACCESS enabled

    stackleak plugin:
    lib/ubsan.o: warning: objtool: __ubsan_handle_type_mismatch()+0x4a: call to stackleak_track_stack() with UACCESS enabled
    lib/ubsan.o: warning: objtool: __ubsan_handle_type_mismatch_v1()+0x4a: call to stackleak_track_stack() with UACCESS enabled

    kasan:
    lib/ubsan.o: warning: objtool: __ubsan_handle_type_mismatch()+0x25: call to memcpy() with UACCESS enabled
    lib/ubsan.o: warning: objtool: __ubsan_handle_type_mismatch_v1()+0x25: call to memcpy() with UACCESS enabled

    The stackleak and kasan options just need to be disabled for this file
    as we do for other files already. For the stack protector, we already
    attempt to disable it, but this fails on clang because the check is
    mixed with the gcc specific -fno-conserve-stack option. According to
    Andrey Ryabinin, that option is not even needed, dropping it here fixes
    the stackprotector issue.

    Link: http://lkml.kernel.org/r/20190722125139.1335385-1-arnd@arndb.de
    Link: https://lore.kernel.org/lkml/20190617123109.667090-1-arnd@arndb.de/t/
    Link: https://lore.kernel.org/lkml/20190722091050.2188664-1-arnd@arndb.de/t/
    Fixes: d08965a27e84 ("x86/uaccess, ubsan: Fix UBSAN vs. SMAP")
    Signed-off-by: Arnd Bergmann
    Reviewed-by: Andrey Ryabinin
    Cc: Josh Poimboeuf
    Cc: Peter Zijlstra
    Cc: Arnd Bergmann
    Cc: Borislav Petkov
    Cc: Dmitry Vyukov
    Cc: Thomas Gleixner
    Cc: Ingo Molnar
    Cc: Kees Cook
    Cc: Matthew Wilcox
    Cc: Ard Biesheuvel
    Cc: Andy Shevchenko
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arnd Bergmann
     
  • asan-stack mode still uses dangerously large kernel stacks of tens of
    kilobytes in some drivers, and it does not seem that anyone is working
    on the clang bug.

    Turn it off for all clang versions to prevent users from accidentally
    enabling it once they update to clang-9, and to help automated build
    testing with clang-9.

    Link: https://bugs.llvm.org/show_bug.cgi?id=38809
    Link: http://lkml.kernel.org/r/20190719200347.2596375-1-arnd@arndb.de
    Fixes: 6baec880d7a5 ("kasan: turn off asan-stack for clang-8 and earlier")
    Signed-off-by: Arnd Bergmann
    Acked-by: Nick Desaulniers
    Reviewed-by: Mark Brown
    Reviewed-by: Andrey Ryabinin
    Cc: Qian Cai
    Cc: Andrey Konovalov
    Cc: Vasily Gorbik
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arnd Bergmann
     

31 Jul, 2019

4 commits

  • The following four files are every time rebuilt:

    UNROLL lib/raid6/vpermxor1.c
    UNROLL lib/raid6/vpermxor2.c
    UNROLL lib/raid6/vpermxor4.c
    UNROLL lib/raid6/vpermxor8.c

    Fix the suffixes in the targets.

    Fixes: 72ad21075df8 ("lib/raid6: refactor unroll rules with pattern rules")
    Signed-off-by: Masahiro Yamada

    Masahiro Yamada
     
  • To address the regression which causes seccomp to deny applications the
    access to clock_gettime64() and clock_getres64() syscalls because they
    are not enabled in the existing filters.

    That trips over the fact that 32bit VDSOs use the new clock_gettime64() and
    clock_getres64() syscalls in the fallback path.

    Add a conditional to invoke the 32bit legacy fallback syscalls instead of
    the new 64bit variants. The conditional can go away once all architectures
    are converted.

    Fixes: 00b26474c2f1 ("lib/vdso: Provide generic VDSO implementation")
    Signed-off-by: Thomas Gleixner
    Tested-by: Sean Christopherson
    Reviewed-by: Sean Christopherson
    Link: https://lkml.kernel.org/r/alpine.DEB.2.21.1907301134470.1738@nanos.tec.linutronix.de

    Thomas Gleixner
     
  • To allow syscall fallbacks using the legacy 32bit syscall for 32bit VDSO
    builds, move the fallback invocation out into the callers.

    Split the common code out of __cvdso_clock_gettime/getres() and invoke the
    syscall fallback in the 64bit and 32bit variants.

    Preparatory work for using legacy syscalls in 32bit VDSO. No functional
    change.

    Fixes: 00b26474c2f1 ("lib/vdso: Provide generic VDSO implementation")
    Signed-off-by: Thomas Gleixner
    Tested-by: Vincenzo Frascino
    Reviewed-by: Andy Lutomirski
    Reviewed-by: Vincenzo Frascino
    Link: https://lkml.kernel.org/r/20190728131648.695579736@linutronix.de

    Thomas Gleixner
     
  • The 32bit variants of vdso_clock_gettime()/getres() have a NULL pointer
    check for the timespec pointer. That's inconsistent vs. 64bit.

    But the vdso implementation will never be consistent versus the syscall
    because the only case which it can handle is NULL. Any other invalid
    pointer will cause a segfault. So special casing NULL is not really useful.

    Remove it along with the superflouos syscall fallback invocation as that
    will return -EFAULT anyway. That also gets rid of the dubious typecast
    which only works because the pointer is NULL.

    Fixes: 00b26474c2f1 ("lib/vdso: Provide generic VDSO implementation")
    Signed-off-by: Thomas Gleixner
    Tested-by: Vincenzo Frascino
    Reviewed-by: Vincenzo Frascino
    Reviewed-by: Andy Lutomirski
    Link: https://lkml.kernel.org/r/20190728131648.587523358@linutronix.de

    Thomas Gleixner
     

26 Jul, 2019

2 commits

  • DIM causes to the following warnings during kernel compilation
    which indicates that tx_profile and rx_profile are supposed to
    be declared in *.c and not in *.h files.

    In file included from ./include/rdma/ib_verbs.h:64,
    from ./include/linux/mlx5/device.h:37,
    from ./include/linux/mlx5/driver.h:51,
    from ./include/linux/mlx5/vport.h:36,
    from drivers/infiniband/hw/mlx5/ib_virt.c:34:
    ./include/linux/dim.h:326:1: warning: _tx_profile_ defined but not used [-Wunused-const-variable=]
    326 | tx_profile[DIM_CQ_PERIOD_NUM_MODES][NET_DIM_PARAMS_NUM_PROFILES] = {
    | ^~~~~~~~~~
    ./include/linux/dim.h:320:1: warning: _rx_profile_ defined but not used [-Wunused-const-variable=]
    320 | rx_profile[DIM_CQ_PERIOD_NUM_MODES][NET_DIM_PARAMS_NUM_PROFILES] = {
    | ^~~~~~~~~~

    Fixes: 4f75da3666c0 ("linux/dim: Move implementation to .c files")
    Signed-off-by: Leon Romanovsky
    Reviewed-by: Bart Van Assche
    Acked-by: Saeed Mahameed
    Signed-off-by: David S. Miller

    Leon Romanovsky
     
  • While using net_dim, a dim_sample was used without ever initializing the
    comps value. Added use of DIV_ROUND_DOWN_ULL() to prevent potential
    overflow, it should not be a problem to save the final result in an int
    because after the division by epms the value should not be larger than a
    few thousand.

    [ 1040.127124] UBSAN: Undefined behaviour in lib/dim/dim.c:78:23
    [ 1040.130118] signed integer overflow:
    [ 1040.131643] 134718714 * 100 cannot be represented in type 'int'

    Fixes: 398c2b05bbee ("linux/dim: Add completions count to dim_sample")
    Signed-off-by: Yamin Friedman
    Signed-off-by: Leon Romanovsky
    Acked-by: Saeed Mahameed
    Signed-off-by: David S. Miller

    Yamin Friedman
     

25 Jul, 2019

1 commit

  • In test_firmware_init(), the buffer pointed to by the global pointer
    'test_fw_config' is allocated through kzalloc(). Then, the buffer is
    initialized in __test_firmware_config_init(). In the case that the
    initialization fails, the following execution in test_firmware_init() needs
    to be terminated with an error code returned to indicate this failure.
    However, the allocated buffer is not freed on this execution path, leading
    to a memory leak bug.

    To fix the above issue, free the allocated buffer before returning from
    test_firmware_init().

    Signed-off-by: Wenwen Wang
    Link: https://lore.kernel.org/r/1563084696-6865-1-git-send-email-wang6495@umn.edu
    Signed-off-by: Greg Kroah-Hartman

    Wenwen Wang
     

21 Jul, 2019

1 commit

  • Pull more Kbuild updates from Masahiro Yamada:

    - match the directory structure of the linux-libc-dev package to that
    of Debian-based distributions

    - fix incorrect include/config/auto.conf generation when Kconfig
    creates it along with the .config file

    - remove misleading $(AS) from documents

    - clean up precious tag files by distclean instead of mrproper

    - add a new coccinelle patch for devm_platform_ioremap_resource
    migration

    - refactor module-related scripts to read modules.order instead of
    $(MODVERDIR)/*.mod files to get the list of created modules

    - remove MODVERDIR

    - update list of header compile-test

    - add -fcf-protection=none flag to avoid conflict with the retpoline
    flags when CONFIG_RETPOLINE=y

    - misc cleanups

    * tag 'kbuild-v5.3-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (25 commits)
    kbuild: add -fcf-protection=none when using retpoline flags
    kbuild: update compile-test header list for v5.3-rc1
    kbuild: split out *.mod out of {single,multi}-used-m rules
    kbuild: remove 'prepare1' target
    kbuild: remove the first line of *.mod files
    kbuild: create *.mod with full directory path and remove MODVERDIR
    kbuild: export_report: read modules.order instead of .tmp_versions/*.mod
    kbuild: modpost: read modules.order instead of $(MODVERDIR)/*.mod
    kbuild: modsign: read modules.order instead of $(MODVERDIR)/*.mod
    kbuild: modinst: read modules.order instead of $(MODVERDIR)/*.mod
    scsi: remove pointless $(MODVERDIR)/$(obj)/53c700.ver
    kbuild: remove duplication from modules.order in sub-directories
    kbuild: get rid of kernel/ prefix from in-tree modules.{order,builtin}
    kbuild: do not create empty modules.order in the prepare stage
    coccinelle: api: add devm_platform_ioremap_resource script
    kbuild: compile-test headers listed in header-test-m as well
    kbuild: remove unused hostcc-option
    kbuild: remove tag files by distclean instead of mrproper
    kbuild: add --hash-style= and --build-id unconditionally
    kbuild: get rid of misleading $(AS) from documents
    ...

    Linus Torvalds
     

20 Jul, 2019

1 commit

  • Pull ARM SoC-related driver updates from Olof Johansson:
    "Various driver updates for platforms and a couple of the small driver
    subsystems we merge through our tree:

    - A driver for SCU (system control) on NXP i.MX8QXP

    - Qualcomm Always-on Subsystem messaging driver (AOSS QMP)

    - Qualcomm PM support for MSM8998

    - Support for a newer version of DRAM PHY driver for Broadcom (DPFE)

    - Reset controller support for Bitmain BM1880

    - TI SCI (System Control Interface) support for CPU control on AM654
    processors

    - More TI sysc refactoring and rework"

    * tag 'armsoc-drivers' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc: (84 commits)
    reset: remove redundant null check on pointer dev
    soc: rockchip: work around clang warning
    dt-bindings: reset: imx7: Fix the spelling of 'indices'
    soc: imx: Add i.MX8MN SoC driver support
    soc: aspeed: lpc-ctrl: Fix probe error handling
    soc: qcom: geni: Add support for ACPI
    firmware: ti_sci: Fix gcc unused-but-set-variable warning
    firmware: ti_sci: Use the correct style for SPDX License Identifier
    soc: imx8: Use existing of_root directly
    soc: imx8: Fix potential kernel dump in error path
    firmware/psci: psci_checker: Park kthreads before stopping them
    memory: move jedec_ddr.h from include/memory to drivers/memory/
    memory: move jedec_ddr_data.c from lib/ to drivers/memory/
    MAINTAINERS: Remove myself as qcom maintainer
    soc: aspeed: lpc-ctrl: make parameter optional
    soc: qcom: apr: Don't use reg for domain id
    soc: qcom: fix QCOM_AOSS_QMP dependency and build errors
    memory: tegra: Fix -Wunused-const-variable
    firmware: tegra: Early resume BPMP
    soc/tegra: Select pinctrl for Tegra194
    ...

    Linus Torvalds
     

18 Jul, 2019

1 commit

  • While descending directories, Kbuild produces objects for modules,
    but do not link final *.ko files; it is done in the modpost.

    To keep track of modules, Kbuild creates a *.mod file in $(MODVERDIR)
    for every module it is building. Some post-processing steps read the
    necessary information from *.mod files. This avoids descending into
    directories again. This mechanism was introduced in 2003 or so.

    Later, commit 551559e13af1 ("kbuild: implement modules.order") added
    modules.order. So, we can simply read it out to know all the modules
    with directory paths. This is easier than parsing the first line of
    *.mod files.

    $(MODVERDIR) has a flat directory structure, that is, *.mod files
    are named only with base names. This is based on the assumption that
    the module name is unique across the tree. This assumption is really
    fragile.

    Stephen Rothwell reported a race condition caused by a module name
    conflict:

    https://lkml.org/lkml/2019/5/13/991

    In parallel building, two different threads could write to the same
    $(MODVERDIR)/*.mod simultaneously.

    Non-unique module names are the source of all kind of troubles, hence
    commit 3a48a91901c5 ("kbuild: check uniqueness of module names")
    introduced a new checker script.

    However, it is still fragile in the build system point of view because
    this race happens before scripts/modules-check.sh is invoked. If it
    happens again, the modpost will emit unclear error messages.

    To fix this issue completely, create *.mod with full directory path
    so that two threads never attempt to write to the same file.

    $(MODVERDIR) is no longer needed.

    Since modules with directory paths are listed in modules.order, Kbuild
    is still able to find *.mod files without additional descending.

    I also killed cmd_secanalysis; scripts/mod/sumversion.c computes MD4 hash
    for modules with MODULE_VERSION(). When CONFIG_DEBUG_SECTION_MISMATCH=y,
    it occurs not only in the modpost stage, but also during directory
    descending, where sumversion.c may parse stale *.mod files. It would emit
    'No such file or directory' warning when an object consisting a module is
    renamed, or when a single-obj module is turned into a multi-obj module or
    vice versa.

    Signed-off-by: Masahiro Yamada
    Acked-by: Nicolas Pitre

    Masahiro Yamada
     

17 Jul, 2019

14 commits

  • Merge more updates from Andrew Morton:
    "VM:
    - z3fold fixes and enhancements by Henry Burns and Vitaly Wool

    - more accurate reclaimed slab caches calculations by Yafang Shao

    - fix MAP_UNINITIALIZED UAPI symbol to not depend on config, by
    Christoph Hellwig

    - !CONFIG_MMU fixes by Christoph Hellwig

    - new novmcoredd parameter to omit device dumps from vmcore, by
    Kairui Song

    - new test_meminit module for testing heap and pagealloc
    initialization, by Alexander Potapenko

    - ioremap improvements for huge mappings, by Anshuman Khandual

    - generalize kprobe page fault handling, by Anshuman Khandual

    - device-dax hotplug fixes and improvements, by Pavel Tatashin

    - enable synchronous DAX fault on powerpc, by Aneesh Kumar K.V

    - add pte_devmap() support for arm64, by Robin Murphy

    - unify locked_vm accounting with a helper, by Daniel Jordan

    - several misc fixes

    core/lib:
    - new typeof_member() macro including some users, by Alexey Dobriyan

    - make BIT() and GENMASK() available in asm, by Masahiro Yamada

    - changed LIST_POISON2 on x86_64 to 0xdead000000000122 for better
    code generation, by Alexey Dobriyan

    - rbtree code size optimizations, by Michel Lespinasse

    - convert struct pid count to refcount_t, by Joel Fernandes

    get_maintainer.pl:
    - add --no-moderated switch to skip moderated ML's, by Joe Perches

    misc:
    - ptrace PTRACE_GET_SYSCALL_INFO interface

    - coda updates

    - gdb scripts, various"

    [ Using merge message suggestion from Vlastimil Babka, with some editing - Linus ]

    * emailed patches from Andrew Morton : (100 commits)
    fs/select.c: use struct_size() in kmalloc()
    mm: add account_locked_vm utility function
    arm64: mm: implement pte_devmap support
    mm: introduce ARCH_HAS_PTE_DEVMAP
    mm: clean up is_device_*_page() definitions
    mm/mmap: move common defines to mman-common.h
    mm: move MAP_SYNC to asm-generic/mman-common.h
    device-dax: "Hotremove" persistent memory that is used like normal RAM
    mm/hotplug: make remove_memory() interface usable
    device-dax: fix memory and resource leak if hotplug fails
    include/linux/lz4.h: fix spelling and copy-paste errors in documentation
    ipc/mqueue.c: only perform resource calculation if user valid
    include/asm-generic/bug.h: fix "cut here" for WARN_ON for __WARN_TAINT architectures
    scripts/gdb: add helpers to find and list devices
    scripts/gdb: add lx-genpd-summary command
    drivers/pps/pps.c: clear offset flags in PPS_SETPARAMS ioctl
    kernel/pid.c: convert struct pid count to refcount_t
    drivers/rapidio/devices/rio_mport_cdev.c: NUL terminate some strings
    select: shift restore_saved_sigmask_unless() into poll_select_copy_remaining()
    select: change do_poll() to return -ERESTARTNOHAND rather than -EINTR
    ...

    Linus Torvalds
     
  • As was already noted in rbtree.h, the logic to cache rb_first (or
    rb_last) can easily be implemented externally to the core rbtree api.

    Change the implementation to do just that. Previously the update of
    rb_leftmost was wired deeper into the implmentation, but there were some
    disadvantages to that - mostly, lib/rbtree.c had separate instantiations
    for rb_insert_color() vs rb_insert_color_cached(), as well as rb_erase()
    vs rb_erase_cached(), which were doing exactly the same thing save for
    the rb_leftmost update at the start of either function.

    text data bss dec hex filename
    5405 120 0 5525 1595 lib/rbtree.o-vanilla
    3827 96 0 3923 f53 lib/rbtree.o-patch

    [dave@stgolabs.net: changelog addition]
    Link: http://lkml.kernel.org/r/20190628171416.by5gdizl3rcxk5h5@linux-r8p5
    [akpm@linux-foundation.org: coding-style fixes]
    Link: http://lkml.kernel.org/r/20190628045008.39926-1-walken@google.com
    Signed-off-by: Michel Lespinasse
    Acked-by: Davidlohr Bueso
    Acked-by: Peter Zijlstra (Intel)
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michel Lespinasse
     
  • Fix the following issues in test_meminit.c:
    - |size| in fill_with_garbage_skip() should be signed so that it
    doesn't overflow if it's not aligned on sizeof(*p);
    - fill_with_garbage_skip() should actually skip |skip| bytes;
    - do_kmem_cache_size() should deallocate memory in the RCU case.

    Link: http://lkml.kernel.org/r/20190626133135.217355-1-glider@google.com
    Fixes: 7e659650cbda ("lib: introduce test_meminit module")
    Fixes: 94e8988d91c7 ("lib/test_meminit.c: fix -Wmaybe-uninitialized false positive")
    Signed-off-by: Alexander Potapenko
    Cc: Arnd Bergmann
    Cc: Kees Cook
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexander Potapenko
     
  • The conditional logic is too complicated for the compiler to fully
    comprehend:

    lib/test_meminit.c: In function 'test_meminit_init':
    lib/test_meminit.c:236:5: error: 'buf_copy' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    kfree(buf_copy);
    ^~~~~~~~~~~~~~~
    lib/test_meminit.c:201:14: note: 'buf_copy' was declared here

    Simplify it by splitting out the non-rcu section.

    Link: http://lkml.kernel.org/r/20190617131210.2190280-1-arnd@arndb.de
    Fixes: af734ee6ec85 ("lib: introduce test_meminit module")
    Signed-off-by: Arnd Bergmann
    Acked-by: Alexander Potapenko
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arnd Bergmann
     
  • Due to some sad limitations in how kerneldoc comments are parsed, the
    documentation in lib/string_helpers.c generates these warnings:

    lib/string_helpers.c:236: WARNING: Unexpected indentation.
    lib/string_helpers.c:241: WARNING: Block quote ends without a blank line; unexpected unindent.
    lib/string_helpers.c:446: WARNING: Unexpected indentation.
    lib/string_helpers.c:451: WARNING: Block quote ends without a blank line; unexpected unindent.
    lib/string_helpers.c:474: WARNING: Unexpected indentation.

    Rework the comments to obtain something like the desired result.

    Link: http://lkml.kernel.org/r/20190607110952.409011ba@lwn.net
    Signed-off-by: Jonathan Corbet
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jonathan Corbet
     
  • Finish up what commit c2febafc6773 ("mm: convert generic code to 5-level
    paging") started while levelling up P4D huge mapping support at par with
    PUD and PMD. A new arch call back arch_ioremap_p4d_supported() is added
    which just maintains status quo (P4D huge map not supported) on x86,
    arm64 and powerpc.

    When HAVE_ARCH_HUGE_VMAP is enabled its just a simple check from the
    arch about the support, hence runtime effects are minimal.

    Link: http://lkml.kernel.org/r/1561699231-20991-1-git-send-email-anshuman.khandual@arm.com
    Signed-off-by: Anshuman Khandual
    Acked-by: Thomas Gleixner
    Acked-by: Michael Ellerman (powerpc)
    Cc: Catalin Marinas
    Cc: Will Deacon
    Cc: Dave Hansen
    Cc: Andy Lutomirski
    Cc: Peter Zijlstra
    Cc: Ingo Molnar
    Cc: Kirill A. Shutemov
    Cc: Michal Hocko
    Cc: Stephen Rothwell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Anshuman Khandual
     
  • Virtual address alignment is essential in ensuring correct clearing for
    all intermediate level pgtable entries and freeing associated pgtable
    pages. An unaligned address can end up randomly freeing pgtable page
    that potentially still contains valid mappings. Hence also check it's
    alignment along with existing phys_addr check.

    Signed-off-by: Anshuman Khandual
    Reviewed-by: Catalin Marinas
    Cc: Toshi Kani
    Cc: Will Deacon
    Cc: Chintan Pandya
    Cc: Thomas Gleixner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Anshuman Khandual
     
  • Add tests for heap and pagealloc initialization. These can be used to
    check init_on_alloc and init_on_free implementations as well as other
    approaches to initialization.

    Expected test output in the case the kernel provides heap initialization
    (e.g. when running with either init_on_alloc=1 or init_on_free=1):

    test_meminit: all 10 tests in test_pages passed
    test_meminit: all 40 tests in test_kvmalloc passed
    test_meminit: all 60 tests in test_kmemcache passed
    test_meminit: all 10 tests in test_rcu_persistent passed
    test_meminit: all 120 tests passed!

    Link: http://lkml.kernel.org/r/20190529123812.43089-4-glider@google.com
    Signed-off-by: Alexander Potapenko
    Acked-by: Kees Cook
    Cc: Christoph Lameter
    Cc: Nick Desaulniers
    Cc: Kostya Serebryany
    Cc: Dmitry Vyukov
    Cc: Sandeep Patil
    Cc: Laura Abbott
    Cc: Jann Horn
    Cc: Marco Elver
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexander Potapenko
     
  • This adds __GFP_NOWARN to the kmalloc()-portions of the overflow test to
    avoid tainting the kernel. Additionally fixes up the math on wrap size
    to be architecture and page size agnostic.

    Link: http://lkml.kernel.org/r/201905282012.0A8767E24@keescook
    Fixes: ca90800a91ba ("test_overflow: Add memory allocation overflow tests")
    Signed-off-by: Kees Cook
    Reported-by: Randy Dunlap
    Suggested-by: Rasmus Villemoes
    Cc: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Kees Cook
     
  • Make sure that the trailing NUL is considered part of the string and can
    be found.

    Link: http://lkml.kernel.org/r/20190506124634.6807-4-peda@axentia.se
    Signed-off-by: Peter Rosin
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Peter Rosin
     
  • If a memsetXX implementation is completely broken and fails in the first
    iteration, when i, j, and k are all zero, the failure is masked as zero
    is returned. Failing in the first iteration is perhaps the most likely
    failure, so this makes the tests pretty much useless. Avoid the
    situation by always setting a random unused bit in the result on
    failure.

    Link: http://lkml.kernel.org/r/20190506124634.6807-3-peda@axentia.se
    Fixes: 03270c13c5ff ("lib/string.c: add testcases for memset16/32/64")
    Signed-off-by: Peter Rosin
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Peter Rosin
     
  • Patch series "lib/string: search for NUL with strchr/strnchr".

    I noticed an inconsistency where strchr and strnchr do not behave the
    same with respect to the trailing NUL. strchr is standardised and the
    kernel function conforms, and the kernel relies on the behavior. So,
    naturally strchr stays as-is and strnchr is what I change.

    While writing a few tests to verify that my new strnchr loop was sane, I
    noticed that the tests for memset16/32/64 had a problem. Since it's all
    about the lib/string.c file I made a short series of it all...

    This patch (of 3):

    strchr considers the terminating NUL to be part of the string, and NUL
    can thus be searched for with that function. For consistency, do the
    same with strnchr.

    Link: http://lkml.kernel.org/r/20190506124634.6807-2-peda@axentia.se
    Signed-off-by: Peter Rosin
    Cc: Matthew Wilcox
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Peter Rosin
     
  • The mpi library contains some rather old inline assembly statements that
    produce a lot of warnings for 32-bit x86, such as:

    lib/mpi/mpih-div.c:76:16: error: invalid use of a cast in a inline asm context requiring an l-value: remove the cast or build with -fheinous-gnu-extensions
    udiv_qrnnd(qp[i], n1, n1, np[i], d);
    ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
    lib/mpi/longlong.h:423:20: note: expanded from macro 'udiv_qrnnd'
    : "=a" ((USItype)(q)), \
    ~~~~~~~~~~^~

    There is no point in doing a type cast for the output of an inline
    assembler statement, so just remove the cast here, as we have done for
    other architectures in the past.

    See also dea632cadd12 ("lib/mpi: fix build with clang").

    Link: http://lkml.kernel.org/r/20190712090740.340186-1-arnd@arndb.de
    Signed-off-by: Arnd Bergmann
    Reviewed-by: Nick Desaulniers
    Cc: Stefan Agner
    Cc: Dmitry Kasatkin
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arnd Bergmann
     
  • Pull rst conversion of docs from Mauro Carvalho Chehab:
    "As agreed with Jon, I'm sending this big series directly to you, c/c
    him, as this series required a special care, in order to avoid
    conflicts with other trees"

    * tag 'docs/v5.3-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (77 commits)
    docs: kbuild: fix build with pdf and fix some minor issues
    docs: block: fix pdf output
    docs: arm: fix a breakage with pdf output
    docs: don't use nested tables
    docs: gpio: add sysfs interface to the admin-guide
    docs: locking: add it to the main index
    docs: add some directories to the main documentation index
    docs: add SPDX tags to new index files
    docs: add a memory-devices subdir to driver-api
    docs: phy: place documentation under driver-api
    docs: serial: move it to the driver-api
    docs: driver-api: add remaining converted dirs to it
    docs: driver-api: add xilinx driver API documentation
    docs: driver-api: add a series of orphaned documents
    docs: admin-guide: add a series of orphaned documents
    docs: cgroup-v1: add it to the admin-guide book
    docs: aoe: add it to the driver-api book
    docs: add some documentation dirs to the driver-api book
    docs: driver-model: move it to the driver-api book
    docs: lp855x-driver.rst: add it to the driver-api book
    ...

    Linus Torvalds
     

16 Jul, 2019

1 commit

  • Pull rdma updates from Jason Gunthorpe:
    "A smaller cycle this time. Notably we see another new driver, 'Soft
    iWarp', and the deletion of an ancient unused driver for nes.

    - Revise and simplify the signature offload RDMA MR APIs

    - More progress on hoisting object allocation boiler plate code out
    of the drivers

    - Driver bug fixes and revisions for hns, hfi1, efa, cxgb4, qib,
    i40iw

    - Tree wide cleanups: struct_size, put_user_page, xarray, rst doc
    conversion

    - Removal of obsolete ib_ucm chardev and nes driver

    - netlink based discovery of chardevs and autoloading of the modules
    providing them

    - Move more of the rdamvt/hfi1 uapi to include/uapi/rdma

    - New driver 'siw' for software based iWarp running on top of netdev,
    much like rxe's software RoCE.

    - mlx5 feature to report events in their raw devx format to userspace

    - Expose per-object counters through rdma tool

    - Adaptive interrupt moderation for RDMA (DIM), sharing the DIM core
    from netdev"

    * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma: (194 commits)
    RMDA/siw: Require a 64 bit arch
    RDMA/siw: Mark expected switch fall-throughs
    RDMA/core: Fix -Wunused-const-variable warnings
    rdma/siw: Remove set but not used variable 's'
    rdma/siw: Add missing dependencies on LIBCRC32C and DMA_VIRT_OPS
    RDMA/siw: Add missing rtnl_lock around access to ifa
    rdma/siw: Use proper enumerated type in map_cqe_status
    RDMA/siw: Remove unnecessary kthread create/destroy printouts
    IB/rdmavt: Fix variable shadowing issue in rvt_create_cq
    RDMA/core: Fix race when resolving IP address
    RDMA/core: Make rdma_counter.h compile stand alone
    IB/core: Work on the caller socket net namespace in nldev_newlink()
    RDMA/rxe: Fill in wc byte_len with IB_WC_RECV_RDMA_WITH_IMM
    RDMA/mlx5: Set RDMA DIM to be enabled by default
    RDMA/nldev: Added configuration of RDMA dynamic interrupt moderation to netlink
    RDMA/core: Provide RDMA DIM support for ULPs
    linux/dim: Implement RDMA adaptive moderation (DIM)
    IB/mlx5: Report correctly tag matching rendezvous capability
    docs: infiniband: add it to the driver-api bookset
    IB/mlx5: Implement VHCA tunnel mechanism in DEVX
    ...

    Linus Torvalds
     

15 Jul, 2019

2 commits

  • Convert the locking documents to ReST and add them to the
    kernel development book where it belongs.

    Most of the stuff here is just to make Sphinx to properly
    parse the text file, as they're already in good shape,
    not requiring massive changes in order to be parsed.

    The conversion is actually:
    - add blank lines and identation in order to identify paragraphs;
    - fix tables markups;
    - add some lists markups;
    - mark literal blocks;
    - adjust title markups.

    At its new index.rst, let's add a :orphan: while this is not linked to
    the main index.rst file, in order to avoid build warnings.

    Signed-off-by: Mauro Carvalho Chehab
    Acked-by: Federico Vaga

    Mauro Carvalho Chehab
     
  • Pull percpu updates from Dennis Zhou:
    "This includes changes to let percpu_ref release the backing percpu
    memory earlier after it has been switched to atomic in cases where the
    percpu ref is not revived.

    This will help recycle percpu memory earlier in cases where the
    refcounts are pinned for prolonged periods of time"

    * 'for-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/dennis/percpu:
    percpu_ref: release percpu memory early without PERCPU_REF_ALLOW_REINIT
    md: initialize percpu refcounters using PERCU_REF_ALLOW_REINIT
    io_uring: initialize percpu refcounters using PERCU_REF_ALLOW_REINIT
    percpu_ref: introduce PERCPU_REF_ALLOW_REINIT flag

    Linus Torvalds
     

14 Jul, 2019

1 commit

  • Pull io_uring updates from Jens Axboe:
    "This contains:

    - Support for recvmsg/sendmsg as first class opcodes.

    I don't envision going much further down this path, as there are
    plans in progress to support potentially any system call in an
    async fashion through io_uring. But I think it does make sense to
    have certain core ops available directly, especially those that can
    support a "try this non-blocking" flag/mode. (me)

    - Handle generic short reads automatically.

    This can happen fairly easily if parts of the buffered read is
    cached. Since the application needs to issue another request for
    the remainder, just do this internally and save kernel/user
    roundtrip while providing a nicer more robust API. (me)

    - Support for linked SQEs.

    This allows SQEs to depend on each other, enabling an application
    to eg queue a read-from-this-file,write-to-that-file pair. (me)

    - Fix race in stopping SQ thread (Jackie)"

    * tag 'for-5.3/io_uring-20190711' of git://git.kernel.dk/linux-block:
    io_uring: fix io_sq_thread_stop running in front of io_sq_thread
    io_uring: add support for recvmsg()
    io_uring: add support for sendmsg()
    io_uring: add support for sqe links
    io_uring: punt short reads to async context
    uio: make import_iovec()/compat_import_iovec() return bytes on success

    Linus Torvalds
     

13 Jul, 2019

1 commit

  • Pull Kbuild updates from Masahiro Yamada:

    - remove headers_{install,check}_all targets

    - remove unreasonable 'depends on !UML' from CONFIG_SAMPLES

    - re-implement 'make headers_install' more cleanly

    - add new header-test-y syntax to compile-test headers

    - compile-test exported headers to ensure they are compilable in
    user-space

    - compile-test headers under include/ to ensure they are self-contained

    - remove -Waggregate-return, -Wno-uninitialized, -Wno-unused-value
    flags

    - add -Werror=unknown-warning-option for Clang

    - add 128-bit built-in types support to genksyms

    - fix missed rebuild of modules.builtin

    - propagate 'No space left on device' error in fixdep to Make

    - allow Clang to use its integrated assembler

    - improve some coccinelle scripts

    - add a new flag KBUILD_ABS_SRCTREE to request Kbuild to use absolute
    path for $(srctree).

    - do not ignore errors when compression utility is missing

    - misc cleanups

    * tag 'kbuild-v5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (49 commits)
    kbuild: use -- separater intead of $(filter-out ...) for cc-cross-prefix
    kbuild: Inform user to pass ARCH= for make mrproper
    kbuild: fix compression errors getting ignored
    kbuild: add a flag to force absolute path for srctree
    kbuild: replace KBUILD_SRCTREE with boolean building_out_of_srctree
    kbuild: remove src and obj from the top Makefile
    scripts/tags.sh: remove unused environment variables from comments
    scripts/tags.sh: drop SUBARCH support for ARM
    kbuild: compile-test kernel headers to ensure they are self-contained
    kheaders: include only headers into kheaders_data.tar.xz
    kheaders: remove meaningless -R option of 'ls'
    kbuild: support header-test-pattern-y
    kbuild: do not create wrappers for header-test-y
    kbuild: compile-test exported headers to ensure they are self-contained
    init/Kconfig: add CONFIG_CC_CAN_LINK
    kallsyms: exclude kasan local symbols on s390
    kbuild: add more hints about SUBDIRS replacement
    coccinelle: api/stream_open: treat all wait_.*() calls as blocking
    coccinelle: put_device: Add a cast to an expression for an assignment
    coccinelle: put_device: Adjust a message construction
    ...

    Linus Torvalds