07 Feb, 2018

3 commits

  • clang's AddressSanitizer implementation adds redzones on either side of
    alloca()ed buffers. These redzones are 32-byte aligned and at least 32
    bytes long.

    __asan_alloca_poison() is passed the size and address of the allocated
    buffer, *excluding* the redzones on either side. The left redzone will
    always be to the immediate left of this buffer; but AddressSanitizer may
    need to add padding between the end of the buffer and the right redzone.
    If there are any 8-byte chunks inside this padding, we should poison
    those too.

    __asan_allocas_unpoison() is just passed the top and bottom of the dynamic
    stack area, so unpoisoning is simpler.

    Link: http://lkml.kernel.org/r/20171204191735.132544-4-paullawrence@google.com
    Signed-off-by: Greg Hackmann
    Signed-off-by: Paul Lawrence
    Acked-by: Andrey Ryabinin
    Cc: Alexander Potapenko
    Cc: Dmitry Vyukov
    Cc: Masahiro Yamada
    Cc: Matthias Kaehlcke
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Paul Lawrence
     
  • LLVM doesn't understand GCC-style paramters ("--param asan-foo=bar"), thus
    we currently we don't use inline/globals/stack instrumentation when
    building the kernel with clang.

    Add support for LLVM-style parameters ("-mllvm -asan-foo=bar") to enable
    all KASAN features.

    Link: http://lkml.kernel.org/r/20171204191735.132544-3-paullawrence@google.com
    Signed-off-by: Andrey Ryabinin
    Signed-off-by: Paul Lawrence
    Reviewed-by: Alexander Potapenko
    Cc: Dmitry Vyukov
    Cc: Greg Hackmann
    Cc: Masahiro Yamada
    Cc: Matthias Kaehlcke
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrey Ryabinin
     
  • With KASAN enabled the kernel has two different memset() functions, one
    with KASAN checks (memset) and one without (__memset). KASAN uses some
    macro tricks to use the proper version where required. For example
    memset() calls in mm/slub.c are without KASAN checks, since they operate
    on poisoned slab object metadata.

    The issue is that clang emits memset() calls even when there is no
    memset() in the source code. They get linked with improper memset()
    implementation and the kernel fails to boot due to a huge amount of KASAN
    reports during early boot stages.

    The solution is to add -fno-builtin flag for files with KASAN_SANITIZE :=
    n marker.

    Link: http://lkml.kernel.org/r/8ffecfffe04088c52c42b92739c2bd8a0bcb3f5e.1516384594.git.andreyknvl@google.com
    Signed-off-by: Andrey Konovalov
    Acked-by: Nick Desaulniers
    Cc: Masahiro Yamada
    Cc: Michal Marek
    Cc: Andrey Ryabinin
    Cc: Alexander Potapenko
    Cc: Dmitry Vyukov
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrey Konovalov
     

02 Feb, 2018

5 commits

  • Pull printk updates from Petr Mladek:

    - Add a console_msg_format command line option:

    The value "default" keeps the old "[time stamp] text\n" format. The
    value "syslog" allows to see the syslog-like "[timestamp] text" format.

    This feature was requested by people doing regression tests, for
    example, 0day robot. They want to have both filtered and full logs
    at hands.

    - Reduce the risk of softlockup:

    Pass the console owner in a busy loop.

    This is a new approach to the old problem. It was first proposed by
    Steven Rostedt on Kernel Summit 2017. It marks a context in which
    the console_lock owner calls console drivers and could not sleep.
    On the other side, printk() callers could detect this state and use
    a busy wait instead of a simple console_trylock(). Finally, the
    console_lock owner checks if there is a busy waiter at the end of
    the special context and eventually passes the console_lock to the
    waiter.

    The hand-off works surprisingly well and helps in many situations.
    Well, there is still a possibility of the softlockup, for example,
    when the flood of messages stops and the last owner still has too
    much to flush.

    There is increasing number of people having problems with
    printk-related softlockups. We might eventually need to get better
    solution. Anyway, this looks like a good start and promising
    direction.

    - Do not allow to schedule in console_unlock() called from printk():

    This reverts an older controversial commit. The reschedule helped
    to avoid softlockups. But it also slowed down the console output.
    This patch is obsoleted by the new console waiter logic described
    above. In fact, the reschedule made the hand-off less effective.

    - Deprecate "%pf" and "%pF" format specifier:

    It was needed on ia64, ppc64 and parisc64 to dereference function
    descriptors and show the real function address. It is done
    transparently by "%ps" and "pS" format specifier now.

    Sergey Senozhatsky found that all the function descriptors were in
    a special elf section and could be easily detected.

    - Remove printk_symbol() API:

    It has been obsoleted by "%pS" format specifier, and this change
    helped to remove few continuous lines and a less intuitive old API.

    - Remove redundant memsets:

    Sergey removed unnecessary memset when processing printk.devkmsg
    command line option.

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/pmladek/printk: (27 commits)
    printk: drop redundant devkmsg_log_str memsets
    printk: Never set console_may_schedule in console_trylock()
    printk: Hide console waiter logic into helpers
    printk: Add console owner and waiter logic to load balance console writes
    kallsyms: remove print_symbol() function
    checkpatch: add pF/pf deprecation warning
    symbol lookup: introduce dereference_symbol_descriptor()
    parisc64: Add .opd based function descriptor dereference
    powerpc64: Add .opd based function descriptor dereference
    ia64: Add .opd based function descriptor dereference
    sections: split dereference_function_descriptor()
    openrisc: Fix conflicting types for _exext and _stext
    lib: do not use print_symbol()
    irq debug: do not use print_symbol()
    sysfs: do not use print_symbol()
    drivers: do not use print_symbol()
    x86: do not use print_symbol()
    unicore32: do not use print_symbol()
    sh: do not use print_symbol()
    mn10300: do not use print_symbol()
    ...

    Linus Torvalds
     
  • Pull Kconfig updates from Masahiro Yamada:
    "A pretty big batch of Kconfig updates.

    I have to mention the lexer and parser of Kconfig are now built from
    real .l and .y sources. So, flex and bison are the requirement for
    building the kernel. Both of them (unlike gperf) have been stable for
    a long time. This change has been tested several weeks in linux-next,
    and I did not receive any problem report about this.

    Summary:

    - add checks for mistakes, like the choice default is not in choice,
    help is doubled

    - document data structure and complex code

    - fix various memory leaks

    - change Makefile to build lexer and parser instead of using
    pre-generated C files

    - drop 'boolean' keyword, which is equivalent to 'bool'

    - use default 'yy' prefix and remove unneeded Make variables

    - fix gettext() check for xconfig

    - announce that oldnoconfig will be finally removed

    - make 'Selected by:' and 'Implied by' readable in help and search
    result

    - hide silentoldconfig from 'make help' to stop confusing people

    - fix misc things and cleanups"

    * tag 'kconfig-v4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (37 commits)
    kconfig: Remove silentoldconfig from help and docs; fix kconfig/conf's help
    kconfig: make "Selected by:" and "Implied by:" readable
    kconfig: announce removal of oldnoconfig if used
    kconfig: fix make xconfig when gettext is missing
    kconfig: Clarify menu and 'if' dependency propagation
    kconfig: Document 'if' flattening logic
    kconfig: Clarify choice dependency propagation
    kconfig: Document SYMBOL_OPTIONAL logic
    kbuild: remove unnecessary LEX_PREFIX and YACC_PREFIX
    kconfig: use default 'yy' prefix for lexer and parser
    kconfig: make conf_unsaved a local variable of conf_read()
    kconfig: make xfgets() really static
    kconfig: make input_mode static
    kconfig: Warn if there is more than one help text
    kconfig: drop 'boolean' keyword
    kconfig: use bool instead of boolean for type definition attributes, again
    kconfig: Remove menu_end_entry()
    kconfig: Document important expression functions
    kconfig: Document automatic submenu creation code
    kconfig: Fix choice symbol expression leak
    ...

    Linus Torvalds
     
  • …asahiroy/linux-kbuild

    Pull Kbuild misc updates from Masahiro Yamada:

    - add snap-pkg target to create Linux kernel snap package

    - make out-of-tree creation of source packages fail correctly

    - improve and fix several semantic patches

    * tag 'kbuild-misc-v4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
    Coccinelle: coccicheck: fix typo
    Coccinelle: memdup: drop spurious line
    Coccinelle: kzalloc-simple: Rename kzalloc-simple to zalloc-simple
    Coccinelle: ifnullfree: Trim the warning reported in report mode
    Coccinelle: alloc_cast: Add more memory allocating functions to the list
    Coccinelle: array_size: report even if include is missing
    Coccinelle: kzalloc-simple: Add all zero allocating functions
    kbuild: pkg: make out-of-tree rpm/deb-pkg build immediately fail
    scripts/package: snap-pkg target

    Linus Torvalds
     
  • Pull Kbuild updates from Masahiro Yamada:

    - terminate the build correctly in case of fixdep errors

    - clean up fixdep

    - suppress packed-not-aligned warnings from GCC-8

    - fix W= handling for extra DTC warnings

    * tag 'kbuild-v4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
    kbuild: fix W= option checks for extra DTC warnings
    Kbuild: suppress packed-not-aligned warning for default setting only
    fixdep: use existing helper to check modular CONFIG options
    fixdep: refactor parse_dep_file()
    fixdep: move global variables to local variables of main()
    fixdep: remove unneeded memcpy() in parse_dep_file()
    fixdep: factor out common code for reading files
    fixdep: use malloc() and read() to load dep_file to buffer
    fixdep: remove unnecessary inclusion
    fixdep: exit with error code in error branches of do_config_file()

    Linus Torvalds
     
  • Pull char/misc driver updates from Greg KH:
    "Here is the big pull request for char/misc drivers for 4.16-rc1.

    There's a lot of stuff in here. Three new driver subsystems were added
    for various types of hardware busses:

    - siox
    - slimbus
    - soundwire

    as well as a new vboxguest subsystem for the VirtualBox hypervisor
    drivers.

    There's also big updates from the FPGA subsystem, lots of Android
    binder fixes, the usual handful of hyper-v updates, and lots of other
    smaller driver updates.

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

    * tag 'char-misc-4.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (155 commits)
    char: lp: use true or false for boolean values
    android: binder: use VM_ALLOC to get vm area
    android: binder: Use true and false for boolean values
    lkdtm: fix handle_irq_event symbol for INT_HW_IRQ_EN
    EISA: Delete error message for a failed memory allocation in eisa_probe()
    EISA: Whitespace cleanup
    misc: remove AVR32 dependencies
    virt: vbox: Add error mapping for VERR_INVALID_NAME and VERR_NO_MORE_FILES
    soundwire: Fix a signedness bug
    uio_hv_generic: fix new type mismatch warnings
    uio_hv_generic: fix type mismatch warnings
    auxdisplay: img-ascii-lcd: add missing MODULE_DESCRIPTION/AUTHOR/LICENSE
    uio_hv_generic: add rescind support
    uio_hv_generic: check that host supports monitor page
    uio_hv_generic: create send and receive buffers
    uio: document uio_hv_generic regions
    doc: fix documentation about uio_hv_generic
    vmbus: add monitor_id and subchannel_id to sysfs per channel
    vmbus: fix ABI documentation
    uio_hv_generic: use ISR callback method
    ...

    Linus Torvalds
     

01 Feb, 2018

4 commits

  • Correct spelling of "coccinelle".

    Signed-off-by: Julia Lawall
    Signed-off-by: Masahiro Yamada

    Julia Lawall
     
  • Pull documentation updates from Jonathan Corbet:
    "Documentation updates for 4.16.

    New stuff includes refcount_t documentation, errseq documentation,
    kernel-doc support for nested structure definitions, the removal of
    lots of crufty kernel-doc support for unused formats, SPDX tag
    documentation, the beginnings of a manual for subsystem maintainers,
    and lots of fixes and updates.

    As usual, some of the changesets reach outside of Documentation/ to
    effect kerneldoc comment fixes. It also adds the new LICENSES
    directory, of which Thomas promises I do not need to be the
    maintainer"

    * tag 'docs-4.16' of git://git.lwn.net/linux: (65 commits)
    linux-next: docs-rst: Fix typos in kfigure.py
    linux-next: DOC: HWPOISON: Fix path to debugfs in hwpoison.txt
    Documentation: Fix misconversion of #if
    docs: add index entry for networking/msg_zerocopy
    Documentation: security/credentials.rst: explain need to sort group_list
    LICENSES: Add MPL-1.1 license
    LICENSES: Add the GPL 1.0 license
    LICENSES: Add Linux syscall note exception
    LICENSES: Add the MIT license
    LICENSES: Add the BSD-3-clause "Clear" license
    LICENSES: Add the BSD 3-clause "New" or "Revised" License
    LICENSES: Add the BSD 2-clause "Simplified" license
    LICENSES: Add the LGPL-2.1 license
    LICENSES: Add the LGPL 2.0 license
    LICENSES: Add the GPL 2.0 license
    Documentation: Add license-rules.rst to describe how to properly identify file licenses
    scripts: kernel_doc: better handle show warnings logic
    fs/*/Kconfig: drop links to 404-compliant http://acl.bestbits.at
    doc: md: Fix a file name to md-fault.c in fault-injection.txt
    errseq: Add to documentation tree
    ...

    Linus Torvalds
     
  • The current find done in find_other_sources() excludes directories in
    the kernel tree that are named 'include', eg.:

    ./security/apparmor/include
    ./security/selinux/include
    ./drivers/net/wireless/broadcom/brcm80211/include
    ./drivers/gpu/drm/amd/acp/include
    ./drivers/gpu/drm/amd/display/include
    ./drivers/gpu/drm/amd/include
    ./drivers/gpu/drm/nouveau/include

    This changes the find command in find_other_sources() to include those
    using the -path option.

    Link: http://lkml.kernel.org/r/1513335768-7852-1-git-send-email-arend.vanspriel@broadcom.com
    Signed-off-by: Arend van Spriel
    Cc: Robert Jarzmik
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arend van Spriel
     
  • In case of running scripts/decodecode without any parameters in order to
    give a copy'n'pasted Code line from, for example, email it would parse
    only first line of it, while in emails it's split to few.

    ie, when you have a file out of oops the Code line looks like

    Code: hh hh ... ... hh\n

    When copy'n'paste from, for example, email where sender or some middle
    MTA split it, the line looks like:

    Code: hh hh ... hh\n
    hh ... ... hh\n
    hh hh ... hh\n

    The Code line followed by another oops line usually contains characters
    out of hex digit + space + < + > set.

    So add logic to join this split back if and only if the following lines
    have hex digits, or spaces, or '' characters. It will be quite
    unlikely to have a broken input in well formed Oops or dmesg, thus a
    simple regex is being used.

    Link: http://lkml.kernel.org/r/20171212100323.33201-1-andriy.shevchenko@linux.intel.com
    Signed-off-by: Andy Shevchenko
    Cc: Will Deacon
    Cc: Dave Martin
    Cc: Philippe Ombredanne
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Shevchenko
     

31 Jan, 2018

1 commit

  • Pull RCU updates from Ingo Molnar:
    "The main RCU changes in this cycle were:

    - Updates to use cond_resched() instead of cond_resched_rcu_qs()
    where feasible (currently everywhere except in kernel/rcu and in
    kernel/torture.c). Also a couple of fixes to avoid sending IPIs to
    offline CPUs.

    - Updates to simplify RCU's dyntick-idle handling.

    - Updates to remove almost all uses of smp_read_barrier_depends() and
    read_barrier_depends().

    - Torture-test updates.

    - Miscellaneous fixes"

    * 'core-rcu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (72 commits)
    torture: Save a line in stutter_wait(): while -> for
    torture: Eliminate torture_runnable and perf_runnable
    torture: Make stutter less vulnerable to compilers and races
    locking/locktorture: Fix num reader/writer corner cases
    locking/locktorture: Fix rwsem reader_delay
    torture: Place all torture-test modules in one MAINTAINERS group
    rcutorture/kvm-build.sh: Skip build directory check
    rcutorture: Simplify functions.sh include path
    rcutorture: Simplify logging
    rcutorture/kvm-recheck-*: Improve result directory readability check
    rcutorture/kvm.sh: Support execution from any directory
    rcutorture/kvm.sh: Use consistent help text for --qemu-args
    rcutorture/kvm.sh: Remove unused variable, `alldone`
    rcutorture: Remove unused script, config2frag.sh
    rcutorture/configinit: Fix build directory error message
    rcutorture: Preempt RCU-preempt readers more vigorously
    torture: Reduce #ifdefs for preempt_schedule()
    rcu: Remove have_rcu_nocb_mask from tree_plugin.h
    rcu: Add comment giving debug strategy for double call_rcu()
    tracing, rcu: Hide trace event rcu_nocb_wake when not used
    ...

    Linus Torvalds
     

30 Jan, 2018

1 commit

  • Pull x86/pti updates from Thomas Gleixner:
    "Another set of melted spectrum related changes:

    - Code simplifications and cleanups for RSB and retpolines.

    - Make the indirect calls in KVM speculation safe.

    - Whitelist CPUs which are known not to speculate from Meltdown and
    prepare for the new CPUID flag which tells the kernel that a CPU is
    not affected.

    - A less rigorous variant of the module retpoline check which merily
    warns when a non-retpoline protected module is loaded and reflects
    that fact in the sysfs file.

    - Prepare for Indirect Branch Prediction Barrier support.

    - Prepare for exposure of the Speculation Control MSRs to guests, so
    guest OSes which depend on those "features" can use them. Includes
    a blacklist of the broken microcodes. The actual exposure of the
    MSRs through KVM is still being worked on"

    * 'x86-pti-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
    x86/speculation: Simplify indirect_branch_prediction_barrier()
    x86/retpoline: Simplify vmexit_fill_RSB()
    x86/cpufeatures: Clean up Spectre v2 related CPUID flags
    x86/cpu/bugs: Make retpoline module warning conditional
    x86/bugs: Drop one "mitigation" from dmesg
    x86/nospec: Fix header guards names
    x86/alternative: Print unadorned pointers
    x86/speculation: Add basic IBPB (Indirect Branch Prediction Barrier) support
    x86/cpufeature: Blacklist SPEC_CTRL/PRED_CMD on early Spectre v2 microcodes
    x86/pti: Do not enable PTI on CPUs which are not vulnerable to Meltdown
    x86/msr: Add definitions for new speculation control MSRs
    x86/cpufeatures: Add AMD feature bits for Speculation Control
    x86/cpufeatures: Add Intel feature bits for Speculation Control
    x86/cpufeatures: Add CPUID_7_EDX CPUID leaf
    module/retpoline: Warn about missing retpoline in module
    KVM: VMX: Make indirect call speculation safe
    KVM: x86: Make indirect calls in emulator speculation safe

    Linus Torvalds
     

29 Jan, 2018

1 commit


28 Jan, 2018

1 commit

  • As explained by Michal Marek at https://lkml.org/lkml/2011/8/31/189
    silentoldconfig has become a misnomer. It has become an internal interface
    so remove it from "make help" and Documentation/ to stop confusing people
    using it as seen for instance at
    https://chromium-review.googlesource.com/835632 Don't remove it from
    kconfig/Makefile yet not to break any (other) tool using it.

    On the other hand, correct and expand its description in the help of
    the (internal) scripts/kconfig/conf.c

    Signed-off-by: Marc Herbert
    Signed-off-by: Masahiro Yamada

    Marc Herbert
     

26 Jan, 2018

1 commit

  • There's a risk that a kernel which has full retpoline mitigations becomes
    vulnerable when a module gets loaded that hasn't been compiled with the
    right compiler or the right option.

    To enable detection of that mismatch at module load time, add a module info
    string "retpoline" at build time when the module was compiled with
    retpoline support. This only covers compiled C source, but assembler source
    or prebuilt object files are not checked.

    If a retpoline enabled kernel detects a non retpoline protected module at
    load time, print a warning and report it in the sysfs vulnerability file.

    [ tglx: Massaged changelog ]

    Signed-off-by: Andi Kleen
    Signed-off-by: Thomas Gleixner
    Cc: David Woodhouse
    Cc: gregkh@linuxfoundation.org
    Cc: torvalds@linux-foundation.org
    Cc: jeyu@kernel.org
    Cc: arjan@linux.intel.com
    Link: https://lkml.kernel.org/r/20180125235028.31211-1-andi@firstfloor.org

    Andi Kleen
     

25 Jan, 2018

3 commits

  • Kbuild supports 3 levels of extra warnings, and multiple levels can
    be combined, like W=12, W=123. It was added by commit a6de553da01c
    ("kbuild: Allow to combine multiple W= levels").

    From the log of commit 8654cb8d0371 ("dtc: update warning settings
    for new bus and node/property name checks"), I assume:

    - unit_address_vs_reg, simple_bus_reg, etc. belong to level 1
    - node_name_chars_strict, property_name_chars_strict belong to level 2

    However, the level 1 warnings are displayed by any argument to W=.
    On the other hand, the level 2 warnings are displayed by W=2, but
    not by W=12, or W=123.

    Use $(findstring ...) like scripts/Makefile.extrawarn.

    Signed-off-by: Masahiro Yamada
    Acked-by: Arnd Bergmann

    Masahiro Yamada
     
  • Reverse dependency expressions can get rather unwieldy, especially if
    a symbol is selected by more than a handful of other symbols. I.e. it's
    possible to have near endless expressions like:
    A && B && !C || D || F && (G || H) || [...]

    Chop these expressions into actually readable chunks:
    - A && B && !C
    - D
    - F && (G || H)
    - [...]

    I.e. transform the top level OR tokens into newlines and prepend each
    line with a minus. This makes the "Selected by:" and "Implied by:" blurb
    much easier to read. This is done only if there is more than one top
    level OR. "Depends on:" and "Range :" were deliberately left as they are.

    Based on idea from Paul Bolle.

    Suggested-by: Paul Bolle
    Signed-off-by: Petr Vorel
    Signed-off-by: Masahiro Yamada

    Petr Vorel
     
  • The 'oldnoconfig' is really confusing due to its counter-intuitive name.
    It was renamed by commit fb16d8912db5 ("kconfig: replace 'oldnoconfig'
    with 'olddefconfig', and keep the old name as an alias").

    The 'oldnoconfig' has been kept as an alias for enough period of time,
    and finally I am planning to remove it. I will give people a little
    more time for migration. Meanwhile, the following message will be
    displayed if oldnoconfig is used.

    WARNING: "oldnoconfig" target will be removed after Linux 4.19
    Please use "olddefconfig" instead, which is an alias.

    Signed-off-by: Masahiro Yamada
    Reviewed-by: Ulf Magnusson

    Masahiro Yamada
     

22 Jan, 2018

3 commits

  • The C-based config programs are properly guarded from a missing (or,
    currently, external) libintl.h by the HOST_EXTRACFLAGS check, but
    this does not help the C++-based qconf.

    Signed-off-by: Yaakov Selkowitz
    Signed-off-by: Masahiro Yamada

    Yaakov Selkowitz
     
  • It is not obvious that the last two cases refer to menus and ifs,
    respectively, in the conditional that sets 'parentdep'.

    Automatic submenu creation is done later, so the parent can't be a
    symbol here.

    No functional changes. Only comments added.

    Signed-off-by: Ulf Magnusson
    Signed-off-by: Masahiro Yamada

    Ulf Magnusson
     
  • It is not obvious that this might refer to an 'if', making the code
    pretty cryptic:

    if (menu->list && (!menu->prompt || !menu->prompt->text)) {

    Kconfig keeps the 'if' menu nodes even after flattening. Reflect that in
    the example to be accurate.

    No functional changes. Only comments added.

    Signed-off-by: Ulf Magnusson
    Signed-off-by: Masahiro Yamada

    Ulf Magnusson
     

21 Jan, 2018

16 commits

  • It's easy to miss that choices are special-cased to pass on their mode
    as the parent dependency.

    No functional changes. Only comments added.

    Signed-off-by: Ulf Magnusson
    Signed-off-by: Masahiro Yamada

    Ulf Magnusson
     
  • Not obvious, especially if you don't already know how choices are
    implemented.

    No functional changes. Only comments added.

    Signed-off-by: Ulf Magnusson
    Signed-off-by: Masahiro Yamada

    Ulf Magnusson
     
  • Kconfig was the only user of these. With Kconfig converted to use
    the default 'yy' prefix, we do not need them any more.

    Signed-off-by: Masahiro Yamada
    Reviewed-by: Ulf Magnusson

    Masahiro Yamada
     
  • Flex and Bison provide an option to change the prefix of globally-
    visible symbols. This is useful to link multiple lexers and/or
    parsers into the same executable. However, Kconfig (and any other
    host programs in kernel) uses a single lexer and parser. I do not
    see a good reason to change the default 'yy' prefix.

    Signed-off-by: Masahiro Yamada
    Reviewed-by: Ulf Magnusson

    Masahiro Yamada
     
  • conf_unsaved is initialized by conf_read_simple(), but it is possible
    to move it to conf_read() so that it can be a local variable.

    Signed-off-by: Masahiro Yamada

    Masahiro Yamada
     
  • Sparse reports:
    warning: symbol 'xfgets' was not declared. Should it be static?

    It is declared as static, but it is missing in the definition part.
    Move the definition up and remove the forward declaration.

    Signed-off-by: Masahiro Yamada

    Masahiro Yamada
     
  • Sparse reports:
    warning: symbol 'input_mode' was not declared. Should it be static?

    Signed-off-by: Masahiro Yamada

    Masahiro Yamada
     
  • Avoids mistakes like in the following real-world example, where only the
    final help string ("Say Y...") was used. This particular example was
    fixed in commit 561b29e4ec8d ("media: fix media Kconfig help syntax
    issues").

    config DVB_NETUP_UNIDVB
    ...
    select DVB_CXD2841ER if MEDIA_SUBDRV_AUTOSELECT
    ---help---
    Support for NetUP PCI express Universal DVB card.
    help
    Say Y when you want to support NetUP Dual Universal DVB card
    ...

    This now prints the following warning:

    drivers/media/pci/netup_unidvb:13: warning: 'DVB_NETUP_UNIDVB' defined with more than one help text -- only the last one will be used

    Also free() any extra help strings.

    Signed-off-by: Ulf Magnusson
    Signed-off-by: Masahiro Yamada

    Ulf Magnusson
     
  • No more users of this keyword. Drop it according to the notice by
    commit 6341e62b212a ("kconfig: use bool instead of boolean for type
    definition attributes").

    Signed-off-by: Masahiro Yamada
    Acked-by: Luis R. Rodriguez

    Masahiro Yamada
     
  • menu_end_entry() is empty and completely unused as far as I can tell:

    $ git log -G menu_end_entry --oneline
    a02f057 [PATCH] kconfig: improve error handling in the parser
    1da177e Linux-2.6.12-rc2

    Last one is the initial Git commit, where menu_end_entry() is empty as
    well. I couldn't find anything that redefined it on Google either.

    It might be a debugging helper for setting a breakpoint after each
    config, menuconfig, and comment is parsed. IMO it hurts more than it
    helps in that case by making the parsing code look more complicated at a
    glance than it really is, and I suspect it doesn't get used much.

    Tested by running the Kconfiglib test suite, which indirectly verifies
    that the .config files generated by the C implementation for each
    defconfig file in the kernel stays the same.

    Signed-off-by: Ulf Magnusson
    Signed-off-by: Masahiro Yamada

    Ulf Magnusson
     
  • Many of these functions are quite the head scratchers if you don't know
    what they're trying to do. Document them.

    Also make it clear which functions rewrite expressions in-place and
    which return new expressions. This prevents memory errors.

    No functional changes. Only comments added.

    Signed-off-by: Ulf Magnusson
    Signed-off-by: Masahiro Yamada

    Ulf Magnusson
     
  • It's tricky to figure out what it does (and how) without staring at the
    code for a long time. Document it to make it more transparent.

    No functional changes. Only comments added.

    Signed-off-by: Ulf Magnusson
    Signed-off-by: Masahiro Yamada

    Ulf Magnusson
     
  • When propagating dependencies from parents after parsing, an expression
    node is allocated if the parent symbol is a 'choice'. This node was
    never freed.

    Outline of leak:

    if (sym && sym_is_choice(sym)) {
    ...
    *Allocate (in this case only)*
    parentdep = expr_alloc_symbol(sym);
    } else if (parent->prompt)
    parentdep = parent->prompt->visible.expr;
    else
    parentdep = parent->dep;

    for (menu = parent->list; menu; menu = menu->next) {
    ...
    *Copy*
    basedep = expr_alloc_and(expr_copy(parentdep), basedep);
    ...
    }
    *parentdep lost if the parent is a choice!*

    Fix by freeing 'parentdep' after the loop if the parent symbol is a
    choice. Note that this only frees the expression node and not the choice
    symbol itself.

    Summary from Valgrind on 'menuconfig' (ARCH=x86) before the fix:

    LEAK SUMMARY:
    definitely lost: 1,608 bytes in 67 blocks
    ...

    Summary after the fix:

    LEAK SUMMARY:
    definitely lost: 0 bytes in 0 blocks
    ...

    Signed-off-by: Ulf Magnusson
    Signed-off-by: Masahiro Yamada

    Ulf Magnusson
     
  • Only the E_NOT operand and not the E_NOT node itself was freed, due to
    accidentally returning too early in expr_free(). Outline of leak:

    switch (e->type) {
    ...
    case E_NOT:
    expr_free(e->left.expr);
    return;
    ...
    }
    *Never reached, 'e' leaked*
    free(e);

    Fix by changing the 'return' to a 'break'.

    Summary from Valgrind on 'menuconfig' (ARCH=x86) before the fix:

    LEAK SUMMARY:
    definitely lost: 44,448 bytes in 1,852 blocks
    ...

    Summary after the fix:

    LEAK SUMMARY:
    definitely lost: 1,608 bytes in 67 blocks
    ...

    Signed-off-by: Ulf Magnusson
    Signed-off-by: Masahiro Yamada

    Ulf Magnusson
     
  • expr_trans_compare() always allocates and returns a new expression,
    giving the following leak outline:

    ...
    *Allocate*
    basedep = expr_trans_compare(basedep, E_UNEQUAL, &symbol_no);
    ...
    for (menu = parent->next; menu; menu = menu->next) {
    ...
    *Copy*
    dep2 = expr_copy(basedep);
    ...
    *Free copy*
    expr_free(dep2);
    }
    *basedep lost!*

    Fix by freeing 'basedep' after the loop.

    Summary from Valgrind on 'menuconfig' (ARCH=x86) before the fix:

    LEAK SUMMARY:
    definitely lost: 344,376 bytes in 14,349 blocks
    ...

    Summary after the fix:

    LEAK SUMMARY:
    definitely lost: 44,448 bytes in 1,852 blocks
    ...

    Signed-off-by: Ulf Magnusson
    Signed-off-by: Masahiro Yamada

    Ulf Magnusson
     
  • If a 'mainmenu' entry appeared in the Kconfig files, two things would
    leak:

    - The 'struct property' allocated for the default "Linux Kernel
    Configuration" prompt.

    - The string for the T_WORD/T_WORD_QUOTE prompt after the
    T_MAINMENU token, allocated on the heap in zconf.l.

    To fix it, introduce a new 'no_mainmenu_stmt' nonterminal that matches
    if there's no 'mainmenu' and adds the default prompt. That means the
    prompt only gets allocated once regardless of whether there's a
    'mainmenu' statement or not, and managing it becomes simple.

    Summary from Valgrind on 'menuconfig' (ARCH=x86) before the fix:

    LEAK SUMMARY:
    definitely lost: 344,568 bytes in 14,352 blocks
    ...

    Summary after the fix:

    LEAK SUMMARY:
    definitely lost: 344,440 bytes in 14,350 blocks
    ...

    Signed-off-by: Ulf Magnusson
    Signed-off-by: Masahiro Yamada

    Ulf Magnusson
     

20 Jan, 2018

1 commit

  • Since kernel 4.9, the thread_info has been moved into task_struct, no
    longer locates at the bottom of kernel stack.

    See commits c65eacbe290b ("sched/core: Allow putting thread_info into
    task_struct") and 15f4eae70d36 ("x86: Move thread_info into
    task_struct").

    Before fix:
    (gdb) set $current = $lx_current()
    (gdb) p $lx_thread_info($current)
    $1 = {flags = 1470918301}
    (gdb) p $current.thread_info
    $2 = {flags = 2147483648}

    After fix:
    (gdb) p $lx_thread_info($current)
    $1 = {flags = 2147483648}
    (gdb) p $current.thread_info
    $2 = {flags = 2147483648}

    Link: http://lkml.kernel.org/r/20180118210159.17223-1-imxikangjie@gmail.com
    Fixes: 15f4eae70d36 ("x86: Move thread_info into task_struct")
    Signed-off-by: Xi Kangjie
    Acked-by: Jan Kiszka
    Acked-by: Kieran Bingham
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Xi Kangjie