16 Apr, 2018

2 commits

  • Pull more Kbuild updates from Masahiro Yamada:

    - pass HOSTLDFLAGS when compiling single .c host programs

    - build genksyms lexer and parser files instead of using shipped
    versions

    - rename *-asn1.[ch] to *.asn1.[ch] for suffix consistency

    - let the top .gitignore globally ignore artifacts generated by flex,
    bison, and asn1_compiler

    - let the top Makefile globally clean artifacts generated by flex,
    bison, and asn1_compiler

    - use safer .SECONDARY marker instead of .PRECIOUS to prevent
    intermediate files from being removed

    - support -fmacro-prefix-map option to make __FILE__ a relative path

    - fix # escaping to prepare for the future GNU Make release

    - clean up deb-pkg by using debian tools instead of handrolled
    source/changes generation

    - improve rpm-pkg portability by supporting kernel-install as a
    fallback of new-kernel-pkg

    - extend Kconfig listnewconfig target to provide more information

    * tag 'kbuild-v4.17-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
    kconfig: extend output of 'listnewconfig'
    kbuild: rpm-pkg: use kernel-install as a fallback for new-kernel-pkg
    Kbuild: fix # escaping in .cmd files for future Make
    kbuild: deb-pkg: split generating packaging and build
    kbuild: use -fmacro-prefix-map to make __FILE__ a relative path
    kbuild: mark $(targets) as .SECONDARY and remove .PRECIOUS markers
    kbuild: rename *-asn1.[ch] to *.asn1.[ch]
    kbuild: clean up *-asn1.[ch] patterns from top-level Makefile
    .gitignore: move *-asn1.[ch] patterns to the top-level .gitignore
    kbuild: add %.dtb.S and %.dtb to 'targets' automatically
    kbuild: add %.lex.c and %.tab.[ch] to 'targets' automatically
    genksyms: generate lexer and parser during build instead of shipping
    kbuild: clean up *.lex.c and *.tab.[ch] patterns from top-level Makefile
    .gitignore: move *.lex.c *.tab.[ch] patterns to the top-level .gitignore
    kbuild: use HOSTLDFLAGS for single .c executables

    Linus Torvalds
     
  • Pull x86 fixes from Thomas Gleixner:
    "A set of fixes and updates for x86:

    - Address a swiotlb regression which was caused by the recent DMA
    rework and made driver fail because dma_direct_supported() returned
    false

    - Fix a signedness bug in the APIC ID validation which caused invalid
    APIC IDs to be detected as valid thereby bloating the CPU possible
    space.

    - Fix inconsisten config dependcy/select magic for the MFD_CS5535
    driver.

    - Fix a corruption of the physical address space bits when encryption
    has reduced the address space and late cpuinfo updates overwrite
    the reduced bit information with the original value.

    - Dominiks syscall rework which consolidates the architecture
    specific syscall functions so all syscalls can be wrapped with the
    same macros. This allows to switch x86/64 to struct pt_regs based
    syscalls. Extend the clearing of user space controlled registers in
    the entry patch to the lower registers"

    * 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
    x86/apic: Fix signedness bug in APIC ID validity checks
    x86/cpu: Prevent cpuinfo_x86::x86_phys_bits adjustment corruption
    x86/olpc: Fix inconsistent MFD_CS5535 configuration
    swiotlb: Use dma_direct_supported() for swiotlb_ops
    syscalls/x86: Adapt syscall_wrapper.h to the new syscall stub naming convention
    syscalls/core, syscalls/x86: Rename struct pt_regs-based sys_*() to __x64_sys_*()
    syscalls/core, syscalls/x86: Clean up compat syscall stub naming convention
    syscalls/core, syscalls/x86: Clean up syscall stub naming convention
    syscalls/x86: Extend register clearing on syscall entry to lower registers
    syscalls/x86: Unconditionally enable 'struct pt_regs' based syscalls on x86_64
    syscalls/x86: Use 'struct pt_regs' based syscall calling for IA32_EMULATION and x32
    syscalls/core: Prepare CONFIG_ARCH_HAS_SYSCALL_WRAPPER=y for compat syscalls
    syscalls/x86: Use 'struct pt_regs' based syscall calling convention for 64-bit syscalls
    syscalls/core: Introduce CONFIG_ARCH_HAS_SYSCALL_WRAPPER=y
    x86/syscalls: Don't pointlessly reload the system call number
    x86/mm: Fix documentation of module mapping range with 4-level paging
    x86/cpuid: Switch to 'static const' specifier

    Linus Torvalds
     

13 Apr, 2018

3 commits

  • We at Red Hat/Fedora have generally tried to have a per file breakdown of
    every config option we set. This makes it easy for us to add new options
    when they are exposed and keep a changelog of why they were set.

    A Fedora example is here:
    https://src.fedoraproject.org/cgit/rpms/kernel.git/tree/configs/fedora/generic

    Using various merge scripts, we build up a config file and run it through
    'make listnewconfig' and 'make oldnoconfig'. The idea is to print out new
    config options that haven't been manually set and use the default until
    a patch is posted to set it properly.

    To speed things up, it would be nice to make it easier to generate a
    patch to post the default setting. The output of 'make listnewconfig'
    has two issues that limit us:

    - it doesn't provide the default value
    - it doesn't provide the new 'choice' options that get flagged in
    'oldconfig'

    This patch extends 'listnewconfig' to address the above two issues.

    This allows us to run a script

    make listnewconfig | rhconfig-tool -o patches; git send-email patches/

    The output of 'make listnewconfig':

    CONFIG_NET_EMATCH_IPT
    CONFIG_IPVLAN
    CONFIG_ICE
    CONFIG_NET_VENDOR_NI
    CONFIG_IEEE802154_MCR20A
    CONFIG_IR_IMON_DECODER
    CONFIG_IR_IMON_RAW

    The new output of 'make listnewconfig':

    CONFIG_KERNEL_XZ=n
    CONFIG_KERNEL_LZO=n
    CONFIG_NET_EMATCH_IPT=n
    CONFIG_IPVLAN=n
    CONFIG_ICE=n
    CONFIG_NET_VENDOR_NI=y
    CONFIG_IEEE802154_MCR20A=n
    CONFIG_IR_IMON_DECODER=n
    CONFIG_IR_IMON_RAW=n

    Signed-off-by: Don Zickus
    Signed-off-by: Masahiro Yamada

    Don Zickus
     
  • The new-kernel-pkg script is only present when grubby is installed, but it
    may not always be the case. So if the script isn't present, attempt to use
    the kernel-install script as a fallback instead.

    Signed-off-by: Javier Martinez Canillas
    Signed-off-by: Masahiro Yamada

    Javier Martinez Canillas
     
  • Pull asm-generic fixes from Arnd Bergmann:
    "I have one regression fix for a minor build problem after the
    architecture removal series, plus a rework of the barriers in the
    readl/writel functions, thanks to work by Sinan Kaya:

    This started from a discussion on the linuxpcc and rdma mailing
    lists[1]. To summarize, we decided that architectures are responsible
    to serialize readl() and writel() accesses on a device MMIO space
    relative to DMA performed by that device.

    This series provides a pessimistic implementation of that behavior for
    asm-generic/io.h, which is in turn used by a number of architectures
    (h8300, microblaze, nios2, openrisc, s390, sparc, um, unicore32, and
    xtensa). Some of those presumably need no extra barriers, or something
    weaker than rmb()/wmb(), and they are advised to override the new
    default for better performance.

    For inb()/outb(), the same barriers are used, but architectures might
    want to add another barrier to outb() here if that can guarantee
    non-posted behavior (some architectures can, others cannot do that).

    The readl_relaxed()/writel_relaxed() family of functions retains the
    existing behavior with no extra barriers"

    [1] https://lists.ozlabs.org/pipermail/linuxppc-dev/2018-March/170481.html

    * tag 'asm-generic' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic:
    io: change writeX_relaxed() to remove barriers
    io: change readX_relaxed() to remove barriers
    dts: remove cris & metag dts hard link file
    io: change inX() to have their own IO barrier overrides
    io: change outX() to have their own IO barrier overrides
    io: define stronger ordering for the default writeX() implementation
    io: define stronger ordering for the default readX() implementation
    io: define several IO & PIO barrier types for the asm-generic version

    Linus Torvalds
     

12 Apr, 2018

13 commits

  • Using bool in a bitfield isn't a good idea as the alignment behavior is
    arch implementation defined.

    Suggest using unsigned int or u instead.

    Link: http://lkml.kernel.org/r/e22fb871b1b7f2fda4b22f3a24e0d7f092eb612c.camel@perches.com
    Signed-off-by: Joe Perches
    Suggested-by: Peter Zijlstra
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • Allow a space between a colon and subsequent opening bracket. This
    sequence may occur in inline assembler statements like

    asm(
    "ldr %[out], [%[in]]\n\t"
    : [out] "=r" (ret)
    : [in] "r" (addr)
    );

    Link: http://lkml.kernel.org/r/20180403191655.23700-1-xypron.glpk@gmx.de
    Signed-off-by: Heinrich Schuchardt
    Acked-by: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Heinrich Schuchardt
     
  • Kernel style seems to prefer line wrapping an assignment with the
    assignment operator on the previous line like:

    identifier =
    expression;
    over
    identifier
    = expression;

    somewhere around a 50:1 ratio

    $ git grep -P "[^=]=\s*$" -- "*.[ch]" | wc -l
    52008
    $ git grep -P "^\s+[\*\/\+\|\%\-]?=[^=>]" | wc -l
    1161

    So add a --strict test for that condition.

    Link: http://lkml.kernel.org/r/1522275726.2210.12.camel@perches.com
    Signed-off-by: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • There are occasions where symbolic perms are used in a ternary like

    return (channel == 0) ? S_IRUGO | S_IWUSR : S_IRUGO;

    The current test will find the first use "S_IRUGO | S_IWUSR" but not the
    second use "S_IRUGO" on the same line.

    Improve the test to look for all instances on a line.

    Link: http://lkml.kernel.org/r/1522127944.12357.49.camel@perches.com
    Signed-off-by: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • completly -> completely
    wacking -> whacking

    Link: http://lkml.kernel.org/r/1520405394-5586-1-git-send-email-claudio.fontana@gliwa.com
    Signed-off-by: Claudio Fontana
    Acked-by: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Claudio Fontana
     
  • The get_quoted_string function does not expect invalid arguments.

    The $stat test can return non-statements for complicated macros like
    TRACE_EVENT.

    Allow the $stat block and test for vsprintf misuses to exceed the actual
    block length and possibly test invalid lines by validating the arguments
    of get_quoted_string.

    Return "" if either get_quoted_string argument is undefined.

    Miscellanea:

    o Properly align the comment for the vsprintf extension test

    Link: http://lkml.kernel.org/r/9e9725342ca3dfc0f5e3e0b8ca3c482b0e5712cc.1520356392.git.joe@perches.com
    Signed-off-by: Joe Perches
    Reported-by: Chuck Lever
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • Usage of the new %px specifier potentially leaks sensitive information.
    Printing kernel addresses exposes the kernel layout in memory, this is
    potentially exploitable. We have tools in the kernel to help us do the
    right thing. We can have checkpatch warn developers of potential
    dangers of using %px.

    Have checkpatch emit a warning for usage of specifier %px.

    Link: http://lkml.kernel.org/r/1519700648-23108-5-git-send-email-me@tobin.cc
    Signed-off-by: Tobin C. Harding
    Signed-off-by: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tobin C. Harding
     
  • checkpatch currently contains duplicate code. We can define a sub
    routine and call that instead. This reduces code duplication and line
    count.

    Add subroutine get_stat_here().

    Link: http://lkml.kernel.org/r/1519700648-23108-4-git-send-email-me@tobin.cc
    Signed-off-by: Tobin C. Harding
    Cc: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tobin C. Harding
     
  • Variables are declared and not used, we should remove them.

    Link: http://lkml.kernel.org/r/1519700648-23108-3-git-send-email-me@tobin.cc
    Signed-off-by: Tobin C. Harding
    Cc: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tobin C. Harding
     
  • checkpatch currently contains duplicate code. We can define a sub
    routine and call that instead. This reduces code duplication and line
    count.

    Add subroutine get_stat_real()

    Link: http://lkml.kernel.org/r/1519700648-23108-2-git-send-email-me@tobin.cc
    Signed-off-by: Tobin C. Harding
    Cc: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tobin C. Harding
     
  • Add the crypto API *_ON_STACK to $declaration_macros.

    Resolves the following false warning:

    WARNING: Missing a blank line after declarations
    + int err;
    + SHASH_DESC_ON_STACK(desc, ctx_p->shash_tfm);

    Link: http://lkml.kernel.org/r/1518941636-4484-1-git-send-email-gilad@benyossef.com
    Signed-off-by: Gilad Ben-Yossef
    Signed-off-by: Joe Perches
    Acked-by: Greg Kroah-Hartman
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Gilad Ben-Yossef
     
  • Add SPDX license tag check based on the rules defined in
    Documentation/process/license-rules.rst. To summarize, SPDX license
    tags should be on the 1st line (or 2nd line in scripts) using the
    appropriate comment style for the file type.

    Link: http://lkml.kernel.org/r/20180202154026.15298-1-robh@kernel.org
    Signed-off-by: Rob Herring
    Signed-off-by: Joe Perches
    Acked-by: Greg Kroah-Hartman
    Acked-by: Philippe Ombredanne
    Cc: Andy Whitcroft
    Cc: Joe Perches
    Cc: Thomas Gleixner
    Cc: Igor Stoppa
    Cc: Jonathan Corbet
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rob Herring
     
  • Bare email addresses with non alphanumeric characters require escape
    quoting before being substituted in the parse_email routine.

    e.g. Reported-by: syzbot+bbd8e9a06452cc48059b@syzkaller.appspotmail.com

    Do so.

    Link: http://lkml.kernel.org/r/1518631805.3678.12.camel@perches.com
    Signed-off-by: Joe Perches
    Cc: Dmitry Vyukov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     

10 Apr, 2018

1 commit

  • I tried building using a freshly built Make (4.2.1-69-g8a731d1), but
    already the objtool build broke with

    orc_dump.c: In function ‘orc_dump’:
    orc_dump.c:106:2: error: ‘elf_getshnum’ is deprecated [-Werror=deprecated-declarations]
    if (elf_getshdrnum(elf, &nr_sections)) {

    Turns out that with that new Make, the backslash was not removed, so cpp
    didn't see a #include directive, grep found nothing, and
    -DLIBELF_USE_DEPRECATED was wrongly put in CFLAGS.

    Now, that new Make behaviour is documented in their NEWS file:

    * WARNING: Backward-incompatibility!
    Number signs (#) appearing inside a macro reference or function invocation
    no longer introduce comments and should not be escaped with backslashes:
    thus a call such as:
    foo := $(shell echo '#')
    is legal. Previously the number sign needed to be escaped, for example:
    foo := $(shell echo '\#')
    Now this latter will resolve to "\#". If you want to write makefiles
    portable to both versions, assign the number sign to a variable:
    C := \#
    foo := $(shell echo '$C')
    This was claimed to be fixed in 3.81, but wasn't, for some reason.
    To detect this change search for 'nocomment' in the .FEATURES variable.

    This also fixes up the two make-cmd instances to replace # with $(pound)
    rather than with \#. There might very well be other places that need
    similar fixup in preparation for whatever future Make release contains
    the above change, but at least this builds an x86_64 defconfig with the
    new make.

    Link: https://bugzilla.kernel.org/show_bug.cgi?id=197847
    Cc: Randy Dunlap
    Signed-off-by: Rasmus Villemoes
    Signed-off-by: Masahiro Yamada

    Rasmus Villemoes
     

09 Apr, 2018

2 commits

  • Tidy the naming convention for compat syscall subs. Hints which describe
    the purpose of the stub go in front and receive a double underscore to
    denote that they are generated on-the-fly by the COMPAT_SYSCALL_DEFINEx()
    macro.

    For the generic case, this means:

    t kernel_waitid # common C function (see kernel/exit.c)

    __do_compat_sys_waitid # inlined helper doing the actual work
    # (takes original parameters as declared)

    T __se_compat_sys_waitid # sign-extending C function calling inlined
    # helper (takes parameters of type long,
    # casts them to unsigned long and then to
    # the declared type)

    T compat_sys_waitid # alias to __se_compat_sys_waitid()
    # (taking parameters as declared), to
    # be included in syscall table

    For x86, the naming is as follows:

    t kernel_waitid # common C function (see kernel/exit.c)

    __do_compat_sys_waitid # inlined helper doing the actual work
    # (takes original parameters as declared)

    t __se_compat_sys_waitid # sign-extending C function calling inlined
    # helper (takes parameters of type long,
    # casts them to unsigned long and then to
    # the declared type)

    T __ia32_compat_sys_waitid # IA32_EMULATION 32-bit-ptregs -> C stub,
    # calls __se_compat_sys_waitid(); to be
    # included in syscall table

    T __x32_compat_sys_waitid # x32 64-bit-ptregs -> C stub, calls
    # __se_compat_sys_waitid(); to be included
    # in syscall table

    If only one of IA32_EMULATION and x32 is enabled, __se_compat_sys_waitid()
    may be inlined into the stub __{ia32,x32}_compat_sys_waitid().

    Suggested-by: Ingo Molnar
    Signed-off-by: Dominik Brodowski
    Cc: Al Viro
    Cc: Andrew Morton
    Cc: Andy Lutomirski
    Cc: Borislav Petkov
    Cc: Brian Gerst
    Cc: Denys Vlasenko
    Cc: Josh Poimboeuf
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/20180409105145.5364-3-linux@dominikbrodowski.net
    Signed-off-by: Ingo Molnar

    Dominik Brodowski
     
  • Tidy the naming convention for compat syscall subs. Hints which describe
    the purpose of the stub go in front and receive a double underscore to
    denote that they are generated on-the-fly by the SYSCALL_DEFINEx() macro.

    For the generic case, this means (0xffffffff prefix removed):

    810f08d0 t kernel_waitid # common C function (see kernel/exit.c)

    __do_sys_waitid # inlined helper doing the actual work
    # (takes original parameters as declared)

    810f1aa0 T __se_sys_waitid # sign-extending C function calling inlined
    # helper (takes parameters of type long;
    # casts them to the declared type)

    810f1aa0 T sys_waitid # alias to __se_sys_waitid() (taking
    # parameters as declared), to be included
    # in syscall table

    For x86, the naming is as follows:

    810efc70 t kernel_waitid # common C function (see kernel/exit.c)

    __do_sys_waitid # inlined helper doing the actual work
    # (takes original parameters as declared)

    810efd60 t __se_sys_waitid # sign-extending C function calling inlined
    # helper (takes parameters of type long;
    # casts them to the declared type)

    810f1140 T __ia32_sys_waitid # IA32_EMULATION 32-bit-ptregs -> C stub,
    # calls __se_sys_waitid(); to be included
    # in syscall table

    810f1110 T sys_waitid # x86 64-bit-ptregs -> C stub, calls
    # __se_sys_waitid(); to be included in
    # syscall table

    For x86, sys_waitid() will be re-named to __x64_sys_waitid in a follow-up
    patch.

    Suggested-by: Ingo Molnar
    Signed-off-by: Dominik Brodowski
    Cc: Al Viro
    Cc: Andrew Morton
    Cc: Andy Lutomirski
    Cc: Borislav Petkov
    Cc: Brian Gerst
    Cc: Denys Vlasenko
    Cc: Josh Poimboeuf
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/20180409105145.5364-2-linux@dominikbrodowski.net
    Signed-off-by: Ingo Molnar

    Dominik Brodowski
     

08 Apr, 2018

2 commits

  • Pull leaking-addresses updates from Tobin Harding:
    "This set represents improvements to the scripts/leaking_addresses.pl
    script.

    The major improvement is that with this set applied the script
    actually runs in a reasonable amount of time (less than a minute on a
    standard stock Ubuntu user desktop). Also, we have a second maintainer
    now and a tree hosted on kernel.org

    We do a few code clean ups. We fix the command help output. Handling
    of the vsyscall address range is fixed to check the whole range
    instead of just the start/end addresses. We add support for 5 page
    table levels (suggested on LKML). We use a system command to get the
    machine architecture instead of using Perl. Calling this command for
    every regex comparison is what previously choked the script, caching
    the result of this call gave the major speed improvement. We add
    support for scanning 32-bit kernels using the user/kernel memory
    split. Path skipping code refactored and simplified (meaning easier
    script configuration). We remove version numbering. We add a variable
    name to improve readability of a regex and finally we check filenames
    for leaking addresses.

    Currently script scans /proc/PID for all PID. With this set applied we
    only scan for PID==1. It was observed that on an idle system files
    under /proc/PID are predominantly the same for all processes. Also it
    was noted that the script does not scan _all_ the kernel since it only
    scans active processes. Scanning only for PID==1 makes explicit the
    inherent flaw in the script that the scan is only partial and also
    speeds things up"

    * tag 'leaks-4.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tobin/leaks:
    MAINTAINERS: Update LEAKING_ADDRESSES
    leaking_addresses: check if file name contains address
    leaking_addresses: explicitly name variable used in regex
    leaking_addresses: remove version number
    leaking_addresses: skip '/proc/1/syscall'
    leaking_addresses: skip all /proc/PID except /proc/1
    leaking_addresses: cache architecture name
    leaking_addresses: simplify path skipping
    leaking_addresses: do not parse binary files
    leaking_addresses: add 32-bit support
    leaking_addresses: add is_arch() wrapper subroutine
    leaking_addresses: use system command to get arch
    leaking_addresses: add support for 5 page table levels
    leaking_addresses: add support for kernel config file
    leaking_addresses: add range check for vsyscall memory
    leaking_addresses: indent dependant options
    leaking_addresses: remove command examples
    leaking_addresses: remove mention of kptr_restrict
    leaking_addresses: fix typo function not called

    Linus Torvalds
     
  • Pull general security layer updates from James Morris:

    - Convert security hooks from list to hlist, a nice cleanup, saving
    about 50% of space, from Sargun Dhillon.

    - Only pass the cred, not the secid, to kill_pid_info_as_cred and
    security_task_kill (as the secid can be determined from the cred),
    from Stephen Smalley.

    - Close a potential race in kernel_read_file(), by making the file
    unwritable before calling the LSM check (vs after), from Kees Cook.

    * 'next-general' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security:
    security: convert security hooks to use hlist
    exec: Set file unwritable before LSM check
    usb, signal, security: only pass the cred, not the secid, to kill_pid_info_as_cred and security_task_kill

    Linus Torvalds
     

07 Apr, 2018

17 commits

  • Move debian/ directory generation out of builddeb to a new script,
    mkdebian. The package build commands are kept in builddeb, which
    is now an internal command called from debian/rules.

    With these changes in place, we can now use dpkg-buildpackage from
    deb-pkg and bindeb-pkg removing need for handrolled source/changes
    generation.

    This patch is based on the criticism of the current state of builddeb
    discussed on:

    https://patchwork.kernel.org/patch/9656403/

    Signed-off-by: Riku Voipio
    Signed-off-by: Masahiro Yamada

    Riku Voipio
     
  • GNU Make automatically deletes intermediate files that are updated
    in a chain of pattern rules.

    Example 1) %.dtb.o
    Acked-by: Frank Rowand
    Acked-by: Ingo Molnar

    Masahiro Yamada
     
  • Our convention is to distinguish file types by suffixes with a period
    as a separator.

    *-asn1.[ch] is a different pattern from other generated sources such
    as *.lex.c, *.tab.[ch], *.dtb.S, etc. More confusing, files with
    '-asn1.[ch]' are generated files, but '_asn1.[ch]' are checked-in
    files:
    net/netfilter/nf_conntrack_h323_asn1.c
    include/linux/netfilter/nf_conntrack_h323_asn1.h
    include/linux/sunrpc/gss_asn1.h

    Rename generated files to *.asn1.[ch] for consistency.

    Signed-off-by: Masahiro Yamada

    Masahiro Yamada
     
  • Another common pattern that consists of chained commands is to compile
    a DTB as binary data into the kernel image or a module. It is used in
    several places in the source tree. Support it in the core Makefile.

    $(call if_changed,dt_S_dtb) is more suitable than $(call cmd,dt_S_dtb)
    in case cmd_dt_S_dtb is changed in the future.

    Signed-off-by: Masahiro Yamada
    Acked-by: Frank Rowand

    Masahiro Yamada
     
  • Files generated by if_changed* must be added to 'targets' to include
    *.cmd files. Otherwise, they would be regenerated every time.

    The build system automatically adds objects to 'targets' where
    appropriate, such as obj-y, extra-y, etc. but does nothing for
    intermediate files. So, each Makefile needs to add them by itself.

    There are some common cases where objects are generated by chained
    rules. Lexers and parsers are compiled like follows:

    %.lex.o
    Acked-by: Frank Rowand

    Masahiro Yamada
     
  • Now that the kernel build supports flex and bison, remove the _shipped
    files and generate them during the build instead.

    There are no more shipped lexer and parser, so I ripped off the rules
    in scripts/Malefile.lib that were used for REGENERATE_PARSERS.

    The genksyms parser has ambiguous grammar, which would emit warnings:

    scripts/genksyms/parse.y: warning: 9 shift/reduce conflicts [-Wconflicts-sr]
    scripts/genksyms/parse.y: warning: 5 reduce/reduce conflicts [-Wconflicts-rr]

    They are normally suppressed, but displayed when W=1 is given.

    Signed-off-by: Masahiro Yamada

    Masahiro Yamada
     
  • Files suffixed by .lex.c, .tab.[ch] are generated lexers, parsers,
    respectively. Clean them up globally from the top Makefile.

    Some of the final host programs those lexer/parser are linked into
    are necessary for building external modules, but the intermediates
    are unneeded. They can be cleaned away by 'make clean' instead of
    'make mrproper'.

    Signed-off-by: Masahiro Yamada
    Acked-by: Frank Rowand

    Masahiro Yamada
     
  • These patterns are common to host programs that require lexer and parser.
    Move them to the top .gitignore.

    Signed-off-by: Masahiro Yamada
    Acked-by: Frank Rowand

    Masahiro Yamada
     
  • When compiling executables from a single .c file, the linker is also
    invoked. Pass the HOSTLDFLAGS like for other linker commands.

    Signed-off-by: Robin Jarry
    Cc: Josh Poimboeuf
    Cc: Ingo Molnar
    Signed-off-by: Masahiro Yamada

    Robin Jarry
     
  • Sometimes files may be created by using output from printk. As the scan
    traverses the directory tree we should parse each path name and check if
    it is leaking an address.

    Add check for leaking address on each path name.

    Suggested-by: Tycho Andersen
    Acked-by: Tycho Andersen
    Signed-off-by: Tobin C. Harding

    Tobin C. Harding
     
  • Currently sub routine may_leak_address() is checking regex against Perl
    special variable $_ which is _fortunately_ being set correctly in a loop
    before this sub routine is called. We already have declared a variable
    to hold this value '$line' we should use it.

    Use $line in regex match instead of implicit $_

    Signed-off-by: Tobin C. Harding

    Tobin C. Harding
     
  • We have git now, we don't need a version number. This was originally
    added because leaking_addresses.pl shamelessly (and mindlessly) copied
    checkpatch.pl

    Remove version number from script.

    Signed-off-by: Tobin C. Harding

    Tobin C. Harding
     
  • The pointers listed in /proc/1/syscall are user pointers, and negative
    syscall args will show up like kernel addresses.

    For example

    /proc/31808/syscall: 0 0x3 0x55b107a38180 0x2000 0xffffffffffffffb0 \
    0x55b107a302d0 0x55b107a38180 0x7fffa313b8e8 0x7ff098560d11

    Skip parsing /proc/1/syscall

    Suggested-by: Tycho Andersen
    Signed-off-by: Tobin C. Harding

    Tobin C. Harding
     
  • When the system is idle it is likely that most files under /proc/PID
    will be identical for various processes. Scanning _all_ the PIDs under
    /proc is unnecessary and implies that we are thoroughly scanning /proc.
    This is _not_ the case because there may be ways userspace can trigger
    creation of /proc files that leak addresses but were not present during
    a scan. For these two reasons we should exclude all PID directories
    under /proc except '1/'

    Exclude all /proc/PID except /proc/1.

    Signed-off-by: Tobin C. Harding

    Tobin C. Harding
     
  • Currently we are repeatedly calling `uname -m`. This is causing the
    script to take a long time to run (more than 10 seconds to parse
    /proc/kallsyms). We can use Perl state variables to cache the result of
    the first call to `uname -m`. With this change in place the script
    scans the whole kernel in under a minute.

    Cache machine architecture in state variable.

    Signed-off-by: Tobin C. Harding

    Tobin C. Harding
     
  • Currently script has multiple configuration arrays. This is confusing,
    evident by the fact that a bunch of the entries are in the wrong place.
    We can simplify the code by just having a single array for absolute
    paths to skip and a single array for file names to skip wherever they
    appear in the scanned directory tree. There are also currently multiple
    subroutines to handle the different arrays, we can reduce these to a
    single subroutine also.

    Simplify the path skipping code.

    Signed-off-by: Tobin C. Harding

    Tobin C. Harding
     
  • Currently script parses binary files. Since we are scanning for
    readable kernel addresses there is no need to parse binary files. We
    can use Perl to check if file is binary and skip parsing it if so.

    Do not parse binary files.

    Signed-off-by: Tobin C. Harding

    Tobin C. Harding