15 May, 2019

40 commits

  • We already store the current task fo the new waiter before calling
    wq_sleep() in both send and recv paths. Trivially remove the redundant
    assignment.

    Link: http://lkml.kernel.org/r/20190321190216.1719-1-dave@stgolabs.net
    Signed-off-by: Davidlohr Bueso
    Cc: Manfred Spraul
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Davidlohr Bueso
     
  • msgctl10 of ltp triggers the following lockup When CONFIG_KASAN is
    enabled on large memory SMP systems, the pages initialization can take a
    long time, if msgctl10 requests a huge block memory, and it will block
    rcu scheduler, so release cpu actively.

    After adding schedule() in free_msg, free_msg can not be called when
    holding spinlock, so adding msg to a tmp list, and free it out of
    spinlock

    rcu: INFO: rcu_preempt detected stalls on CPUs/tasks:
    rcu: Tasks blocked on level-1 rcu_node (CPUs 16-31): P32505
    rcu: Tasks blocked on level-1 rcu_node (CPUs 48-63): P34978
    rcu: (detected by 11, t=35024 jiffies, g=44237529, q=16542267)
    msgctl10 R running task 21608 32505 2794 0x00000082
    Call Trace:
    preempt_schedule_irq+0x4c/0xb0
    retint_kernel+0x1b/0x2d
    RIP: 0010:__is_insn_slot_addr+0xfb/0x250
    Code: 82 1d 00 48 8b 9b 90 00 00 00 4c 89 f7 49 c1 ee 03 e8 59 83 1d 00 48 b8 00 00 00 00 00 fc ff df 4c 39 eb 48 89 9d 58 ff ff ff c6 04 06 f8 74 66 4c 8d 75 98 4c 89 f1 48 c1 e9 03 48 01 c8 48
    RSP: 0018:ffff88bce041f758 EFLAGS: 00000246 ORIG_RAX: ffffffffffffff13
    RAX: dffffc0000000000 RBX: ffffffff8471bc50 RCX: ffffffff828a2a57
    RDX: dffffc0000000000 RSI: dffffc0000000000 RDI: ffff88bce041f780
    RBP: ffff88bce041f828 R08: ffffed15f3f4c5b3 R09: ffffed15f3f4c5b3
    R10: 0000000000000001 R11: ffffed15f3f4c5b2 R12: 000000318aee9b73
    R13: ffffffff8471bc50 R14: 1ffff1179c083ef0 R15: 1ffff1179c083eec
    kernel_text_address+0xc1/0x100
    __kernel_text_address+0xe/0x30
    unwind_get_return_address+0x2f/0x50
    __save_stack_trace+0x92/0x100
    create_object+0x380/0x650
    __kmalloc+0x14c/0x2b0
    load_msg+0x38/0x1a0
    do_msgsnd+0x19e/0xcf0
    do_syscall_64+0x117/0x400
    entry_SYSCALL_64_after_hwframe+0x49/0xbe

    rcu: INFO: rcu_preempt detected stalls on CPUs/tasks:
    rcu: Tasks blocked on level-1 rcu_node (CPUs 0-15): P32170
    rcu: (detected by 14, t=35016 jiffies, g=44237525, q=12423063)
    msgctl10 R running task 21608 32170 32155 0x00000082
    Call Trace:
    preempt_schedule_irq+0x4c/0xb0
    retint_kernel+0x1b/0x2d
    RIP: 0010:lock_acquire+0x4d/0x340
    Code: 48 81 ec c0 00 00 00 45 89 c6 4d 89 cf 48 8d 6c 24 20 48 89 3c 24 48 8d bb e4 0c 00 00 89 74 24 0c 48 c7 44 24 20 b3 8a b5 41 c1 ed 03 48 c7 44 24 28 b4 25 18 84 48 c7 44 24 30 d0 54 7a 82
    RSP: 0018:ffff88af83417738 EFLAGS: 00000282 ORIG_RAX: ffffffffffffff13
    RAX: dffffc0000000000 RBX: ffff88bd335f3080 RCX: 0000000000000002
    RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff88bd335f3d64
    RBP: ffff88af83417758 R08: 0000000000000000 R09: 0000000000000000
    R10: 0000000000000001 R11: ffffed13f3f745b2 R12: 0000000000000000
    R13: 0000000000000002 R14: 0000000000000000 R15: 0000000000000000
    is_bpf_text_address+0x32/0xe0
    kernel_text_address+0xec/0x100
    __kernel_text_address+0xe/0x30
    unwind_get_return_address+0x2f/0x50
    __save_stack_trace+0x92/0x100
    save_stack+0x32/0xb0
    __kasan_slab_free+0x130/0x180
    kfree+0xfa/0x2d0
    free_msg+0x24/0x50
    do_msgrcv+0x508/0xe60
    do_syscall_64+0x117/0x400
    entry_SYSCALL_64_after_hwframe+0x49/0xbe

    Davidlohr said:
    "So after releasing the lock, the msg rbtree/list is empty and new
    calls will not see those in the newly populated tmp_msg list, and
    therefore they cannot access the delayed msg freeing pointers, which
    is good. Also the fact that the node_cache is now freed before the
    actual messages seems to be harmless as this is wanted for
    msg_insert() avoiding GFP_ATOMIC allocations, and after releasing the
    info->lock the thing is freed anyway so it should not change things"

    Link: http://lkml.kernel.org/r/1552029161-4957-1-git-send-email-lirongqing@baidu.com
    Signed-off-by: Li RongQing
    Signed-off-by: Zhang Yu
    Reviewed-by: Davidlohr Bueso
    Cc: Manfred Spraul
    Cc: Arnd Bergmann
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Li Rongqing
     
  • The clk rate is always stored in clk_core but might be out of date and
    require calls to update from hardware.

    Deal with that case by printing a (c) suffix.

    Link: http://lkml.kernel.org/r/1a474318982a5f0125f2360c4161029b17f56bd1.1556881728.git.leonard.crestez@nxp.com
    Signed-off-by: Leonard Crestez
    Cc: Jan Kiszka
    Cc: Jason Wessel
    Cc: Kieran Bingham
    Cc: Stephen Boyd
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Leonard Crestez
     
  • An incorrect argument to list_for_each is an internal error in gdb
    scripts so a TypeError should be raised. The gdb.GdbError exception
    type is intended for user errors such as incorrect invocation.

    Drop the type assertion in list_for_each_entry because list_for_each
    isn't going to suddenly yield something else.

    Applies to both list and hlist

    Link: http://lkml.kernel.org/r/c1d3fd4db13d999a3ba57f5bbc1924862d824f61.1556881728.git.leonard.crestez@nxp.com
    Signed-off-by: Leonard Crestez
    Reviewed-by: Stephen Boyd
    Cc: Jan Kiszka
    Cc: Jason Wessel
    Cc: Kieran Bingham
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Leonard Crestez
     
  • Finding an individual clk_core requires walking the tree which can be
    quite complicated so add a helper for easy access.

    (gdb) print *(struct clk_scu*)$lx_clk_core_lookup("uart0_clk")->hw

    Link: http://lkml.kernel.org/r/Message-ID:
    Signed-off-by: Leonard Crestez
    Cc: Jan Kiszka
    Cc: Jason Wessel
    Cc: Kieran Bingham
    Cc: Stephen Boyd
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Leonard Crestez
     
  • Add an lx-clk-summary command which prints a subset of
    /sys/kernel/debug/clk/clk_summary.

    This can be used to examine hangs caused by clk not being enabled.

    Link: http://lkml.kernel.org/r/Message-ID:
    Signed-off-by: Leonard Crestez
    Cc: Jan Kiszka
    Cc: Jason Wessel
    Cc: Kieran Bingham
    Cc: Stephen Boyd
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Leonard Crestez
     
  • This allows easily examining kernel hlists in python.

    Link: http://lkml.kernel.org/r/Message-ID:
    Signed-off-by: Leonard Crestez
    Reviewed-by: Stephen Boyd
    Cc: Jason Wessel
    Cc: Jan Kiszka
    Cc: Kieran Bingham
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Leonard Crestez
     
  • These scripts have some pep8 style warnings. Fix them up so that this
    directory is all pep8 clean.

    Link: http://lkml.kernel.org/r/20190329220844.38234-6-swboyd@chromium.org
    Signed-off-by: Stephen Boyd
    Cc: Douglas Anderson
    Cc: Nikolay Borisov
    Cc: Kieran Bingham
    Cc: Jan Kiszka
    Cc: Jackie Liu
    Cc: Jason Wessel
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stephen Boyd
     
  • Implement a command to print the timer list, much like how
    /proc/timer_list is implemented. This can be used to look at the
    pending timers on a crashed system.

    [swboyd@chromium.org: v2]
    Link: http://lkml.kernel.org/r/20190329220844.38234-5-swboyd@chromium.org
    Link: http://lkml.kernel.org/r/20190325184522.260535-5-swboyd@chromium.org
    Signed-off-by: Stephen Boyd
    Cc: Douglas Anderson
    Cc: Nikolay Borisov
    Cc: Kieran Bingham
    Cc: Jan Kiszka
    Cc: Jackie Liu
    Cc: Jason Wessel
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stephen Boyd
     
  • Implement gdb functions for rb_first(), rb_last(), rb_next(), and
    rb_prev(). These can be useful to iterate through the kernel's
    red-black trees.

    [swboyd@chromium.org: v2]
    Link: http://lkml.kernel.org/r/20190329220844.38234-4-swboyd@chromium.org
    Link: http://lkml.kernel.org/r/20190325184522.260535-4-swboyd@chromium.org
    Signed-off-by: Stephen Boyd
    Cc: Douglas Anderson
    Cc: Nikolay Borisov
    Cc: Kieran Bingham
    Cc: Jan Kiszka
    Cc: Jackie Liu
    Cc: Jason Wessel
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stephen Boyd
     
  • lx-configdump dumps the contents of the gzipped .config to a text
    file when the config is included in the kernel with CONFIG_IKCONFIG. By
    default, the file written is called config.txt, but it can be any user
    supplied filename as well. If the kernel config is in a module
    (configs.ko), then it can be loaded along with symbols for the module
    loaded with 'lx-symbols' and then this command will still work.

    Obviously if you have the whole vmlinux then this can also be achieved
    with scripts/extract-ikconfig, but this gdb script can be useful to
    confirm that the memory contents of the config in memory and the vmlinux
    contents on disk match what is expected.

    [swboyd@chromium.org: v2]
    Link: http://lkml.kernel.org/r/20190329220844.38234-3-swboyd@chromium.org
    Link: http://lkml.kernel.org/r/20190325184522.260535-3-swboyd@chromium.org
    Signed-off-by: Stephen Boyd
    Cc: Douglas Anderson
    Cc: Nikolay Borisov
    Cc: Kieran Bingham
    Cc: Jan Kiszka
    Cc: Jackie Liu
    Cc: Jason Wessel
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stephen Boyd
     
  • Patch series "gdb script for kconfig and timer list".

    This is a handful of changes to the kernel's gdb scripts to do some more
    debugging with kgdb. The first patch allows the vmlinux to be reloaded
    from where it was specified on the command line so that this set of
    scripts can be used from anywhere. The second patch adds a script to
    dump the config.gz to a file on the host debugging machine. The third
    patch adds some rb tree utilities and the last patch uses those rb tree
    walking utilities to dump out the contents of /proc/timer_list from a
    system under debug.

    This patch (of 5):

    If I run 'gdb ' and there's the vmlinux-gdb.py file
    there I can properly see symbols and use the lx commands provided by the
    GDB scripts. But once I run 'lx-symbols' at the command prompt, gdb
    reloads the vmlinux symbols assuming that this script was run from the
    directory that has vmlinux at the root. That isn't always true, but we
    could just look and see what symbols were already loaded and use that
    instead. Let's do that so this can work by being invoked anywhere.

    Link: http://lkml.kernel.org/r/20190325184522.260535-2-swboyd@chromium.org
    Signed-off-by: Stephen Boyd
    Cc: Douglas Anderson
    Cc: Nikolay Borisov
    Cc: Kieran Bingham
    Cc: Jan Kiszka
    Cc: Jackie Liu
    Cc: Jason Wessel
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stephen Boyd
     
  • This patch implements the PPS ECHO functionality for pps-gpio, that
    sysfs claims is available already.

    Configuration is done via device tree bindings.

    No changes are made to userspace interfaces.

    This patch was originally written by Lukas Senger as part of a masters
    thesis project and modified for inclusion into the linux kernel by Tom
    Burkart.

    Link: http://lkml.kernel.org/r/20190324043305.6627-4-tom@aussec.com
    Signed-off-by: Tom Burkart
    Acked-by: Rodolfo Giometti
    Signed-off-by: Lukas Senger
    Cc: Philipp Zabel
    Cc: Rob Herring
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tom Burkart
     
  • This patch implements the device tree binding changes required for the
    PPS ECHO functionality for pps-gpio, that sysfs claims is available
    already.

    It adds two DT properties for configuring the PPS ECHO functionality.

    This patch is provided separated from the rest of the patch per
    Documentation/devicetree/bindings/submitting-patches.txt.

    This patch was originally written by Lukas Senger as part of a masters
    thesis project and modified for inclusion into the linux kernel by Tom
    Burkart.

    Link: http://lkml.kernel.org/r/20190324043305.6627-3-tom@aussec.com
    Signed-off-by: Tom Burkart
    Signed-off-by: Lukas Senger
    Acked-by: Rodolfo Giometti
    Reviewed-by: Rob Herring
    Cc: Philipp Zabel
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tom Burkart
     
  • This patch changes the GPIO access for the pps-gpio driver from the
    integer based API to the descriptor based API.

    The integer based API is considered deprecated and the descriptor based
    API is the preferred way to access GPIOs as per
    Documentation/driver-api/gpio/intro.rst

    No changes are made to userspace interfaces.

    Link: http://lkml.kernel.org/r/20190324043305.6627-2-tom@aussec.com
    Signed-off-by: Tom Burkart
    Acked-by: Rodolfo Giometti
    Reviewed-by: Philipp Zabel
    Cc: Lukas Senger
    Cc: Rob Herring
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tom Burkart
     
  • Allow specifying reboot_mode for panic only. This is needed on systems
    where ramoops is used to store panic logs, and user wants to use warm
    reset to preserve those, while still having cold reset on normal
    reboots.

    Link: http://lkml.kernel.org/r/20190322004735.27702-1-aaro.koskinen@iki.fi
    Signed-off-by: Aaro Koskinen
    Reviewed-by: Kees Cook
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Aaro Koskinen
     
  • When kernel panic happens, it will first print the panic call stack,
    then the ending msg like:

    [ 35.743249] ---[ end Kernel panic - not syncing: Fatal exception
    [ 35.749975] ------------[ cut here ]------------

    The above message are very useful for debugging.

    But if system is configured to not reboot on panic, say the
    "panic_timeout" parameter equals 0, it will likely print out many noisy
    message like WARN() call stack for each and every CPU except the panic
    one, messages like below:

    WARNING: CPU: 1 PID: 280 at kernel/sched/core.c:1198 set_task_cpu+0x183/0x190
    Call Trace:

    try_to_wake_up
    default_wake_function
    autoremove_wake_function
    __wake_up_common
    __wake_up_common_lock
    __wake_up
    wake_up_klogd_work_func
    irq_work_run_list
    irq_work_tick
    update_process_times
    tick_sched_timer
    __hrtimer_run_queues
    hrtimer_interrupt
    smp_apic_timer_interrupt
    apic_timer_interrupt

    For people working in console mode, the screen will first show the panic
    call stack, but immediately overridden by these noisy extra messages,
    which makes debugging much more difficult, as the original context gets
    lost on screen.

    Also these noisy messages will confuse some users, as I have seen many bug
    reporters posted the noisy message into bugzilla, instead of the real
    panic call stack and context.

    Adding a flag "suppress_printk" which gets set in panic() to avoid those
    noisy messages, without changing current kernel behavior that both panic
    blinking and sysrq magic key can work as is, suggested by Petr Mladek.

    To verify this, make sure kernel is not configured to reboot on panic and
    in console
    # echo c > /proc/sysrq-trigger
    to see if console only prints out the panic call stack.

    Link: http://lkml.kernel.org/r/1551430186-24169-1-git-send-email-feng.tang@intel.com
    Signed-off-by: Feng Tang
    Suggested-by: Petr Mladek
    Reviewed-by: Petr Mladek
    Acked-by: Steven Rostedt (VMware)
    Acked-by: Sergey Senozhatsky
    Cc: Thomas Gleixner
    Cc: Kees Cook
    Cc: Borislav Petkov
    Cc: Andi Kleen
    Cc: Peter Zijlstra
    Cc: Greg Kroah-Hartman
    Cc: Jiri Slaby
    Cc: Sasha Levin
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Feng Tang
     
  • LLVM uses profiling data that's deliberately similar to GCC, but has a
    very different way of exporting that data. LLVM calls llvm_gcov_init()
    once per module, and provides a couple of callbacks that we can use to
    ask for more data.

    We care about the "writeout" callback, which in turn calls back into
    compiler-rt/this module to dump all the gathered coverage data to disk:

    llvm_gcda_start_file()
    llvm_gcda_emit_function()
    llvm_gcda_emit_arcs()
    llvm_gcda_emit_function()
    llvm_gcda_emit_arcs()
    [... repeats for each function ...]
    llvm_gcda_summary_info()
    llvm_gcda_end_file()

    This design is much more stateless and unstructured than gcc's, and is
    intended to run at process exit. This forces us to keep some local
    state about which module we're dealing with at the moment. On the other
    hand, it also means we don't depend as much on how LLVM represents
    profiling data internally.

    See LLVM's lib/Transforms/Instrumentation/GCOVProfiling.cpp for more
    details on how this works, particularly GCOVProfiler::emitProfileArcs(),
    GCOVProfiler::insertCounterWriteout(), and GCOVProfiler::insertFlush().

    [akpm@linux-foundation.org: coding-style fixes]
    Link: http://lkml.kernel.org/r/20190417225328.208129-1-trong@android.com
    Signed-off-by: Greg Hackmann
    Signed-off-by: Nick Desaulniers
    Signed-off-by: Tri Vo
    Co-developed-by: Nick Desaulniers
    Co-developed-by: Tri Vo
    Tested-by: Trilok Soni
    Tested-by: Prasad Sodagudi
    Tested-by: Tri Vo
    Tested-by: Daniel Mentz
    Tested-by: Petri Gynther
    Reviewed-by: Peter Oberparleiter
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Greg Hackmann
     
  • Document some things of note to gcov users:
    1. GCC gcov and Clang llvm-cov tools are not compatible.
    2. The use of GCC vs Clang is transparent at build-time.

    Also adjust the documentation to account for the removal of config symbol
    CONFIG_GCOV_FORMAT_AUTODETECT by commit 6a61b70b43c9 ("gcov: remove
    CONFIG_GCOV_FORMAT_AUTODETECT").

    Link: http://lkml.kernel.org/r/20190318025411.98014-4-trong@android.com
    Signed-off-by: Tri Vo
    Reviewed-by: Peter Oberparleiter
    Cc: Daniel Mentz
    Cc: Greg Hackmann
    Cc: Nick Desaulniers
    Cc: Petri Gynther
    Cc: Prasad Sodagudi
    Cc: Trilok Soni
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tri Vo
     
  • Patch series "gcov: add Clang support", v4.

    This patch (of 3):

    base.c contains a few callbacks specific to GCC's gcov implementation.
    Move these into their own module in preparation for Clang support.

    Link: http://lkml.kernel.org/r/20190318025411.98014-2-trong@android.com
    Signed-off-by: Greg Hackmann
    Signed-off-by: Nick Desaulniers
    Signed-off-by: Tri Vo
    Tested-by: Trilok Soni
    Tested-by: Prasad Sodagudi
    Tested-by: Tri Vo
    Reviewed-by: Peter Oberparleiter
    Cc: Daniel Mentz
    Cc: Petri Gynther
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Greg Hackmann
     
  • Fix sparse warning:

    fs/eventfd.c:26:1: warning:
    symbol 'eventfd_ida' was not declared. Should it be static?

    Link: http://lkml.kernel.org/r/20190413142348.34716-1-yuehaibing@huawei.com
    Signed-off-by: YueHaibing
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    YueHaibing
     
  • Finding endpoints of an IPC channel is one of essential task to
    understand how a user program works. Procfs and netlink socket provide
    enough hints to find endpoints for IPC channels like pipes, unix
    sockets, and pseudo terminals. However, there is no simple way to find
    endpoints for an eventfd file from userland. An inode number doesn't
    hint. Unlike pipe, all eventfd files share the same inode object.

    To provide the way to find endpoints of an eventfd file, this patch adds
    "eventfd-id" field to /proc/PID/fdinfo of eventfd as identifier.
    Integers managed by an IDA are used as ids.

    A tool like lsof can utilize the information to print endpoints.

    Link: http://lkml.kernel.org/r/20190327181823.20222-1-yamato@redhat.com
    Signed-off-by: Masatake YAMATO
    Cc: Al Viro
    Cc: Kees Cook
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Masatake YAMATO
     
  • Hash functions are not needed since idr is used now. Let's remove hash
    header file for cleanup.

    Link: http://lkml.kernel.org/r/20190430053319.95913-1-scuttimmy@gmail.com
    Signed-off-by: Timmy Li
    Cc: "Eric W. Biederman"
    Cc: Michal Hocko
    Cc: Matthew Wilcox
    Cc: Oleg Nesterov
    Cc: Mike Rapoport
    Cc: KJ Tsanaktsidis
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Timmy Li
     
  • Today, proc_do_large_bitmap() truncates a large write input buffer to
    PAGE_SIZE - 1, which may result in misparsed numbers at the (truncated)
    end of the buffer. Further, it fails to notify the caller that the
    buffer was truncated, so it doesn't get called iteratively to finish the
    entire input buffer.

    Tell the caller if there's more work to do by adding the skipped amount
    back to left/*lenp before returning.

    To fix the misparsing, reset the position if we have completely consumed
    a truncated buffer (or if just one char is left, which may be a "-" in a
    range), and ask the caller to come back for more.

    Link: http://lkml.kernel.org/r/20190320222831.8243-7-mcgrof@kernel.org
    Signed-off-by: Eric Sandeen
    Signed-off-by: Luis Chamberlain
    Acked-by: Kees Cook
    Cc: Eric Sandeen
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Eric Sandeen
     
  • The kernel has only two users of proc_do_large_bitmap(), the kernel CPU
    watchdog, and the ip_local_reserved_ports. Refer to watchdog_cpumask
    and ip_local_reserved_ports in Documentation for further details on
    these. When you input a large buffer into these, when it is larger than
    PAGE_SIZE- 1, the input data gets misparsed, and the user get
    incorrectly informed that the desired input value was set. This commit
    implements a test which mimics and exploits that use case, it uses a
    bitmap size, as in the watchdog case. The bitmap is used to test the
    bitmap proc handler, proc_do_large_bitmap().

    The next commit fixes this issue.

    [akpm@linux-foundation.org: move proc_do_large_bitmap() export to EOF]
    [mcgrof@kernel.org: use new target description for backward compatibility]
    [mcgrof@kernel.org: augment test number to 50, ran into issues with bash string comparisons when testing up to 50 cases.]
    [mcgrof@kernel.org: introduce and use verify_diff_proc_file() to use diff]
    [mcgrof@kernel.org: use mktemp for tmp file]
    [mcgrof@kernel.org: merge shell test and C code]
    [mcgrof@kernel.org: commit log love]
    [mcgrof@kernel.org: export proc_do_large_bitmap() to allow for the test
    [mcgrof@kernel.org: check for the return value when writing to the proc file]
    Link: http://lkml.kernel.org/r/20190320222831.8243-6-mcgrof@kernel.org
    Signed-off-by: Eric Sandeen
    Signed-off-by: Luis Chamberlain
    Acked-by: Kees Cook
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Eric Sandeen
     
  • On old kernels older new test knobs implemented on the test_sysctl
    module may not be available. This is expected, and the selftests test
    scripts should be able to run without failures on older kernels.

    Generalize a solution so that we test for each required test target file
    for each test by requiring each test description to annotate their
    respective test target file. If the target file does not exist, we skip
    the test gracefully.

    Link: http://lkml.kernel.org/r/20190320222831.8243-5-mcgrof@kernel.org
    Signed-off-by: Luis Chamberlain
    Acked-by: Kees Cook
    Cc: Eric Sandeen
    Cc: Eric Sandeen
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Luis Chamberlain
     
  • When verify_diff_w() is used we care about the result, not the verbose
    output, and although we use -q, that still gives us a chatty message
    about if the files differ or not. Since verify_diff_w() uses stdinput
    the chatty message says whether or not "-" matches the target file, and
    this just seems rather odd. Better to just ignore that messsage all
    together, what we really care about i sthe results, the return value and
    we check for that.

    Link: http://lkml.kernel.org/r/20190320222831.8243-4-mcgrof@kernel.org
    Signed-off-by: Luis Chamberlain
    Acked-by: Kees Cook
    Cc: Eric Sandeen
    Cc: Eric Sandeen
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Luis Chamberlain
     
  • Currently the test script checks for the existence of the sysctl test
    module's directory path prior to loading it. We must first try to load
    the module prior to checking for that path. This fixes the order for
    the load / test.

    Link: http://lkml.kernel.org/r/20190320222831.8243-3-mcgrof@kernel.org
    Signed-off-by: Luis Chamberlain
    Acked-by: Kees Cook
    Cc: Eric Sandeen
    Cc: Eric Sandeen
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Luis Chamberlain
     
  • Patch series "sysctl: add pending proc_do_large_bitmap fix".

    Eric sent a fix out for proc_do_large_bitmap() last month for when using
    a large input buffer. After patch review a test case for the issue was
    built and submitted. I noticed there were a few issues with the tests,
    but instead of just asking Eric to address them I've taken care of them
    and ammended the commit where necessary. There's a few issues he
    reported which I also address and fix in this series.

    Since we *do* expect users of these scripts to also use them on older
    kernels, I've also addressed not breaking calling the script for them,
    and gives us an easy way to easily extend our tests cases for future
    kernels as well.

    Before anyone considers these for stable as minor fixes, I'd recommend
    we also address the discrepancy on the read side of things: modify the
    test script to use diff against the target file instead of using the
    temp file.

    This patch (of 6):

    We already call test_reqs(), no need to call it twice.

    Link: http://lkml.kernel.org/r/20190320222831.8243-2-mcgrof@kernel.org
    Signed-off-by: Luis Chamberlain
    Acked-by: Kees Cook
    Cc: Eric Sandeen
    Cc: Eric Sandeen
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Luis Chamberlain
     
  • Currently when userspace gives us a values that overflow e.g. file-max
    and other callers of __do_proc_doulongvec_minmax() we simply ignore the
    new value and leave the current value untouched.

    This can be problematic as it gives the illusion that the limit has
    indeed be bumped when in fact it failed. This commit makes sure to
    return EINVAL when an overflow is detected. Please note that this is a
    userspace facing change.

    Link: http://lkml.kernel.org/r/20190210203943.8227-4-christian@brauner.io
    Signed-off-by: Christian Brauner
    Acked-by: Luis Chamberlain
    Cc: Kees Cook
    Cc: Alexey Dobriyan
    Cc: Al Viro
    Cc: Dominik Brodowski
    Cc: "Eric W. Biederman"
    Cc: Joe Lawrence
    Cc: Waiman Long
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christian Brauner
     
  • Switch to bitmap_zalloc() to show clearly what we are allocating.
    Besides that it returns pointer of bitmap type instead of opaque void *.

    Link: http://lkml.kernel.org/r/20190304094037.57756-1-andriy.shevchenko@linux.intel.com
    Signed-off-by: Andy Shevchenko
    Acked-by: Kees Cook
    Reviewed-by: Andrew Morton
    Cc: Luis Chamberlain
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Shevchenko
     
  • In case create_workqueue fails, the fix releases resources and returns
    -ENOMEM to avoid NULL pointer dereference.

    Signed-off-by: Kangjie Lu
    Acked-by: Alexandre Bounine
    Cc: Matt Porter
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Kangjie Lu
     
  • cpumask_parse() finds first occurrence of either or strchr() and
    strlen(). We can do it better with a single call of strchrnul().

    [akpm@linux-foundation.org: remove unneeded cast]
    Link: http://lkml.kernel.org/r/20190409204208.12190-1-ynorov@marvell.com
    Signed-off-by: Yury Norov
    Acked-by: Rasmus Villemoes
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Yury Norov
     
  • Test that trivially recursing script onto itself doesn't work.

    Note: this is different test from ELOOP tests in execveat.c Those test
    that execveat(2) doesn't follow symlinks when told to do so.

    Link: http://lkml.kernel.org/r/20190423192720.GA21433@avx2
    Signed-off-by: Alexey Dobriyan
    Cc: Shuah Khan
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexey Dobriyan
     
  • struct linux_binprm::buf is the first field and it is exactly 128 bytes
    in size. It means that on x86_64 all accesses to other fields will go
    though [r64 + disp32] addressing mode which is 3 bytes bloatier than
    [r64 + disp8] addressing mode. Given that accesses to other fields
    outnumber accesses to ->buf, move it down.

    Space savings (x86_64 defconfig):
    more on distro configs because LSMs actively dereference "bprm"
    but do not care about first 128 bytes of the executable itself.

    add/remove: 0/0 grow/shrink: 0/24 up/down: 0/-492 (-492)
    Function old new delta
    selinux_bprm_committing_creds 552 549 -3
    finalize_exec 94 91 -3
    __audit_log_bprm_fcaps 283 280 -3
    __audit_bprm 39 36 -3
    perf_trace_sched_process_exec 347 341 -6
    install_exec_creds 105 99 -6
    cap_bprm_set_creds.cold 60 54 -6
    would_dump 137 128 -9
    load_script 637 628 -9
    bprm_change_interp 61 52 -9
    trace_event_raw_event_sched_process_exec 260 250 -10
    search_binary_handler 255 240 -15
    remove_arg_zero 295 277 -18
    free_bprm 119 101 -18
    prepare_binprm 379 360 -19
    setup_new_exec 336 315 -21
    flush_old_exec 1638 1617 -21
    copy_strings.isra 746 724 -22
    setup_arg_pages 559 530 -29
    load_misc_binary 1151 1118 -33
    selinux_bprm_set_creds 792 753 -39
    load_elf_binary 11111 11072 -39
    cap_bprm_set_creds 1496 1454 -42
    __do_execve_file.isra 2395 2286 -109

    Link: http://lkml.kernel.org/r/20190421165025.GA26843@avx2
    Signed-off-by: Alexey Dobriyan
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexey Dobriyan
     
  • ->recursion_depth is changed only by current, therefore decrementing can
    be done without taking any locks.

    Link: http://lkml.kernel.org/r/20190417213150.GA26474@avx2
    Signed-off-by: Alexey Dobriyan
    Reviewed-by: Andrew Morton
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexey Dobriyan
     
  • There is a plan to build the kernel with -Wimplicit-fallthrough and this
    place in the code produced a warning (W=1).

    This commit remove the following warning:

    kernel/signal.c:795:13: warning: this statement may fall through [-Wimplicit-fallthrough=]

    Link: http://lkml.kernel.org/r/20190114203505.17875-1-malat@debian.org
    Signed-off-by: Mathieu Malaterre
    Acked-by: Gustavo A. R. Silva
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mathieu Malaterre
     
  • fsync() needs to make sure the data & meta-data of file are persistent
    after the return of fsync(), even when a power-failure occurs later. In
    the case of fat-fs, the FAT belongs to the meta-data of file, so we need
    to issue a flush after the writeback of FAT instead before.

    Also bail out early when any stage of fsync fails.

    Link: http://lkml.kernel.org/r/20190409030158.136316-1-houtao1@huawei.com
    Signed-off-by: Hou Tao
    Acked-by: OGAWA Hirofumi
    Cc: Al Viro
    Cc: Jan Kara
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Hou Tao
     
  • csum_partial() gives different results for little-endian and big-endian
    hosts. This causes images created on little-endian hosts and mounted on
    big endian hosts to see csum mismatches. This causes an endianness bug.
    Sparse gives a warning as csum_partial returns a restricted integer type
    __wsum_t and xattr_hash expects __u32. This warning acts as a reminder
    for this bug and should not be suppressed.

    This comment aims to convey these endianness issues.

    [akpm@linux-foundation.org: coding-style fixes]
    Link: http://lkml.kernel.org/r/20190423161831.GA15387@bharath12345-Inspiron-5559
    Signed-off-by: Bharath Vedartham
    Cc: Al Viro
    Cc: Jann Horn
    Cc: Jeff Mahoney
    Cc: Jan Kara
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Bharath Vedartham
     
  • Add a description of the "ignore" pseudo mount option that can be used
    to provide a generic indicator to applications that the mount entry
    should be ignored when displaying mount information.

    Link: http://lkml.kernel.org/r/155287084617.12593.812733161112154904.stgit@pluto.themaw.net
    Signed-off-by: Ian Kent
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent