14 Apr, 2015

3 commits

  • Pull driver core updates from Greg KH:
    "Here's the driver-core / kobject / lz4 tree update for 4.1-rc1.

    Everything here has been in linux-next for a while with no reported
    issues. It's mostly just coding style cleanups, with other minor
    changes in here as well, nothing big"

    * tag 'driver-core-4.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (32 commits)
    debugfs: allow bad parent pointers to be passed in
    stable_kernel_rules: Add clause about specification of kernel versions to patch.
    kobject: WARN as tip when call kobject_get() to a kobject not initialized
    lib/lz4: Pull out constant tables
    drivers: platform: parse IRQ flags from resources
    driver core: Make probe deferral more quiet
    drivers/core/of: Add symlink to device-tree from devices with an OF node
    device: Add dev_of_node() accessor
    drivers: base: fw: fix ret value when loading fw
    firmware: Avoid manual device_create_file() calls
    drivers/base: cacheinfo: validate device node for all the caches
    drivers/base: use tabs where possible in code indentation
    driver core: add missing blank line after declaration
    drivers: base: node: Delete space after pointer declaration
    drivers: base: memory: Use tabs instead of spaces
    firmware_class: Fix whitespace and indentation
    drivers: base: dma-mapping: Erase blank space after pointer
    drivers: base: class: Add a blank line after declarations
    attribute_container: fix missing blank lines after declarations
    drivers: base: memory: Fix switch indent
    ...

    Linus Torvalds
     
  • Pull timer updates from Ingo Molnar:
    "The main changes in this cycle were:

    - clockevents state machine cleanups and enhancements (Viresh Kumar)

    - clockevents broadcast notifier horror to state machine conversion
    and related cleanups (Thomas Gleixner, Rafael J Wysocki)

    - clocksource and timekeeping core updates (John Stultz)

    - clocksource driver updates and fixes (Ben Dooks, Dmitry Osipenko,
    Hans de Goede, Laurent Pinchart, Maxime Ripard, Xunlei Pang)

    - y2038 fixes (Xunlei Pang, John Stultz)

    - NMI-safe ktime_get_raw_fast() and general refactoring of the clock
    code, in preparation to perf's per event clock ID support (Peter
    Zijlstra)

    - generic sched/clock fixes, optimizations and cleanups (Daniel
    Thompson)

    - clockevents cpu_down() race fix (Preeti U Murthy)"

    * 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (94 commits)
    timers/PM: Drop unnecessary braces from tick_freeze()
    timers/PM: Fix up tick_unfreeze()
    timekeeping: Get rid of stale comment
    clockevents: Cleanup dead cpu explicitely
    clockevents: Make tick handover explicit
    clockevents: Remove broadcast oneshot control leftovers
    sched/idle: Use explicit broadcast oneshot control function
    ARM: Tegra: Use explicit broadcast oneshot control function
    ARM: OMAP: Use explicit broadcast oneshot control function
    intel_idle: Use explicit broadcast oneshot control function
    ACPI/idle: Use explicit broadcast control function
    ACPI/PAD: Use explicit broadcast oneshot control function
    x86/amd/idle, clockevents: Use explicit broadcast oneshot control functions
    clockevents: Provide explicit broadcast oneshot control functions
    clockevents: Remove the broadcast control leftovers
    ARM: OMAP: Use explicit broadcast control function
    intel_idle: Use explicit broadcast control function
    cpuidle: Use explicit broadcast control function
    ACPI/processor: Use explicit broadcast control function
    ACPI/PAD: Use explicit broadcast control function
    ...

    Linus Torvalds
     
  • Pull core locking changes from Ingo Molnar:
    "Main changes:

    - jump label asm preparatory work for PowerPC (Anton Blanchard)

    - rwsem optimizations and cleanups (Davidlohr Bueso)

    - mutex optimizations and cleanups (Jason Low)

    - futex fix (Oleg Nesterov)

    - remove broken atomicity checks from {READ,WRITE}_ONCE() (Peter
    Zijlstra)"

    * 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
    powerpc, jump_label: Include linux/jump_label.h to get HAVE_JUMP_LABEL define
    jump_label: Allow jump labels to be used in assembly
    jump_label: Allow asm/jump_label.h to be included in assembly
    locking/mutex: Further simplify mutex_spin_on_owner()
    locking: Remove atomicy checks from {READ,WRITE}_ONCE
    locking/rtmutex: Rename argument in the rt_mutex_adjust_prio_chain() documentation as well
    locking/rwsem: Fix lock optimistic spinning when owner is not running
    locking: Remove ACCESS_ONCE() usage
    locking/rwsem: Check for active lock before bailing on spinning
    locking/rwsem: Avoid deceiving lock spinners
    locking/rwsem: Set lock ownership ASAP
    locking/rwsem: Document barrier need when waking tasks
    locking/futex: Check PF_KTHREAD rather than !p->mm to filter out kthreads
    locking/mutex: Refactor mutex_spin_on_owner()
    locking/mutex: In mutex_spin_on_owner(), return true when owner changes

    Linus Torvalds
     

04 Apr, 2015

1 commit


01 Apr, 2015

1 commit

  • This is especially important in cases where the kernel allocs a new
    structure and expects a field to be set from a netlink attribute. If such
    attribute is shorter than expected, the rest of the field is left containing
    previous data. When such field is read back by the user space, kernel memory
    content is leaked.

    Signed-off-by: Jiri Benc
    Acked-by: Thomas Graf
    Signed-off-by: David S. Miller

    Jiri Benc
     

31 Mar, 2015

2 commits

  • Linux 3.19 commit 69c953c ("lib/lcm.c: lcm(n,0)=lcm(0,n) is 0, not n")
    caused blk_stack_limits() to not properly stack queue_limits for stacked
    devices (e.g. DM).

    Fix this regression by establishing lcm_not_zero() and switching
    blk_stack_limits() over to using it.

    DM uses blk_set_stacking_limits() to establish the initial top-level
    queue_limits that are then built up based on underlying devices' limits
    using blk_stack_limits(). In the case of optimal_io_size (io_opt)
    blk_set_stacking_limits() establishes a default value of 0. With commit
    69c953c, lcm(0, n) is no longer n, which compromises proper stacking of
    the underlying devices' io_opt.

    Test:
    $ modprobe scsi_debug dev_size_mb=10 num_tgts=1 opt_blks=1536
    $ cat /sys/block/sde/queue/optimal_io_size
    786432
    $ dmsetup create node --table "0 100 linear /dev/sde 0"

    Before this fix:
    $ cat /sys/block/dm-5/queue/optimal_io_size
    0

    After this fix:
    $ cat /sys/block/dm-5/queue/optimal_io_size
    786432

    Signed-off-by: Mike Snitzer
    Cc: stable@vger.kernel.org # 3.19+
    Acked-by: Martin K. Petersen
    Signed-off-by: Jens Axboe

    Mike Snitzer
     
  • Signed-off-by: Ingo Molnar

    Ingo Molnar
     

25 Mar, 2015

2 commits

  • call kobject_get() to kojbect that is not initalized or released will only
    leave following like call trace to us:

    -----------[ cut here ]------------
    [ 54.545816] WARNING: CPU: 0 PID: 213 at include/linux/kref.h:47
    kobject_get+0x41/0x50()
    [ 54.642595] Modules linked in: i2c_i801(+) mfd_core shpchp(+)
    acpi_cpufreq(+) edac_core ioatdma(+) xfs libcrc32c ast syscopyarea ixgbe
    sysfillrect sysimgblt sr_mod sd_mod drm_kms_helper igb mdio cdrom e1000e ahci
    dca ttm libahci uas drm i2c_algo_bit ptp megaraid_sas libata usb_storage
    i2c_core pps_core dm_mirror dm_region_hash dm_log dm_mod
    [ 55.007264] CPU: 0 PID: 213 Comm: kworker/0:2 Not tainted
    3.18.5
    [ 55.099970] Hardware name: Oracle Corporation SUN FIRE X4170 M2 SERVER
    /ASSY,MOTHERBOARD,X4170, BIOS 08120104 05/08/2012
    [ 55.239736] Workqueue: kacpi_notify acpi_os_execute_deferred
    [ 55.308598] 0000000000000000 00000000bd730b61 ffff88046742baf8
    ffffffff816b7edb
    [ 55.398305] 0000000000000000 0000000000000000 ffff88046742bb38
    ffffffff81078ae1
    [ 55.488040] ffff88046742bbd8 ffff8806706b3000 0000000000000292
    0000000000000000
    [ 55.577776] Call Trace:
    [ 55.608228] [] dump_stack+0x46/0x58
    [ 55.670895] [] warn_slowpath_common+0x81/0xa0
    [ 55.743952] [] warn_slowpath_null+0x1a/0x20
    [ 55.814929] [] kobject_get+0x41/0x50
    [ 55.878654] [] cpufreq_cpu_get+0x75/0xc0
    [ 55.946528] [] cpufreq_update_policy+0x2e/0x1f0

    The above issue was casued by a race condition, if there is a WARN in
    kobject_get() of the kobject is not initialized, that would save us much
    time to debug it.

    Signed-off-by: Ethan Zhao
    Signed-off-by: Greg Kroah-Hartman

    Ethan Zhao
     
  • There's no reason to allocate the dec{32,64}table on the stack; it
    just wastes a bunch of instructions setting them up and, of course,
    also consumes quite a bit of stack. Using size_t for such small
    integers is a little excessive.

    $ scripts/bloat-o-meter /tmp/built-in.o lib/built-in.o
    add/remove: 2/2 grow/shrink: 2/0 up/down: 1304/-1548 (-244)
    function old new delta
    lz4_decompress_unknownoutputsize 55 718 +663
    lz4_decompress 55 632 +577
    dec64table - 32 +32
    dec32table - 32 +32
    lz4_uncompress 747 - -747
    lz4_uncompress_unknownoutputsize 801 - -801

    The now inlined lz4_uncompress functions used to have a stack
    footprint of 176 bytes (according to -fstack-usage); their inlinees
    have increased their stack use from 32 bytes to 48 and 80 bytes,
    respectively.

    Signed-off-by: Rasmus Villemoes
    Signed-off-by: Greg Kroah-Hartman

    Rasmus Villemoes
     

17 Mar, 2015

1 commit

  • If the part of the compression data are corrupted, or the compression
    data is totally fake, the memory access over the limit is possible.

    This is the log from my system usning lz4 decompression.
    [6502]data abort, halting
    [6503]r0 0x00000000 r1 0x00000000 r2 0xdcea0ffc r3 0xdcea0ffc
    [6509]r4 0xb9ab0bfd r5 0xdcea0ffc r6 0xdcea0ff8 r7 0xdce80000
    [6515]r8 0x00000000 r9 0x00000000 r10 0x00000000 r11 0xb9a98000
    [6522]r12 0xdcea1000 usp 0x00000000 ulr 0x00000000 pc 0x820149bc
    [6528]spsr 0x400001f3
    and the memory addresses of some variables at the moment are
    ref:0xdcea0ffc, op:0xdcea0ffc, oend:0xdcea1000

    As you can see, COPYLENGH is 8bytes, so @ref and @op can access the momory
    over @oend.

    Signed-off-by: JeHyeon Yeon
    Reviewed-by: David Sterba
    Signed-off-by: Greg Kroah-Hartman

    JeHyeon Yeon
     

14 Mar, 2015

1 commit

  • Pull gadgetfs fixes from Al Viro:
    "Assorted fixes around AIO on gadgetfs: leaks, use-after-free, troubles
    caused by ->f_op flipping"

    * 'gadget' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    gadgetfs: really get rid of switching ->f_op
    gadgetfs: get rid of flipping ->f_op in ep_config()
    gadget: switch ep_io_operations to ->read_iter/->write_iter
    gadgetfs: use-after-free in ->aio_read()
    gadget/function/f_fs.c: switch to ->{read,write}_iter()
    gadget/function/f_fs.c: use put iov_iter into io_data
    gadget/function/f_fs.c: close leaks
    move iov_iter.c from mm/ to lib/
    new helper: dup_iter()

    Linus Torvalds
     

13 Mar, 2015

1 commit

  • Recently there's been requests for better sanity
    checking in the time code, so that it's more clear
    when something is going wrong, since timekeeping issues
    could manifest in a large number of strange ways in
    various subsystems.

    Thus, this patch adds some extra infrastructure to
    add a check to update_wall_time() to print two new
    warnings:

    1) if we see the call delayed beyond the 'max_cycles'
    overflow point,

    2) or if we see the call delayed beyond the clocksource's
    'max_idle_ns' value, which is currently 50% of the
    overflow point.

    This extra infrastructure is conditional on
    a new CONFIG_DEBUG_TIMEKEEPING option, also
    added in this patch - default off.

    Tested this a bit by halting qemu for specified
    lengths of time to trigger the warnings.

    Signed-off-by: John Stultz
    Cc: Dave Jones
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Prarit Bhargava
    Cc: Richard Cochran
    Cc: Stephen Boyd
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/1426133800-29329-5-git-send-email-john.stultz@linaro.org
    [ Improved the changelog and the messages a bit. ]
    Signed-off-by: Ingo Molnar

    John Stultz
     

10 Mar, 2015

1 commit

  • …git/rostedt/linux-trace

    Pull seq-buf/ftrace fixes from Steven Rostedt:
    "This includes fixes for seq_buf_bprintf() truncation issue. It also
    contains fixes to ftrace when /proc/sys/kernel/ftrace_enabled and
    function tracing are started. Doing the following causes some issues:

    # echo 0 > /proc/sys/kernel/ftrace_enabled
    # echo function_graph > /sys/kernel/debug/tracing/current_tracer
    # echo 1 > /proc/sys/kernel/ftrace_enabled
    # echo nop > /sys/kernel/debug/tracing/current_tracer
    # echo function_graph > /sys/kernel/debug/tracing/current_tracer

    As well as with function tracing too. Pratyush Anand first reported
    this issue to me and supplied a patch. When I tested this on my x86
    test box, it caused thousands of backtraces and warnings to appear in
    dmesg, which also caused a denial of service (a warning for every
    function that was listed). I applied Pratyush's patch but it did not
    fix the issue for me. I looked into it and found a slight problem
    with trampoline accounting. I fixed it and sent Pratyush a patch, but
    he said that it did not fix the issue for him.

    I later learned tha Pratyush was using an ARM64 server, and when I
    tested on my ARM board, I was able to reproduce the same issue as
    Pratyush. After applying his patch, it fixed the problem. The above
    test uncovered two different bugs, one in x86 and one in ARM and
    ARM64. As this looked like it would affect PowerPC, I tested it on my
    PPC64 box. It too broke, but neither the patch that fixed ARM or x86
    fixed this box (the changes were all in generic code!). The above
    test, uncovered two more bugs that affected PowerPC. Again, the
    changes were only done to generic code. It's the way the arch code
    expected things to be done that was different between the archs. Some
    where more sensitive than others.

    The rest of this series fixes the PPC bugs as well"

    * tag 'trace-fixes-v4.0-rc2-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
    ftrace: Fix ftrace enable ordering of sysctl ftrace_enabled
    ftrace: Fix en(dis)able graph caller when en(dis)abling record via sysctl
    ftrace: Clear REGS_EN and TRAMP_EN flags on disabling record via sysctl
    seq_buf: Fix seq_buf_bprintf() truncation
    seq_buf: Fix seq_buf_vprintf() truncation

    Linus Torvalds
     

05 Mar, 2015

1 commit

  • In seq_buf_bprintf(), bstr_printf() is used to copy the format into the
    buffer remaining in the seq_buf structure. The return of bstr_printf()
    is the amount of characters written to the buffer excluding the '\0',
    unless the line was truncated!

    If the line copied does not fit, it is truncated, and a '\0' is added
    to the end of the buffer. But in this case, '\0' is included in the length
    of the line written. To know if the buffer had overflowed, the return
    length will be the same or greater than the length of the buffer passed in.

    The check in seq_buf_bprintf() only checked if the length returned from
    bstr_printf() would fit in the buffer, as the seq_buf_bprintf() is only
    to be an all or nothing command. It either writes all the string into
    the seq_buf, or none of it. If the string is truncated, the pointers
    inside the seq_buf must be reset to what they were when the function was
    called. This is not the case. On overflow, it copies only part of the string.

    The fix is to change the overflow check to see if the length returned from
    bstr_printf() is less than the length remaining in the seq_buf buffer, and not
    if it is less than or equal to as it currently does. Then seq_buf_bprintf()
    will know if the write from bstr_printf() was truncated or not.

    Link: http://lkml.kernel.org/r/1425500481.2712.27.camel@perches.com

    Cc: stable@vger.kernel.org
    Reported-by: Joe Perches
    Signed-off-by: Steven Rostedt

    Steven Rostedt (Red Hat)
     

04 Mar, 2015

2 commits

  • In seq_buf_vprintf(), vsnprintf() is used to copy the format into the
    buffer remaining in the seq_buf structure. The return of vsnprintf()
    is the amount of characters written to the buffer excluding the '\0',
    unless the line was truncated!

    If the line copied does not fit, it is truncated, and a '\0' is added
    to the end of the buffer. But in this case, '\0' is included in the length
    of the line written. To know if the buffer had overflowed, the return
    length will be the same as the length of the buffer passed in.

    The check in seq_buf_vprintf() only checked if the length returned from
    vsnprintf() would fit in the buffer, as the seq_buf_vprintf() is only
    to be an all or nothing command. It either writes all the string into
    the seq_buf, or none of it. If the string is truncated, the pointers
    inside the seq_buf must be reset to what they were when the function was
    called. This is not the case. On overflow, it copies only part of the string.

    The fix is to change the overflow check to see if the length returned from
    vsnprintf() is less than the length remaining in the seq_buf buffer, and not
    if it is less than or equal to as it currently does. Then seq_buf_vprintf()
    will know if the write from vsnpritnf() was truncated or not.

    Cc: stable@vger.kernel.org
    Signed-off-by: Steven Rostedt

    Steven Rostedt (Red Hat)
     
  • Pull networking fixes from David Miller:

    1) If an IPVS tunnel is created with a mixed-family destination
    address, it cannot be removed. Fix from Alexey Andriyanov.

    2) Fix module refcount underflow in netfilter's nft_compat, from Pablo
    Neira Ayuso.

    3) Generic statistics infrastructure can reference variables sitting on
    a released function stack, therefore use dynamic allocation always.
    Fix from Ignacy Gawędzki.

    4) skb_copy_bits() return value test is inverted in ip_check_defrag().

    5) Fix network namespace exit in openvswitch, we have to release all of
    the per-net vports. From Pravin B Shelar.

    6) Fix signedness bug in CAIF's cfpkt_iterate(), from Dan Carpenter.

    7) Fix rhashtable grow/shrink behavior, only expand during inserts and
    shrink during deletes. From Daniel Borkmann.

    8) Netdevice names with semicolons should never be allowed, because
    they serve as a separator. From Matthew Thode.

    9) Use {,__}set_current_state() where appropriate, from Fabian
    Frederick.

    10) Revert byte queue limits support in r8169 driver, it's causing
    regressions we can't figure out.

    11) tcp_should_expand_sndbuf() erroneously uses tp->packets_out to
    measure packets in flight, properly use tcp_packets_in_flight()
    instead. From Neal Cardwell.

    12) Fix accidental removal of support for bluetooth in CSR based Intel
    wireless cards. From Marcel Holtmann.

    13) We accidently added a behavioral change between native and compat
    tasks, wrt testing the MSG_CMSG_COMPAT bit. Just ignore it if the
    user happened to set it in a native binary as that was always the
    behavior we had. From Catalin Marinas.

    14) Check genlmsg_unicast() return valud in hwsim netlink tx frame
    handling, from Bob Copeland.

    15) Fix stale ->radar_required setting in mac80211 that can prevent
    starting new scans, from Eliad Peller.

    16) Fix memory leak in nl80211 monitor, from Johannes Berg.

    17) Fix race in TX index handling in xen-netback, from David Vrabel.

    18) Don't enable interrupts in amx-xgbe driver until all software et al.
    state is ready for the interrupt handler to run. From Thomas
    Lendacky.

    19) Add missing netlink_ns_capable() checks to rtnl_newlink(), from Eric
    W Biederman.

    20) The amount of header space needed in macvtap was not calculated
    properly, fix it otherwise we splat past the beginning of the
    packet. From Eric Dumazet.

    21) Fix bcmgenet TCP TX perf regression, from Jaedon Shin.

    22) Don't raw initialize or mod timers, use setup_timer() and
    mod_timer() instead. From Vaishali Thakkar.

    23) Fix software maintained statistics in bcmgenet and systemport
    drivers, from Florian Fainelli.

    24) DMA descriptor updates in sh_eth need proper memory barriers, from
    Ben Hutchings.

    25) Don't do UDP Fragmentation Offload on RAW sockets, from Michal
    Kubecek.

    26) Openvswitch's non-masked set actions aren't constructed properly
    into netlink messages, fix from Joe Stringer.

    * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (116 commits)
    openvswitch: Fix serialization of non-masked set actions.
    gianfar: Reduce logging noise seen due to phy polling if link is down
    ibmveth: Add function to enable live MAC address changes
    net: bridge: add compile-time assert for cb struct size
    udp: only allow UFO for packets from SOCK_DGRAM sockets
    sh_eth: Really fix padding of short frames on TX
    Revert "sh_eth: Enable Rx descriptor word 0 shift for r8a7790"
    sh_eth: Fix RX recovery on R-Car in case of RX ring underrun
    sh_eth: Ensure proper ordering of descriptor active bit write/read
    net/mlx4_en: Disbale GRO for incoming loopback/selftest packets
    net/mlx4_core: Fix wrong mask and error flow for the update-qp command
    net: systemport: fix software maintained statistics
    net: bcmgenet: fix software maintained statistics
    rxrpc: don't multiply with HZ twice
    rxrpc: terminate retrans loop when sending of skb fails
    net/hsr: Fix NULL pointer dereference and refcnt bugs when deleting a HSR interface.
    net: pasemi: Use setup_timer and mod_timer
    net: stmmac: Use setup_timer and mod_timer
    net: 8390: axnet_cs: Use setup_timer and mod_timer
    net: 8390: pcnet_cs: Use setup_timer and mod_timer
    ...

    Linus Torvalds
     

28 Feb, 2015

3 commits

  • If a hash table has 128 slots and 16384 elems, expand to 256 slots
    takes more than one second. For larger sets, a soft lockup is detected.

    Holding cpu for that long, even in a work queue is a show stopper
    for non preemptable kernels.

    cond_resched() at strategic points to allow process scheduler
    to reschedule us.

    Signed-off-by: Eric Dumazet
    Acked-by: Daniel Borkmann
    Signed-off-by: David S. Miller

    Eric Dumazet
     
  • Currently, all real users of rhashtable default their grow and shrink
    decision functions to rht_grow_above_75() and rht_shrink_below_30(),
    so that there's currently no need to have this explicitly selectable.

    It can/should be generic and private inside rhashtable until a real
    use case pops up. Since we can make this private, we'll save us this
    additional indirection layer and can improve insertion/deletion time
    as well.

    Reference: http://patchwork.ozlabs.org/patch/443040/
    Suggested-by: David S. Miller
    Signed-off-by: Daniel Borkmann
    Acked-by: Thomas Graf
    Signed-off-by: David S. Miller

    Daniel Borkmann
     
  • While commit c0c09bfdc415 ("rhashtable: avoid unnecessary wakeup for
    worker queue") rightfully moved part of the decision making of
    whether we should expand or shrink from the expand/shrink functions
    themselves into insert/delete functions in order to avoid unnecessary
    worker wake-ups, it however introduced a regression by doing so.

    Before that change, if no max_shift was specified (= 0) on rhashtable
    initialization, rhashtable_expand() would just grow unconditionally
    and lets the available memory be the limiting factor. After that
    change, if no max_shift was specified, there would be _no_ expansion
    step at all.

    Given that netlink and tipc have a max_shift specified, it was not
    visible there, but Josh Hunt reported that if nft that starts out
    with a default element hint of 3 if not otherwise provided, would
    slow i.e. inserts down trememdously as it cannot grow larger to
    relax table occupancy.

    Given that the test case verifies shrinks/expands manually, we also
    must remove pointer to the helper functions to explicitly avoid
    parallel resizing on insertions/deletions. test_bucket_stats() and
    test_rht_lookup() could also be wrapped around rhashtable mutex to
    explicitly synchronize a walk from resizing, but I think that defeats
    the actual test case which intended to have explicit test steps,
    i.e. 1) inserts, 2) expands, 3) shrinks, 4) deletions, with object
    verification after each stage.

    Reported-by: Josh Hunt
    Fixes: c0c09bfdc415 ("rhashtable: avoid unnecessary wakeup for worker queue")
    Signed-off-by: Daniel Borkmann
    Cc: Ying Xue
    Cc: Josh Hunt
    Acked-by: Thomas Graf
    Signed-off-by: David S. Miller

    Daniel Borkmann
     

24 Feb, 2015

2 commits

  • With the new standardized functions, we can replace all
    ACCESS_ONCE() calls across relevant locking - this includes
    lockref and seqlock while at it.

    ACCESS_ONCE() does not work reliably on non-scalar types.
    For example gcc 4.6 and 4.7 might remove the volatile tag
    for such accesses during the SRA (scalar replacement of
    aggregates) step:

    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145

    Update the new calls regardless of if it is a scalar type,
    this is cleaner than having three alternatives.

    Signed-off-by: Davidlohr Bueso
    Cc: Peter Zijlstra
    Cc: Linus Torvalds
    Cc: Andrew Morton
    Cc: Thomas Gleixner
    Cc: Paul E. McKenney
    Link: http://lkml.kernel.org/r/1424662301.6539.18.camel@stgolabs.net
    Signed-off-by: Ingo Molnar

    Davidlohr Bueso
     
  • Commit f2dba9c6ff ("rhashtable: Introduce rhashtable_walk_*") forgot to
    initialize the members of struct rhashtable_walker after allocating it, which
    caused an undefined value for 'resize' which is used later on.

    Fixes: f2dba9c6ff ("rhashtable: Introduce rhashtable_walk_*")
    Signed-off-by: Sasha Levin
    Signed-off-by: David S. Miller

    Sasha Levin
     

21 Feb, 2015

4 commits

  • There's no good reason why to disallow unloading of the rhashtable
    test case module.

    Commit 9d6dbe1bbaf8 moved the code from a boot test into a stand-alone
    module, but only converted the subsys_initcall() handler into a
    module_init() function without a related exit handler, and thus
    preventing the test module from unloading.

    Fixes: 9d6dbe1bbaf8 ("rhashtable: Make selftest modular")
    Signed-off-by: Daniel Borkmann
    Acked-by: Thomas Graf
    Signed-off-by: David S. Miller

    Daniel Borkmann
     
  • When trying to allocate future tables via bucket_table_alloc(), it seems
    overkill on large table shifts that we probe for kzalloc() unconditionally
    first, as it's likely to fail.

    Only probe with kzalloc() for more reasonable table sizes and use vzalloc()
    either as a fallback on failure or directly in case of large table sizes.

    Fixes: 7e1e77636e36 ("lib: Resizable, Scalable, Concurrent Hash Table")
    Signed-off-by: Daniel Borkmann
    Acked-by: Thomas Graf
    Signed-off-by: David S. Miller

    Daniel Borkmann
     
  • Restore pre 54c5b7d311c8 behaviour and only probe for expansions on inserts
    and shrinks on deletes. Currently, it will happen that on initial inserts
    into a sparse hash table, we may i.e. shrink it first simply because it's
    not fully populated yet, only to later realize that we need to grow again.

    This however is counter intuitive, e.g. an initial default size of 64
    elements is already small enough, and in case an elements size hint is given
    to the hash table by a user, we should avoid unnecessary expansion steps,
    so a shrink is clearly unintended here.

    Fixes: 54c5b7d311c8 ("rhashtable: introduce rhashtable_wakeup_worker helper function")
    Signed-off-by: Daniel Borkmann
    Cc: Ying Xue
    Acked-by: Thomas Graf
    Signed-off-by: David S. Miller

    Daniel Borkmann
     
  • With object runtime debugging enabled, the rhashtable test suite
    will rightfully throw a warning "ODEBUG: object is on stack, but
    not annotated" from rhashtable_init().

    This is because run_work is (correctly) being initialized via
    INIT_WORK(), and not annotated by INIT_WORK_ONSTACK(). Meaning,
    rhashtable_init() is okay as is, we just need to move ht e.g.,
    into global scope.

    It never triggered anything, since test_rhashtable is rather a
    controlled environment and effectively runs to completion, so
    that stack memory is not vanishing underneath us, we shouldn't
    confuse any testers with it though.

    Fixes: 7e1e77636e36 ("lib: Resizable, Scalable, Concurrent Hash Table")
    Signed-off-by: Daniel Borkmann
    Acked-by: Thomas Graf
    Signed-off-by: David S. Miller

    Daniel Borkmann
     

20 Feb, 2015

1 commit

  • Pull kconfig updates from Michal Marek:
    "Yann E Morin was supposed to take over kconfig maintainership, but
    this hasn't happened. So I'm sending a few kconfig patches that I
    collected:

    - Fix for missing va_end in kconfig
    - merge_config.sh displays used if given too few arguments
    - s/boolean/bool/ in Kconfig files for consistency, with the plan to
    only support bool in the future"

    * 'kconfig' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild:
    kconfig: use va_end to match corresponding va_start
    merge_config.sh: Display usage if given too few arguments
    kconfig: use bool instead of boolean for type definition attributes

    Linus Torvalds
     

19 Feb, 2015

1 commit

  • Pull virtio updates from Rusty Russell:
    "OK, this has the big virtio 1.0 implementation, as specified by OASIS.

    On top of tht is the major rework of lguest, to use PCI and virtio
    1.0, to double-check the implementation.

    Then comes the inevitable fixes and cleanups from that work"

    * tag 'virtio-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux: (80 commits)
    virtio: don't set VIRTIO_CONFIG_S_DRIVER_OK twice.
    virtio_net: unconditionally define struct virtio_net_hdr_v1.
    tools/lguest: don't use legacy definitions for net device in example launcher.
    virtio: Don't expose legacy net features when VIRTIO_NET_NO_LEGACY defined.
    tools/lguest: use common error macros in the example launcher.
    tools/lguest: give virtqueues names for better error messages
    tools/lguest: more documentation and checking of virtio 1.0 compliance.
    lguest: don't look in console features to find emerg_wr.
    tools/lguest: don't start devices until DRIVER_OK status set.
    tools/lguest: handle indirect partway through chain.
    tools/lguest: insert driver references from the 1.0 spec (4.1 Virtio Over PCI)
    tools/lguest: insert device references from the 1.0 spec (4.1 Virtio Over PCI)
    tools/lguest: rename virtio_pci_cfg_cap field to match spec.
    tools/lguest: fix features_accepted logic in example launcher.
    tools/lguest: handle device reset correctly in example launcher.
    virtual: Documentation: simplify and generalize paravirt_ops.txt
    lguest: remove NOTIFY call and eventfd facility.
    lguest: remove NOTIFY facility from demonstration launcher.
    lguest: use the PCI console device's emerg_wr for early boot messages.
    lguest: always put console in PCI slot #1.
    ...

    Linus Torvalds
     

18 Feb, 2015

3 commits

  • Signed-off-by: Al Viro

    Al Viro
     
  • Pull misc VFS updates from Al Viro:
    "This cycle a lot of stuff sits on topical branches, so I'll be sending
    more or less one pull request per branch.

    This is the first pile; more to follow in a few. In this one are
    several misc commits from early in the cycle (before I went for
    separate branches), plus the rework of mntput/dput ordering on umount,
    switching to use of fs_pin instead of convoluted games in
    namespace_unlock()"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    switch the IO-triggering parts of umount to fs_pin
    new fs_pin killing logics
    allow attaching fs_pin to a group not associated with some superblock
    get rid of the second argument of acct_kill()
    take count and rcu_head out of fs_pin
    dcache: let the dentry count go down to zero without taking d_lock
    pull bumping refcount into ->kill()
    kill pin_put()
    mode_t whack-a-mole: chelsio
    file->f_path.dentry is pinned down for as long as the file is open...
    get rid of lustre_dump_dentry()
    gut proc_register() a bit
    kill d_validate()
    ncpfs: get rid of d_validate() nonsense
    selinuxfs: don't open-code d_genocide()

    Linus Torvalds
     
  • This provides the basic infrastructure to load kernel-specific python
    helper scripts when debugging the kernel in gdb.

    The loading mechanism is based on gdb loading for -gdb.py when
    opening . Therefore, this places a corresponding link to the
    main helper script into the output directory that contains vmlinux.

    The main scripts will pull in submodules containing Linux specific gdb
    commands and functions. To avoid polluting the source directory with
    compiled python modules, we link to them from the object directory.

    Due to gdb.parse_and_eval and string redirection for gdb.execute, we
    depend on gdb >= 7.2.

    This feature is enabled via CONFIG_GDB_SCRIPTS.

    Signed-off-by: Jan Kiszka
    Acked-by: Michal Marek [kbuild stuff]
    Cc: Thomas Gleixner
    Cc: Jason Wessel
    Cc: Andi Kleen
    Cc: Ben Widawsky
    Cc: Borislav Petkov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jan Kiszka
     

17 Feb, 2015

1 commit

  • Keyword 'boolean' for type definition attributes is considered
    deprecated and, therefore, should not be used anymore.

    See http://lkml.kernel.org/r/cover.1418003065.git.cj@linux.com
    See http://lkml.kernel.org/r/1419108071-11607-1-git-send-email-cj@linux.com

    Signed-off-by: Christoph Jaeger
    Cc: Russell King
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christoph Jaeger
     

15 Feb, 2015

1 commit

  • Pull crypto update from Herbert Xu:
    "Here is the crypto update for 3.20:

    - Added 192/256-bit key support to aesni GCM.
    - Added MIPS OCTEON MD5 support.
    - Fixed hwrng starvation and race conditions.
    - Added note that memzero_explicit is not a subsitute for memset.
    - Added user-space interface for crypto_rng.
    - Misc fixes"

    * git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (71 commits)
    crypto: tcrypt - do not allocate iv on stack for aead speed tests
    crypto: testmgr - limit IV copy length in aead tests
    crypto: tcrypt - fix buflen reminder calculation
    crypto: testmgr - mark rfc4106(gcm(aes)) as fips_allowed
    crypto: caam - fix resource clean-up on error path for caam_jr_init
    crypto: caam - pair irq map and dispose in the same function
    crypto: ccp - terminate ccp_support array with empty element
    crypto: caam - remove unused local variable
    crypto: caam - remove dead code
    crypto: caam - don't emit ICV check failures to dmesg
    hwrng: virtio - drop extra empty line
    crypto: replace scatterwalk_sg_next with sg_next
    crypto: atmel - Free memory in error path
    crypto: doc - remove colons in comments
    crypto: seqiv - Ensure that IV size is at least 8 bytes
    crypto: cts - Weed out non-CBC algorithms
    MAINTAINERS: add linux-crypto to hw random
    crypto: cts - Remove bogus use of seqiv
    crypto: qat - don't need qat_auth_state struct
    crypto: algif_rng - fix sparse non static symbol warning
    ...

    Linus Torvalds
     

14 Feb, 2015

8 commits

  • This feature let us to detect accesses out of bounds of global variables.
    This will work as for globals in kernel image, so for globals in modules.
    Currently this won't work for symbols in user-specified sections (e.g.
    __init, __read_mostly, ...)

    The idea of this is simple. Compiler increases each global variable by
    redzone size and add constructors invoking __asan_register_globals()
    function. Information about global variable (address, size, size with
    redzone ...) passed to __asan_register_globals() so we could poison
    variable's redzone.

    This patch also forces module_alloc() to return 8*PAGE_SIZE aligned
    address making shadow memory handling (
    kasan_module_alloc()/kasan_module_free() ) more simple. Such alignment
    guarantees that each shadow page backing modules address space correspond
    to only one module_alloc() allocation.

    Signed-off-by: Andrey Ryabinin
    Cc: Dmitry Vyukov
    Cc: Konstantin Serebryany
    Cc: Dmitry Chernenkov
    Signed-off-by: Andrey Konovalov
    Cc: Yuri Gribov
    Cc: Konstantin Khlebnikov
    Cc: Sasha Levin
    Cc: Christoph Lameter
    Cc: Joonsoo Kim
    Cc: Dave Hansen
    Cc: Andi Kleen
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Cc: "H. Peter Anvin"
    Cc: Christoph Lameter
    Cc: Pekka Enberg
    Cc: David Rientjes
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrey Ryabinin
     
  • This is a test module doing various nasty things like out of bounds
    accesses, use after free. It is useful for testing kernel debugging
    features like kernel address sanitizer.

    It mostly concentrates on testing of slab allocator, but we might want to
    add more different stuff here in future (like stack/global variables out
    of bounds accesses and so on).

    Signed-off-by: Andrey Ryabinin
    Cc: Dmitry Vyukov
    Cc: Konstantin Serebryany
    Cc: Dmitry Chernenkov
    Signed-off-by: Andrey Konovalov
    Cc: Yuri Gribov
    Cc: Konstantin Khlebnikov
    Cc: Sasha Levin
    Cc: Christoph Lameter
    Cc: Joonsoo Kim
    Cc: Dave Hansen
    Cc: Andi Kleen
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Cc: "H. Peter Anvin"
    Cc: Christoph Lameter
    Cc: Pekka Enberg
    Cc: David Rientjes
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrey Ryabinin
     
  • With this patch kasan will be able to catch bugs in memory allocated by
    slub. Initially all objects in newly allocated slab page, marked as
    redzone. Later, when allocation of slub object happens, requested by
    caller number of bytes marked as accessible, and the rest of the object
    (including slub's metadata) marked as redzone (inaccessible).

    We also mark object as accessible if ksize was called for this object.
    There is some places in kernel where ksize function is called to inquire
    size of really allocated area. Such callers could validly access whole
    allocated memory, so it should be marked as accessible.

    Code in slub.c and slab_common.c files could validly access to object's
    metadata, so instrumentation for this files are disabled.

    Signed-off-by: Andrey Ryabinin
    Signed-off-by: Dmitry Chernenkov
    Cc: Dmitry Vyukov
    Cc: Konstantin Serebryany
    Signed-off-by: Andrey Konovalov
    Cc: Yuri Gribov
    Cc: Konstantin Khlebnikov
    Cc: Sasha Levin
    Cc: Christoph Lameter
    Cc: Joonsoo Kim
    Cc: Dave Hansen
    Cc: Andi Kleen
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Cc: "H. Peter Anvin"
    Cc: Christoph Lameter
    Cc: Pekka Enberg
    Cc: David Rientjes
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrey Ryabinin
     
  • This patch adds arch specific code for kernel address sanitizer.

    16TB of virtual addressed used for shadow memory. It's located in range
    [ffffec0000000000 - fffffc0000000000] between vmemmap and %esp fixup
    stacks.

    At early stage we map whole shadow region with zero page. Latter, after
    pages mapped to direct mapping address range we unmap zero pages from
    corresponding shadow (see kasan_map_shadow()) and allocate and map a real
    shadow memory reusing vmemmap_populate() function.

    Also replace __pa with __pa_nodebug before shadow initialized. __pa with
    CONFIG_DEBUG_VIRTUAL=y make external function call (__phys_addr)
    __phys_addr is instrumented, so __asan_load could be called before shadow
    area initialized.

    Signed-off-by: Andrey Ryabinin
    Cc: Dmitry Vyukov
    Cc: Konstantin Serebryany
    Cc: Dmitry Chernenkov
    Signed-off-by: Andrey Konovalov
    Cc: Yuri Gribov
    Cc: Konstantin Khlebnikov
    Cc: Sasha Levin
    Cc: Christoph Lameter
    Cc: Joonsoo Kim
    Cc: Dave Hansen
    Cc: Andi Kleen
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Cc: "H. Peter Anvin"
    Cc: Christoph Lameter
    Cc: Pekka Enberg
    Cc: David Rientjes
    Cc: Jim Davis
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrey Ryabinin
     
  • Kernel Address sanitizer (KASan) is a dynamic memory error detector. It
    provides fast and comprehensive solution for finding use-after-free and
    out-of-bounds bugs.

    KASAN uses compile-time instrumentation for checking every memory access,
    therefore GCC > v4.9.2 required. v4.9.2 almost works, but has issues with
    putting symbol aliases into the wrong section, which breaks kasan
    instrumentation of globals.

    This patch only adds infrastructure for kernel address sanitizer. It's
    not available for use yet. The idea and some code was borrowed from [1].

    Basic idea:

    The main idea of KASAN is to use shadow memory to record whether each byte
    of memory is safe to access or not, and use compiler's instrumentation to
    check the shadow memory on each memory access.

    Address sanitizer uses 1/8 of the memory addressable in kernel for shadow
    memory and uses direct mapping with a scale and offset to translate a
    memory address to its corresponding shadow address.

    Here is function to translate address to corresponding shadow address:

    unsigned long kasan_mem_to_shadow(unsigned long addr)
    {
    return (addr >> KASAN_SHADOW_SCALE_SHIFT) + KASAN_SHADOW_OFFSET;
    }

    where KASAN_SHADOW_SCALE_SHIFT = 3.

    So for every 8 bytes there is one corresponding byte of shadow memory.
    The following encoding used for each shadow byte: 0 means that all 8 bytes
    of the corresponding memory region are valid for access; k (1
    Acked-by: Michal Marek
    Signed-off-by: Andrey Konovalov
    Cc: Dmitry Vyukov
    Cc: Konstantin Serebryany
    Cc: Dmitry Chernenkov
    Cc: Yuri Gribov
    Cc: Konstantin Khlebnikov
    Cc: Sasha Levin
    Cc: Christoph Lameter
    Cc: Joonsoo Kim
    Cc: Dave Hansen
    Cc: Andi Kleen
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Cc: "H. Peter Anvin"
    Cc: Christoph Lameter
    Cc: Pekka Enberg
    Cc: David Rientjes
    Cc: Stephen Rothwell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrey Ryabinin
     
  • Now that all bitmap formatting usages have been converted to
    '%*pb[l]', the separate formatting functions are unnecessary. The
    following functions are removed.

    * bitmap_scn[list]printf()
    * cpumask_scnprintf(), cpulist_scnprintf()
    * [__]nodemask_scnprintf(), [__]nodelist_scnprintf()
    * seq_bitmap[_list](), seq_cpumask[_list](), seq_nodemask[_list]()
    * seq_buf_bitmask()

    Signed-off-by: Tejun Heo
    Cc: Rusty Russell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tejun Heo
     
  • printk and friends can now format bitmaps using '%*pb[l]'. cpumask
    and nodemask also provide cpumask_pr_args() and nodemask_pr_args()
    respectively which can be used to generate the two printf arguments
    necessary to format the specified cpu/nodemask.

    Signed-off-by: Tejun Heo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tejun Heo
     
  • bitmap and its derivatives such as cpumask and nodemask currently only
    provide formatting functions which put the output string into the
    provided buffer; however, how long this buffer should be isn't defined
    anywhere and given that some of these bitmaps can be too large to be
    formatted into an on-stack buffer it users sometimes are unnecessarily
    forced to come up with creative solutions and compromises for the
    buffer just to printk these bitmaps.

    There have been a couple different attempts at making this easier.

    1. Way back, PeterZ tried printk '%pb' extension with the precision
    for bit width - '%.*pb'. This was intuitive and made sense but
    unfortunately triggered a compile warning about using precision
    for a pointer.

    http://lkml.kernel.org/g/1336577562.2527.58.camel@twins

    2. I implemented bitmap_pr_cont[_list]() and its wrappers for cpumask
    and nodemask. This works but PeterZ pointed out that pr_cont's
    tendency to produce broken lines when multiple CPUs are printing is
    bothering considering the usages.

    http://lkml.kernel.org/g/1418226774-30215-3-git-send-email-tj@kernel.org

    So, this patch is another attempt at teaching printk and friends how
    to print bitmaps. It's almost identical to what PeterZ tried with
    precision but it uses the field width for the number of bits instead
    of precision. The format used is '%*pb[l]', with the optional
    trailing 'l' specifying list format instead of hex masks.

    This is a valid format string and doesn't trigger compiler warnings;
    however, it does make it impossible to specify output field width when
    printing bitmaps. I think this is an acceptable trade-off given how
    much easier it makes printing bitmaps and that we don't have any
    in-kernel user which is using the field width specification. If any
    future user wants to use field width with a bitmap, it'd have to
    format the bitmap into a string buffer and then print that buffer with
    width spec, which isn't different from how it should be done now.

    This patch implements bitmap[_list]_string() which are called from the
    vsprintf pointer() formatting function. The implementation is mostly
    identical to bitmap_scn[list]printf() except that the output is
    performed in the vsprintf way. These functions handle formatting into
    too small buffers and sprintf() family of functions report the correct
    overrun output length.

    bitmap_scn[list]printf() are now thin wrappers around scnprintf().

    Signed-off-by: Tejun Heo
    Acked-by: Peter Zijlstra (Intel)
    Cc: "David S. Miller"
    Cc: "James E.J. Bottomley"
    Cc: "John W. Linville"
    Cc: "Paul E. McKenney"
    Cc: Benjamin Herrenschmidt
    Cc: Chris Metcalf
    Cc: Chris Zankel
    Cc: Christoph Lameter
    Cc: Dmitry Torokhov
    Cc: Fenghua Yu
    Cc: Greg Kroah-Hartman
    Cc: Ingo Molnar
    Cc: Li Zefan
    Cc: Max Filippov
    Cc: Mike Travis
    Cc: Pekka Enberg
    Cc: Russell King
    Cc: Rusty Russell
    Cc: Steffen Klassert
    Cc: Steven Rostedt
    Cc: Thomas Gleixner
    Cc: Tony Luck
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tejun Heo