18 Sep, 2019

1 commit

  • Pull documentation updates from Jonathan Corbet:
    "It's a somewhat calmer cycle for docs this time, as the churn of the
    mass RST conversion is happily mostly behind us.

    - A new document on reproducible builds.

    - We finally got around to zapping the documentation for hardware
    support that was removed in 2004; one doesn't want to rush these
    things.

    - The usual assortment of fixes, typo corrections, etc"

    * tag 'docs-5.4' of git://git.lwn.net/linux: (67 commits)
    Documentation: kbuild: Add document about reproducible builds
    docs: printk-formats: Stop encouraging use of unnecessary %h[xudi] and %hh[xudi]
    Documentation: Add "earlycon=sbi" to the admin guide
    doc:lock: remove reference to clever use of read-write lock
    devices.txt: improve entry for comedi (char major 98)
    docs: mtd: Update spi nor reference driver
    doc: arm64: fix grammar dtb placed in no attributes region
    Documentation: sysrq: don't recommend 'S' 'U' before 'B'
    mailmap: Update email address for Quentin Perret
    docs: ftrace: clarify when tracing is disabled by the trace file
    docs: process: fix broken link
    Documentation/arm/samsung-s3c24xx: Remove stray U+FEFF character to fix title
    Documentation/arm/sa1100/assabet: Fix 'make assabet_defconfig' command
    Documentation/arm/sa1100: Remove some obsolete documentation
    docs/zh_CN: update Chinese howto.rst for latexdocs making
    Documentation: virt: Fix broken reference to virt tree's index
    docs: Fix typo on pull requests guide
    kernel-doc: Allow anonymous enum
    Documentation: sphinx: Don't parse socket() as identifier reference
    Documentation: sphinx: Add missing comma to list of strings
    ...

    Linus Torvalds
     

20 Aug, 2019

1 commit


09 Aug, 2019

2 commits


06 Aug, 2019

2 commits


01 Aug, 2019

1 commit


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
     

20 Jun, 2019

2 commits

  • While using mmap, the incorrect values of length and vm_pgoff are
    ignored and this driver goes ahead with mapping fbdev.buffer
    to user vma.

    Convert vm_insert_pages() to use vm_map_pages_zero(). We could later
    "fix" these drivers to behave according to the normal vm_pgoff
    offsetting simply by removing the _zero suffix on the function name
    and if that causes regressions, it gives us an easy way to revert.

    Signed-off-by: Souptick Joarder
    Acked-by: Robin van der Gracht
    Signed-off-by: Miguel Ojeda

    Souptick Joarder
     
  • While using mmap, the incorrect values of length and vm_pgoff are
    ignored and this driver goes ahead with mapping cfag12864b_buffer
    to user vma.

    Convert vm_insert_pages() to use vm_map_pages_zero(). We could later
    "fix" these drivers to behave according to the normal vm_pgoff
    offsetting simply by removing the _zero suffix on the function name and
    if that causes regressions, it gives us an easy way to revert.

    Signed-off-by: Souptick Joarder
    Signed-off-by: Miguel Ojeda

    Souptick Joarder
     

15 Jun, 2019

1 commit

  • The kbuild documentation clearly shows that the documents
    there are written at different times: some use markdown,
    some use their own peculiar logic to split sections.

    Convert everything to ReST without affecting too much
    the author's style and avoiding adding uneeded markups.

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

    Mauro Carvalho Chehab
     

31 May, 2019

1 commit

  • 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
     

17 Mar, 2019

8 commits


16 Feb, 2019

1 commit

  • On module unload/remove, we need to ensure that work does not run
    after we have freed resources. Concretely, cancel_delayed_work()
    may return while the callback function is still running.

    From kernel/workqueue.c:

    The work callback function may still be running on return,
    unless it returns true and the work doesn't re-arm itself.
    Explicitly flush or use cancel_delayed_work_sync() to wait on it.

    Link: https://lore.kernel.org/lkml/20190204220952.30761-1-TheSven73@googlemail.com/
    Reported-by: Sven Van Asbroeck
    Reviewed-by: Dmitry Torokhov
    Reviewed-by: Sven Van Asbroeck
    Acked-by: Robin van der Gracht
    Signed-off-by: Miguel Ojeda

    Miguel Ojeda
     

22 Dec, 2018

1 commit

  • The x/y command parsing has been broken since commit 129957069e6a
    ("staging: panel: Fixed checkpatch warning about simple_strtoul()").

    Commit b34050fadb86 ("auxdisplay: charlcd: Fix and clean up handling of
    x/y commands") fixed some problems by rewriting the parsing code,
    but also broke things further by removing the check for a complete
    command before attempting to parse it. As a result, parsing is
    terminated at the first x or y character.

    This reinstates the check for a final semicolon. Whereas the original
    code use strchr(), this is wasteful seeing as the semicolon is always
    at the end of the buffer. Thus check this character directly instead.

    Signed-off-by: Mans Rullgard
    Signed-off-by: Miguel Ojeda

    Mans Rullgard
     

02 Nov, 2018

1 commit

  • Pull compiler attribute updates from Miguel Ojeda:
    "This is an effort to disentangle the include/linux/compiler*.h headers
    and bring them up to date.

    The main idea behind the series is to use feature checking macros
    (i.e. __has_attribute) instead of compiler version checks (e.g.
    GCC_VERSION), which are compiler-agnostic (so they can be shared,
    reducing the size of compiler-specific headers) and version-agnostic.

    Other related improvements have been performed in the headers as well,
    which on top of the use of __has_attribute it has amounted to a
    significant simplification of these headers (e.g. GCC_VERSION is now
    only guarding a few non-attribute macros).

    This series should also help the efforts to support compiling the
    kernel with clang and icc. A fair amount of documentation and comments
    have also been added, clarified or removed; and the headers are now
    more readable, which should help kernel developers in general.

    The series was triggered due to the move to gcc >= 4.6. In turn, this
    series has also triggered Sparse to gain the ability to recognize
    __has_attribute on its own.

    Finally, the __nonstring variable attribute series has been also
    applied on top; plus two related patches from Nick Desaulniers for
    unreachable() that came a bit afterwards"

    * tag 'compiler-attributes-for-linus-4.20-rc1' of https://github.com/ojeda/linux:
    compiler-gcc: remove comment about gcc 4.5 from unreachable()
    compiler.h: update definition of unreachable()
    Compiler Attributes: ext4: remove local __nonstring definition
    Compiler Attributes: auxdisplay: panel: use __nonstring
    Compiler Attributes: enable -Wstringop-truncation on W=1 (gcc >= 8)
    Compiler Attributes: add support for __nonstring (gcc >= 8)
    Compiler Attributes: add MAINTAINERS entry
    Compiler Attributes: add Doc/process/programming-language.rst
    Compiler Attributes: remove uses of __attribute__ from compiler.h
    Compiler Attributes: KENTRY used twice the "used" attribute
    Compiler Attributes: use feature checks instead of version checks
    Compiler Attributes: add missing SPDX ID in compiler_types.h
    Compiler Attributes: remove unneeded sparse (__CHECKER__) tests
    Compiler Attributes: homogenize __must_be_array
    Compiler Attributes: remove unneeded tests
    Compiler Attributes: always use the extra-underscores syntax
    Compiler Attributes: remove unused attributes

    Linus Torvalds
     

01 Oct, 2018

1 commit

  • Let gcc know these arrays are not meant to be NUL-terminated
    by annotating them with the new __nonstring variable attribute;
    and remove the comment since it conveys the same information.

    Tested-by: Sedat Dilek # on top of v4.19-rc5, clang 7
    Reviewed-by: Nick Desaulniers
    Reviewed-by: Luc Van Oostenryck
    Signed-off-by: Miguel Ojeda

    Miguel Ojeda
     

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

  • Pull char/misc driver updates from Greg KH:
    "Here is the bit set of char/misc drivers for 4.19-rc1

    There is a lot here, much more than normal, seems like everyone is
    writing new driver subsystems these days... Anyway, major things here
    are:

    - new FSI driver subsystem, yet-another-powerpc low-level hardware
    bus

    - gnss, finally an in-kernel GPS subsystem to try to tame all of the
    crazy out-of-tree drivers that have been floating around for years,
    combined with some really hacky userspace implementations. This is
    only for GNSS receivers, but you have to start somewhere, and this
    is great to see.

    Other than that, there are new slimbus drivers, new coresight drivers,
    new fpga drivers, and loads of DT bindings for all of these and
    existing drivers.

    All of these have been in linux-next for a while with no reported
    issues"

    * tag 'char-misc-4.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (255 commits)
    android: binder: Rate-limit debug and userspace triggered err msgs
    fsi: sbefifo: Bump max command length
    fsi: scom: Fix NULL dereference
    misc: mic: SCIF Fix scif_get_new_port() error handling
    misc: cxl: changed asterisk position
    genwqe: card_base: Use true and false for boolean values
    misc: eeprom: assignment outside the if statement
    uio: potential double frees if __uio_register_device() fails
    eeprom: idt_89hpesx: clean up an error pointer vs NULL inconsistency
    misc: ti-st: Fix memory leak in the error path of probe()
    android: binder: Show extra_buffers_size in trace
    firmware: vpd: Fix section enabled flag on vpd_section_destroy
    platform: goldfish: Retire pdev_bus
    goldfish: Use dedicated macros instead of manual bit shifting
    goldfish: Add missing includes to goldfish.h
    mux: adgs1408: new driver for Analog Devices ADGS1408/1409 mux
    dt-bindings: mux: add adi,adgs1408
    Drivers: hv: vmbus: Cleanup synic memory free path
    Drivers: hv: vmbus: Remove use of slow_virt_to_phys()
    Drivers: hv: vmbus: Reset the channel callback in vmbus_onoffer_rescind()
    ...

    Linus Torvalds
     

02 Aug, 2018

2 commits

  • We should get drvdata from struct device directly. Going via
    platform_device is an unneeded step back and forth.

    Signed-off-by: Wolfram Sang
    Acked-by: Linus Walleij
    Signed-off-by: Miguel Ojeda

    Wolfram Sang
     
  • The function long_sleep() calls mdelay() when in an interrupt handler.
    But only charlcd_clear_display() and charlcd_init_display calls
    long_sleep(), and my tool finds that the two functions
    are never called in an interrupt handler.
    Thus mdelay() and in_interrupt() are not necessary.

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

    Signed-off-by: Jia-Ju Bai
    Acked-by: Willy Tarreau
    Signed-off-by: Miguel Ojeda

    Jia-Ju Bai
     

07 Jul, 2018

1 commit

  • At over 4000 #includes, is the 9th most
    #included header file in the Linux kernel. It does not need
    , so drop that header and explicitly add
    to source files that need it.

    4146 #include

    After this patch, there are 225 files that use ,
    for a reduction of around 3900 times that
    does not have to be read & parsed.

    225 #include

    This patch was build-tested on 20 different arch-es.

    It also makes these drivers SubmitChecklist#1 compliant.

    Signed-off-by: Randy Dunlap
    Reported-by: kbuild test robot # drivers/media/platform/vimc/
    Reported-by: kbuild test robot # drivers/pinctrl/pinctrl-u300.c
    Signed-off-by: Greg Kroah-Hartman

    Randy Dunlap
     

13 Jun, 2018

1 commit

  • 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
     

13 Apr, 2018

9 commits