28 Sep, 2019

1 commit

  • Pull kernel lockdown mode from James Morris:
    "This is the latest iteration of the kernel lockdown patchset, from
    Matthew Garrett, David Howells and others.

    From the original description:

    This patchset introduces an optional kernel lockdown feature,
    intended to strengthen the boundary between UID 0 and the kernel.
    When enabled, various pieces of kernel functionality are restricted.
    Applications that rely on low-level access to either hardware or the
    kernel may cease working as a result - therefore this should not be
    enabled without appropriate evaluation beforehand.

    The majority of mainstream distributions have been carrying variants
    of this patchset for many years now, so there's value in providing a
    doesn't meet every distribution requirement, but gets us much closer
    to not requiring external patches.

    There are two major changes since this was last proposed for mainline:

    - Separating lockdown from EFI secure boot. Background discussion is
    covered here: https://lwn.net/Articles/751061/

    - Implementation as an LSM, with a default stackable lockdown LSM
    module. This allows the lockdown feature to be policy-driven,
    rather than encoding an implicit policy within the mechanism.

    The new locked_down LSM hook is provided to allow LSMs to make a
    policy decision around whether kernel functionality that would allow
    tampering with or examining the runtime state of the kernel should be
    permitted.

    The included lockdown LSM provides an implementation with a simple
    policy intended for general purpose use. This policy provides a coarse
    level of granularity, controllable via the kernel command line:

    lockdown={integrity|confidentiality}

    Enable the kernel lockdown feature. If set to integrity, kernel features
    that allow userland to modify the running kernel are disabled. If set to
    confidentiality, kernel features that allow userland to extract
    confidential information from the kernel are also disabled.

    This may also be controlled via /sys/kernel/security/lockdown and
    overriden by kernel configuration.

    New or existing LSMs may implement finer-grained controls of the
    lockdown features. Refer to the lockdown_reason documentation in
    include/linux/security.h for details.

    The lockdown feature has had signficant design feedback and review
    across many subsystems. This code has been in linux-next for some
    weeks, with a few fixes applied along the way.

    Stephen Rothwell noted that commit 9d1f8be5cf42 ("bpf: Restrict bpf
    when kernel lockdown is in confidentiality mode") is missing a
    Signed-off-by from its author. Matthew responded that he is providing
    this under category (c) of the DCO"

    * 'next-lockdown' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: (31 commits)
    kexec: Fix file verification on S390
    security: constify some arrays in lockdown LSM
    lockdown: Print current->comm in restriction messages
    efi: Restrict efivar_ssdt_load when the kernel is locked down
    tracefs: Restrict tracefs when the kernel is locked down
    debugfs: Restrict debugfs when the kernel is locked down
    kexec: Allow kexec_file() with appropriate IMA policy when locked down
    lockdown: Lock down perf when in confidentiality mode
    bpf: Restrict bpf when kernel lockdown is in confidentiality mode
    lockdown: Lock down tracing and perf kprobes when in confidentiality mode
    lockdown: Lock down /proc/kcore
    x86/mmiotrace: Lock down the testmmiotrace module
    lockdown: Lock down module params that specify hardware parameters (eg. ioport)
    lockdown: Lock down TIOCSSERIAL
    lockdown: Prohibit PCMCIA CIS storage when the kernel is locked down
    acpi: Disable ACPI table override if the kernel is locked down
    acpi: Ignore acpi_rsdp kernel param when the kernel has been locked down
    ACPI: Limit access to custom_method when the kernel is locked down
    x86/msr: Restrict MSR access when the kernel is locked down
    x86: Lock down IO port access when the kernel is locked down
    ...

    Linus Torvalds
     

04 Sep, 2019

1 commit

  • As suggested in https://kernelnewbies.org/KernelJanitors/Todo
    this patch replaces the outdated macro of DPRINTK for dev_dbg()

    To: Dominik Brodowski
    To: Thomas Gleixner
    To: Adam Zerella
    To: linux-kernel@vger.kernel.org
    Signed-off-by: Adam Zerella
    Link: https://lore.kernel.org/r/20190825053513.13990-1-adam.zerella@gmail.com
    Signed-off-by: Greg Kroah-Hartman

    Adam Zerella
     

20 Aug, 2019

1 commit


10 Aug, 2019

1 commit

  • Mark switch cases where we are expecting to fall through.

    This patch fixes the following warnings (Building: db1xxx_defconfig mips):

    drivers/pcmcia/db1xxx_ss.c:257:3: warning: this statement may fall through [-Wimplicit-fallthrough=]
    drivers/pcmcia/db1xxx_ss.c:269:3: warning: this statement may fall through [-Wimplicit-fallthrough=]

    Reviewed-by: Kees Cook
    Signed-off-by: Gustavo A. R. Silva

    Gustavo A. R. Silva
     

10 Jul, 2019

1 commit

  • Pull Documentation updates from Jonathan Corbet:
    "It's been a relatively busy cycle for docs:

    - A fair pile of RST conversions, many from Mauro. These create more
    than the usual number of simple but annoying merge conflicts with
    other trees, unfortunately. He has a lot more of these waiting on
    the wings that, I think, will go to you directly later on.

    - A new document on how to use merges and rebases in kernel repos,
    and one on Spectre vulnerabilities.

    - Various improvements to the build system, including automatic
    markup of function() references because some people, for reasons I
    will never understand, were of the opinion that
    :c:func:``function()`` is unattractive and not fun to type.

    - We now recommend using sphinx 1.7, but still support back to 1.4.

    - Lots of smaller improvements, warning fixes, typo fixes, etc"

    * tag 'docs-5.3' of git://git.lwn.net/linux: (129 commits)
    docs: automarkup.py: ignore exceptions when seeking for xrefs
    docs: Move binderfs to admin-guide
    Disable Sphinx SmartyPants in HTML output
    doc: RCU callback locks need only _bh, not necessarily _irq
    docs: format kernel-parameters -- as code
    Doc : doc-guide : Fix a typo
    platform: x86: get rid of a non-existent document
    Add the RCU docs to the core-api manual
    Documentation: RCU: Add TOC tree hooks
    Documentation: RCU: Rename txt files to rst
    Documentation: RCU: Convert RCU UP systems to reST
    Documentation: RCU: Convert RCU linked list to reST
    Documentation: RCU: Convert RCU basic concepts to reST
    docs: filesystems: Remove uneeded .rst extension on toctables
    scripts/sphinx-pre-install: fix out-of-tree build
    docs: zh_CN: submitting-drivers.rst: Remove a duplicated Documentation/
    Documentation: PGP: update for newer HW devices
    Documentation: Add section about CPU vulnerabilities for Spectre
    Documentation: platform: Delete x86-laptop-drivers.txt
    docs: Note that :c:func: should no longer be used
    ...

    Linus Torvalds
     

19 Jun, 2019

1 commit

  • Based on 2 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license version 2 as
    published by the free software foundation

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license version 2 as
    published by the free software foundation #

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

    has been chosen to replace the boilerplate/reference in 4122 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Enrico Weigelt
    Reviewed-by: Kate Stewart
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190604081206.933168790@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

15 Jun, 2019

1 commit

  • Convert the pcmcia docs to ReST format. Most of the changes here
    are trivial.

    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: Dominik Brodowski
    Signed-off-by: Jonathan Corbet

    Mauro Carvalho Chehab
     

05 Jun, 2019

1 commit

  • Based on 1 normalized pattern(s):

    the contents of this file may be used under the terms of the gnu
    public license version 2 the gpl

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

    has been chosen to replace the boilerplate/reference in 1 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Richard Fontana
    Reviewed-by: Kate Stewart
    Reviewed-by: Alexios Zavras
    Reviewed-by: Steve Winslow
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190529141333.014369811@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

31 May, 2019

2 commits

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version this program is distributed in the
    hope that it will be useful but without any warranty without even
    the implied warranty of merchantability or fitness for a particular
    purpose see the gnu general public license for more details you
    should have received a copy of the gnu general public license along
    with this program if not write to the free software foundation inc
    59 temple place suite 330 boston ma 02111 1307 usa

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 1334 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Reviewed-by: Richard Fontana
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190527070033.113240726@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     
  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 3029 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190527070032.746973796@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

21 May, 2019

2 commits


15 May, 2019

1 commit


06 Jan, 2019

1 commit

  • Pull ARM updates from Russell King:
    "Included in this update:

    - Florian Fainelli noticed that userspace segfaults caused by the
    lack of kernel-userspace helpers was hard to diagnose; we now issue
    a warning when userspace tries to use the helpers but the kernel
    has them disabled.

    - Ben Dooks wants compatibility for the old ATAG serial number with
    DT systems.

    - Some cleanup of assembly by Nicolas Pitre.

    - User accessors optimisation from Vincent Whitchurch.

    - More robust kdump on SMP systems from Yufen Wang.

    - Sebastian Andrzej Siewior noticed problems with the SMP "boot_lock"
    on RT kernels, and so we convert the Versatile series of platforms
    to use a raw spinlock instead, consolidating the Versatile
    implementation. We entirely remove the boot_lock on OMAP systems,
    where it's unnecessary. Further patches for other systems will be
    submitted for the following merge window.

    - Start switching old StrongARM-11x0 systems to use gpiolib rather
    than their private GPIO implementation - mostly PCMCIA bits.

    - ARM Kconfig cleanups.

    - Cleanup a mostly harmless mistake in the recent Spectre patch in
    4.20 (which had the effect that data that can be placed into the
    init sections was incorrectly always placed in the rodata section)"

    * tag 'for-4.21' of git://git.armlinux.org.uk/~rmk/linux-arm: (25 commits)
    ARM: omap2: remove unnecessary boot_lock
    ARM: versatile: rename and comment SMP implementation
    ARM: versatile: convert boot_lock to raw
    ARM: vexpress/realview: consolidate immitation CPU hotplug
    ARM: fix the cockup in the previous patch
    ARM: sa1100/cerf: switch to using gpio_led_register_device()
    ARM: sa1100/assabet: switch to using gpio leds
    ARM: sa1100/assabet: add gpio keys support for right-hand two buttons
    ARM: sa1111: remove legacy GPIO interfaces
    pcmcia: sa1100*: remove redundant bvd1/bvd2 setting
    ARM: pxa/lubbock: switch PCMCIA to MAX1600 library
    ARM: pxa/mainstone: switch PCMCIA to MAX1600 library and gpiod APIs
    ARM: sa1100/neponset: switch PCMCIA to MAX1600 library and gpiod APIs
    ARM: sa1100/jornada720: switch PCMCIA to gpiod APIs
    pcmcia: add MAX1600 library
    ARM: sa1100: explicitly register sa11x0-pcmcia devices
    ARM: 8813/1: Make aligned 2-byte getuser()/putuser() atomic on ARMv6+
    ARM: 8812/1: Optimise copy_{from/to}_user for !CPU_USE_DOMAINS
    ARM: 8811/1: always list both ldrd/strd registers explicitly
    ARM: 8808/1: kexec:offline panic_smp_self_stop CPU
    ...

    Linus Torvalds
     

05 Dec, 2018

6 commits


23 Nov, 2018

1 commit


27 Oct, 2018

1 commit

  • Pull powerpc updates from Michael Ellerman:
    "Notable changes:

    - A large series to rewrite our SLB miss handling, replacing a lot of
    fairly complicated asm with much fewer lines of C.

    - Following on from that, we now maintain a cache of SLB entries for
    each process and preload them on context switch. Leading to a 27%
    speedup for our context switch benchmark on Power9.

    - Improvements to our handling of SLB multi-hit errors. We now print
    more debug information when they occur, and try to continue running
    by flushing the SLB and reloading, rather than treating them as
    fatal.

    - Enable THP migration on 64-bit Book3S machines (eg. Power7/8/9).

    - Add support for physical memory up to 2PB in the linear mapping on
    64-bit Book3S. We only support up to 512TB as regular system
    memory, otherwise the percpu allocator runs out of vmalloc space.

    - Add stack protector support for 32 and 64-bit, with a per-task
    canary.

    - Add support for PTRACE_SYSEMU and PTRACE_SYSEMU_SINGLESTEP.

    - Support recognising "big cores" on Power9, where two SMT4 cores are
    presented to us as a single SMT8 core.

    - A large series to cleanup some of our ioremap handling and PTE
    flags.

    - Add a driver for the PAPR SCM (storage class memory) interface,
    allowing guests to operate on SCM devices (acked by Dan).

    - Changes to our ftrace code to handle very large kernels, where we
    need to use a trampoline to get to ftrace_caller().

    And many other smaller enhancements and cleanups.

    Thanks to: Alan Modra, Alistair Popple, Aneesh Kumar K.V, Anton
    Blanchard, Aravinda Prasad, Bartlomiej Zolnierkiewicz, Benjamin
    Herrenschmidt, Breno Leitao, Cédric Le Goater, Christophe Leroy,
    Christophe Lombard, Dan Carpenter, Daniel Axtens, Finn Thain, Gautham
    R. Shenoy, Gustavo Romero, Haren Myneni, Hari Bathini, Jia Hongtao,
    Joel Stanley, John Allen, Laurent Dufour, Madhavan Srinivasan, Mahesh
    Salgaonkar, Mark Hairgrove, Masahiro Yamada, Michael Bringmann,
    Michael Neuling, Michal Suchanek, Murilo Opsfelder Araujo, Nathan
    Fontenot, Naveen N. Rao, Nicholas Piggin, Nick Desaulniers, Oliver
    O'Halloran, Paul Mackerras, Petr Vorel, Rashmica Gupta, Reza Arbab,
    Rob Herring, Sam Bobroff, Samuel Mendoza-Jonas, Scott Wood, Stan
    Johnson, Stephen Rothwell, Stewart Smith, Suraj Jitindar Singh, Tyrel
    Datwyler, Vaibhav Jain, Vasant Hegde, YueHaibing, zhong jiang"

    * tag 'powerpc-4.20-1' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: (221 commits)
    Revert "selftests/powerpc: Fix out-of-tree build errors"
    powerpc/msi: Fix compile error on mpc83xx
    powerpc: Fix stack protector crashes on CPU hotplug
    powerpc/traps: restore recoverability of machine_check interrupts
    powerpc/64/module: REL32 relocation range check
    powerpc/64s/radix: Fix radix__flush_tlb_collapsed_pmd double flushing pmd
    selftests/powerpc: Add a test of wild bctr
    powerpc/mm: Fix page table dump to work on Radix
    powerpc/mm/radix: Display if mappings are exec or not
    powerpc/mm/radix: Simplify split mapping logic
    powerpc/mm/radix: Remove the retry in the split mapping logic
    powerpc/mm/radix: Fix small page at boundary when splitting
    powerpc/mm/radix: Fix overuse of small pages in splitting logic
    powerpc/mm/radix: Fix off-by-one in split mapping logic
    powerpc/ftrace: Handle large kernel configs
    powerpc/mm: Fix WARN_ON with THP NUMA migration
    selftests/powerpc: Fix out-of-tree build errors
    powerpc/time: no steal_time when CONFIG_PPC_SPLPAR is not selected
    powerpc/time: Only set CONFIG_ARCH_HAS_SCALED_CPUTIME on PPC64
    powerpc/time: isolate scaled cputime accounting in dedicated functions.
    ...

    Linus Torvalds
     

23 Oct, 2018

1 commit

  • Pull pcmcia fixes from Dominik Brodowski:
    "These are just a few odd fixes and improvements to the PCMCIA core and
    to a few PCMCIA device drivers"

    * 'pcmcia-next' of git://git.kernel.org/pub/scm/linux/kernel/git/brodo/linux:
    pcmcia: Implement CLKRUN protocol disabling for Ricoh bridges
    pcmcia: pcmcia_resource: Replace mdelay() with msleep()
    pcmcia: add error handling for pcmcia_enable_device in qlogic_stub
    char: pcmcia: cm4000_cs: Replace mdelay with usleep_range in set_protocol
    pcmcia: Use module_pcmcia_driver for scsi drivers
    pcmcia: remove KERN_INFO level from debug message

    Linus Torvalds
     

14 Oct, 2018

2 commits


01 Oct, 2018

2 commits

  • Currently, "disable_clkrun" yenta_socket module parameter is only
    implemented for TI CardBus bridges.
    Add also an implementation for Ricoh bridges that have the necessary
    setting documented in publicly available datasheets.

    Tested on a RL5C476II with a Sunrich C-160 CardBus NIC that doesn't work
    correctly unless the CLKRUN protocol is disabled.

    Let's also make it clear in its description that the "disable_clkrun"
    module parameter only works on these two previously mentioned brands of
    CardBus bridges.

    Signed-off-by: Maciej S. Szmigiero
    Cc: stable@vger.kernel.org
    Signed-off-by: Dominik Brodowski

    Maciej S. Szmigiero
     
  • pcmcia_fixup_iowidth() and pcmcia_enable_device() are
    never called in atomic context.
    They call mdelay() to busily wait, which is not necessary.
    mdelay() can be replaced with msleep().

    This is found by a static analysis tool named DCNS written by myself.

    Signed-off-by: Jia-Ju Bai
    Signed-off-by: Dominik Brodowski

    Jia-Ju Bai
     

13 Sep, 2018

2 commits

  • In order to make use of array info obtained from gpiod_get_array() and
    speed up processing of arrays matching single GPIO chip layout, that
    information must be passed to get/set array functions. Extend the
    functions' API with that additional parameter and update all users.
    Pass NULL if a user builds an array itself from single GPIOs.

    Cc: Jonathan Corbet
    Cc: Miguel Ojeda Sandonis
    Cc: Geert Uytterhoeven
    Cc: Sebastien Bourdelin
    Cc: Lukas Wunner
    Cc: Peter Korsgaard
    Cc: Peter Rosin
    Cc: Andrew Lunn
    Cc: Florian Fainelli
    Cc: "David S. Miller"
    Cc: Rojhalat Ibrahim
    Cc: Dominik Brodowski
    Cc: Russell King
    Cc: Kishon Vijay Abraham I
    Cc: Tony Lindgren
    Cc: Lars-Peter Clausen
    Cc: Michael Hennerich
    Cc: Jonathan Cameron
    Cc: Hartmut Knaack
    Cc: Peter Meerwald-Stadler
    Cc: Greg Kroah-Hartman
    Cc: Jiri Slaby
    Cc: Yegor Yefremov
    Cc: Uwe Kleine-König
    Signed-off-by: Janusz Krzysztofik
    Acked-by: Ulf Hansson
    Signed-off-by: Linus Walleij

    Janusz Krzysztofik
     
  • Most users of get/set array functions iterate consecutive bits of data,
    usually a single integer, while processing array of results obtained
    from, or building an array of values to be passed to those functions.
    Save time wasted on those iterations by changing the functions' API to
    accept bitmaps.

    All current users are updated as well.

    More benefits from the change are expected as soon as planned support
    for accepting/passing those bitmaps directly from/to respective GPIO
    chip callbacks if applicable is implemented.

    Cc: Jonathan Corbet
    Cc: Miguel Ojeda Sandonis
    Cc: Sebastien Bourdelin
    Cc: Lukas Wunner
    Cc: Peter Korsgaard
    Cc: Peter Rosin
    Cc: Andrew Lunn
    Cc: Florian Fainelli
    Cc: "David S. Miller"
    Cc: Rojhalat Ibrahim
    Cc: Dominik Brodowski
    Cc: Russell King
    Cc: Kishon Vijay Abraham I
    Cc: Tony Lindgren
    Cc: Lars-Peter Clausen
    Cc: Michael Hennerich
    Cc: Jonathan Cameron
    Cc: Hartmut Knaack
    Cc: Peter Meerwald-Stadler
    Cc: Greg Kroah-Hartman
    Cc: Jiri Slaby
    Cc: Yegor Yefremov
    Cc: Uwe Kleine-König
    Signed-off-by: Janusz Krzysztofik
    Acked-by: Ulf Hansson
    Reviewed-by: Geert Uytterhoeven
    Tested-by: Geert Uytterhoeven
    Signed-off-by: Linus Walleij

    Janusz Krzysztofik
     

19 Aug, 2018

1 commit

  • This function was created as a deprecated fallback case back in 2010 by
    commit eb14120f743d ("pcmcia: re-work pcmcia_request_irq()") for legacy
    cases.

    Actual in-kernel users haven't been around for a long while. The last
    in-kernel user was apparently removed four years ago by commit
    5f5316fcd08e ("am2150: Update nmclan_cs.c to use update PCMCIA API").

    Just remove it entirely.

    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

13 Jun, 2018

2 commits

  • The kzalloc() function has a 2-factor argument form, kcalloc(). This
    patch replaces cases of:

    kzalloc(a * b, gfp)

    with:
    kcalloc(a * b, gfp)

    as well as handling cases of:

    kzalloc(a * b * c, gfp)

    with:

    kzalloc(array3_size(a, b, c), gfp)

    as it's slightly less ugly than:

    kzalloc_array(array_size(a, b), c, gfp)

    This does, however, attempt to ignore constant size factors like:

    kzalloc(4 * 1024, gfp)

    though any constants defined via macros get caught up in the conversion.

    Any factors with a sizeof() of "unsigned char", "char", and "u8" were
    dropped, since they're redundant.

    The Coccinelle script used for this was:

    // Fix redundant parens around sizeof().
    @@
    type TYPE;
    expression THING, E;
    @@

    (
    kzalloc(
    - (sizeof(TYPE)) * E
    + sizeof(TYPE) * E
    , ...)
    |
    kzalloc(
    - (sizeof(THING)) * E
    + sizeof(THING) * E
    , ...)
    )

    // Drop single-byte sizes and redundant parens.
    @@
    expression COUNT;
    typedef u8;
    typedef __u8;
    @@

    (
    kzalloc(
    - sizeof(u8) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(__u8) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(char) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(unsigned char) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(u8) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(__u8) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(char) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(unsigned char) * COUNT
    + COUNT
    , ...)
    )

    // 2-factor product with sizeof(type/expression) and identifier or constant.
    @@
    type TYPE;
    expression THING;
    identifier COUNT_ID;
    constant COUNT_CONST;
    @@

    (
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (COUNT_ID)
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * COUNT_ID
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (COUNT_CONST)
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * COUNT_CONST
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (COUNT_ID)
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * COUNT_ID
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (COUNT_CONST)
    + COUNT_CONST, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * COUNT_CONST
    + COUNT_CONST, sizeof(THING)
    , ...)
    )

    // 2-factor product, only identifiers.
    @@
    identifier SIZE, COUNT;
    @@

    - kzalloc
    + kcalloc
    (
    - SIZE * COUNT
    + COUNT, SIZE
    , ...)

    // 3-factor product with 1 sizeof(type) or sizeof(expression), with
    // redundant parens removed.
    @@
    expression THING;
    identifier STRIDE, COUNT;
    type TYPE;
    @@

    (
    kzalloc(
    - sizeof(TYPE) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    )

    // 3-factor product with 2 sizeof(variable), with redundant parens removed.
    @@
    expression THING1, THING2;
    identifier COUNT;
    type TYPE1, TYPE2;
    @@

    (
    kzalloc(
    - sizeof(TYPE1) * sizeof(TYPE2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kzalloc(
    - sizeof(THING1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(THING1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    )

    // 3-factor product, only identifiers, with redundant parens removed.
    @@
    identifier STRIDE, SIZE, COUNT;
    @@

    (
    kzalloc(
    - (COUNT) * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    )

    // Any remaining multi-factor products, first at least 3-factor products,
    // when they're not all constants...
    @@
    expression E1, E2, E3;
    constant C1, C2, C3;
    @@

    (
    kzalloc(C1 * C2 * C3, ...)
    |
    kzalloc(
    - (E1) * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - (E1) * (E2) * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - (E1) * (E2) * (E3)
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - E1 * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    )

    // And then all remaining 2 factors products when they're not all constants,
    // keeping sizeof() as the second factor argument.
    @@
    expression THING, E1, E2;
    type TYPE;
    constant C1, C2, C3;
    @@

    (
    kzalloc(sizeof(THING) * C2, ...)
    |
    kzalloc(sizeof(TYPE) * C2, ...)
    |
    kzalloc(C1 * C2 * C3, ...)
    |
    kzalloc(C1 * C2, ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (E2)
    + E2, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * E2
    + E2, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (E2)
    + E2, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * E2
    + E2, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - (E1) * E2
    + E1, E2
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - (E1) * (E2)
    + E1, E2
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - E1 * E2
    + E1, E2
    , ...)
    )

    Signed-off-by: Kees Cook

    Kees Cook
     
  • The kmalloc() function has a 2-factor argument form, kmalloc_array(). This
    patch replaces cases of:

    kmalloc(a * b, gfp)

    with:
    kmalloc_array(a * b, gfp)

    as well as handling cases of:

    kmalloc(a * b * c, gfp)

    with:

    kmalloc(array3_size(a, b, c), gfp)

    as it's slightly less ugly than:

    kmalloc_array(array_size(a, b), c, gfp)

    This does, however, attempt to ignore constant size factors like:

    kmalloc(4 * 1024, gfp)

    though any constants defined via macros get caught up in the conversion.

    Any factors with a sizeof() of "unsigned char", "char", and "u8" were
    dropped, since they're redundant.

    The tools/ directory was manually excluded, since it has its own
    implementation of kmalloc().

    The Coccinelle script used for this was:

    // Fix redundant parens around sizeof().
    @@
    type TYPE;
    expression THING, E;
    @@

    (
    kmalloc(
    - (sizeof(TYPE)) * E
    + sizeof(TYPE) * E
    , ...)
    |
    kmalloc(
    - (sizeof(THING)) * E
    + sizeof(THING) * E
    , ...)
    )

    // Drop single-byte sizes and redundant parens.
    @@
    expression COUNT;
    typedef u8;
    typedef __u8;
    @@

    (
    kmalloc(
    - sizeof(u8) * (COUNT)
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(__u8) * (COUNT)
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(char) * (COUNT)
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(unsigned char) * (COUNT)
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(u8) * COUNT
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(__u8) * COUNT
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(char) * COUNT
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(unsigned char) * COUNT
    + COUNT
    , ...)
    )

    // 2-factor product with sizeof(type/expression) and identifier or constant.
    @@
    type TYPE;
    expression THING;
    identifier COUNT_ID;
    constant COUNT_CONST;
    @@

    (
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * (COUNT_ID)
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * COUNT_ID
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * (COUNT_CONST)
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * COUNT_CONST
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * (COUNT_ID)
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * COUNT_ID
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * (COUNT_CONST)
    + COUNT_CONST, sizeof(THING)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * COUNT_CONST
    + COUNT_CONST, sizeof(THING)
    , ...)
    )

    // 2-factor product, only identifiers.
    @@
    identifier SIZE, COUNT;
    @@

    - kmalloc
    + kmalloc_array
    (
    - SIZE * COUNT
    + COUNT, SIZE
    , ...)

    // 3-factor product with 1 sizeof(type) or sizeof(expression), with
    // redundant parens removed.
    @@
    expression THING;
    identifier STRIDE, COUNT;
    type TYPE;
    @@

    (
    kmalloc(
    - sizeof(TYPE) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kmalloc(
    - sizeof(THING) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kmalloc(
    - sizeof(THING) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kmalloc(
    - sizeof(THING) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kmalloc(
    - sizeof(THING) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    )

    // 3-factor product with 2 sizeof(variable), with redundant parens removed.
    @@
    expression THING1, THING2;
    identifier COUNT;
    type TYPE1, TYPE2;
    @@

    (
    kmalloc(
    - sizeof(TYPE1) * sizeof(TYPE2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kmalloc(
    - sizeof(THING1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kmalloc(
    - sizeof(THING1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    )

    // 3-factor product, only identifiers, with redundant parens removed.
    @@
    identifier STRIDE, SIZE, COUNT;
    @@

    (
    kmalloc(
    - (COUNT) * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - COUNT * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - COUNT * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - (COUNT) * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - COUNT * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - (COUNT) * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - (COUNT) * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - COUNT * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    )

    // Any remaining multi-factor products, first at least 3-factor products,
    // when they're not all constants...
    @@
    expression E1, E2, E3;
    constant C1, C2, C3;
    @@

    (
    kmalloc(C1 * C2 * C3, ...)
    |
    kmalloc(
    - (E1) * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kmalloc(
    - (E1) * (E2) * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kmalloc(
    - (E1) * (E2) * (E3)
    + array3_size(E1, E2, E3)
    , ...)
    |
    kmalloc(
    - E1 * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    )

    // And then all remaining 2 factors products when they're not all constants,
    // keeping sizeof() as the second factor argument.
    @@
    expression THING, E1, E2;
    type TYPE;
    constant C1, C2, C3;
    @@

    (
    kmalloc(sizeof(THING) * C2, ...)
    |
    kmalloc(sizeof(TYPE) * C2, ...)
    |
    kmalloc(C1 * C2 * C3, ...)
    |
    kmalloc(C1 * C2, ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * (E2)
    + E2, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * E2
    + E2, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * (E2)
    + E2, sizeof(THING)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * E2
    + E2, sizeof(THING)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - (E1) * E2
    + E1, E2
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - (E1) * (E2)
    + E1, E2
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - E1 * E2
    + E1, E2
    , ...)
    )

    Signed-off-by: Kees Cook

    Kees Cook
     

10 Apr, 2018

1 commit

  • Pull ARM SA1100 updates from Russell King:
    "We have support for arbitary MMIO registers providing platform GPIOs,
    which allows us to abstract some of the SA11x0 CF support.

    This set of updates makes that change"

    * 'for-linus-sa1100' of git://git.armlinux.org.uk/~rmk/linux-arm:
    ARM: sa1100/simpad: switch simpad CF to use gpiod APIs
    ARM: sa1100/shannon: convert to generic CF sockets
    ARM: sa1100/nanoengine: convert to generic CF sockets
    ARM: sa1100/h3xxx: switch h3xxx PCMCIA to use gpiod APIs
    ARM: sa1100/cerf: convert to generic CF sockets
    ARM: sa1100/assabet: convert to generic CF sockets
    ARM: sa1100: provide infrastructure to support generic CF sockets
    pcmcia: sa1100: provide generic CF support

    Linus Torvalds
     

06 Apr, 2018

3 commits


04 Apr, 2018

1 commit

  • Pull power management updates from Rafael Wysocki:
    "These update the cpuidle poll state definition to reduce excessive
    energy usage related to it, add new CPU ID to the RAPL power capping
    driver, update the ACPI system suspend code to handle some special
    cases better, extend the PM core's device links code slightly, add new
    sysfs attribute for better suspend-to-idle diagnostics and easier
    hibernation handling, update power management tools and clean up
    cpufreq quite a bit.

    Specifics:

    - Modify the cpuidle poll state implementation to prevent CPUs from
    staying in the loop in there for excessive times (Rafael Wysocki).

    - Add Intel Cannon Lake chips support to the RAPL power capping
    driver (Joe Konno).

    - Add reference counting to the device links handling code in the PM
    core (Lukas Wunner).

    - Avoid reconfiguring GPEs on suspend-to-idle in the ACPI system
    suspend code (Rafael Wysocki).

    - Allow devices to be put into deeper low-power states via ACPI if
    both _SxD and _SxW are missing (Daniel Drake).

    - Reorganize the core ACPI suspend-to-idle wakeup code to avoid a
    keyboard wakeup issue on Asus UX331UA (Chris Chiu).

    - Prevent the PCMCIA library code from aborting suspend-to-idle due
    to noirq suspend failures resulting from incorrect assumptions
    (Rafael Wysocki).

    - Add coupled cpuidle supprt to the Exynos3250 platform (Marek
    Szyprowski).

    - Add new sysfs file to make it easier to specify the image storage
    location during hibernation (Mario Limonciello).

    - Add sysfs files for collecting suspend-to-idle usage and time
    statistics for CPU idle states (Rafael Wysocki).

    - Update the pm-graph utilities (Todd Brandt).

    - Reduce the kernel log noise related to reporting Low-power Idle
    constraings by the ACPI system suspend code (Rafael Wysocki).

    - Make it easier to distinguish dedicated wakeup IRQs in the
    /proc/interrupts output (Tony Lindgren).

    - Add the frequency table validation in cpufreq to the core and drop
    it from a number of cpufreq drivers (Viresh Kumar).

    - Drop "cooling-{min|max}-level" for CPU nodes from a couple of DT
    bindings (Viresh Kumar).

    - Clean up the CPU online error code path in the cpufreq core (Viresh
    Kumar).

    - Fix assorted issues in the SCPI, CPPC, mediatek and tegra186
    cpufreq drivers (Arnd Bergmann, Chunyu Hu, George Cherian, Viresh
    Kumar).

    - Drop memory allocation error messages from a few places in cpufreq
    and cpuildle drivers (Markus Elfring)"

    * tag 'pm-4.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (56 commits)
    ACPI / PM: Fix keyboard wakeup from suspend-to-idle on ASUS UX331UA
    cpufreq: CPPC: Use transition_delay_us depending transition_latency
    PM / hibernate: Change message when writing to /sys/power/resume
    PM / hibernate: Make passing hibernate offsets more friendly
    cpuidle: poll_state: Avoid invoking local_clock() too often
    PM: cpuidle/suspend: Add s2idle usage and time state attributes
    cpuidle: Enable coupled cpuidle support on Exynos3250 platform
    cpuidle: poll_state: Add time limit to poll_idle()
    cpufreq: tegra186: Don't validate the frequency table twice
    cpufreq: speedstep: Don't validate the frequency table twice
    cpufreq: sparc: Don't validate the frequency table twice
    cpufreq: sh: Don't validate the frequency table twice
    cpufreq: sfi: Don't validate the frequency table twice
    cpufreq: scpi: Don't validate the frequency table twice
    cpufreq: sc520: Don't validate the frequency table twice
    cpufreq: s3c24xx: Don't validate the frequency table twice
    cpufreq: qoirq: Don't validate the frequency table twice
    cpufreq: pxa: Don't validate the frequency table twice
    cpufreq: ppc_cbe: Don't validate the frequency table twice
    cpufreq: powernow: Don't validate the frequency table twice
    ...

    Linus Torvalds
     

26 Mar, 2018

2 commits


24 Mar, 2018

1 commit