06 Mar, 2018

2 commits

  • All of the conflicts were cases of overlapping changes.

    In net/core/devlink.c, we have to make care that the
    resouce size_params have become a struct member rather
    than a pointer to such an object.

    Signed-off-by: David S. Miller

    David S. Miller
     
  • Pull networking fixes from David Miller:

    1) Use an appropriate TSQ pacing shift in mac80211, from Toke
    Høiland-Jørgensen.

    2) Just like ipv4's ip_route_me_harder(), we have to use skb_to_full_sk
    in ip6_route_me_harder, from Eric Dumazet.

    3) Fix several shutdown races and similar other problems in l2tp, from
    James Chapman.

    4) Handle missing XDP flush properly in tuntap, for real this time.
    From Jason Wang.

    5) Out-of-bounds access in powerpc ebpf tailcalls, from Daniel
    Borkmann.

    6) Fix phy_resume() locking, from Andrew Lunn.

    7) IFLA_MTU values are ignored on newlink for some tunnel types, fix
    from Xin Long.

    8) Revert F-RTO middle box workarounds, they only handle one dimension
    of the problem. From Yuchung Cheng.

    9) Fix socket refcounting in RDS, from Ka-Cheong Poon.

    10) Don't allow ppp unit registration to an unregistered channel, from
    Guillaume Nault.

    11) Various hv_netvsc fixes from Stephen Hemminger.

    * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (98 commits)
    hv_netvsc: propagate rx filters to VF
    hv_netvsc: filter multicast/broadcast
    hv_netvsc: defer queue selection to VF
    hv_netvsc: use napi_schedule_irqoff
    hv_netvsc: fix race in napi poll when rescheduling
    hv_netvsc: cancel subchannel setup before halting device
    hv_netvsc: fix error unwind handling if vmbus_open fails
    hv_netvsc: only wake transmit queue if link is up
    hv_netvsc: avoid retry on send during shutdown
    virtio-net: re enable XDP_REDIRECT for mergeable buffer
    ppp: prevent unregistered channels from connecting to PPP units
    tc-testing: skbmod: fix match value of ethertype
    mlxsw: spectrum_switchdev: Check success of FDB add operation
    net: make skb_gso_*_seglen functions private
    net: xfrm: use skb_gso_validate_network_len() to check gso sizes
    net: sched: tbf: handle GSO_BY_FRAGS case in enqueue
    net: rename skb_gso_validate_mtu -> skb_gso_validate_network_len
    rds: Incorrect reference counting in TCP socket creation
    net: ethtool: don't ignore return from driver get_fecparam method
    vrf: check forwarding on the original netdevice when generating ICMP dest unreachable
    ...

    Linus Torvalds
     

02 Mar, 2018

1 commit

  • Daniel Borkmann says:

    ====================
    pull-request: bpf 2018-02-28

    The following pull-request contains BPF updates for your *net* tree.

    The main changes are:

    1) Add schedule points and reduce the number of loop iterations
    the test_bpf kernel module is performing in order to not hog
    the CPU for too long, from Eric.

    2) Fix an out of bounds access in tail calls in the ppc64 BPF
    JIT compiler, from Daniel.

    3) Fix a crash on arm64 on unaligned BPF xadd operations that
    could be triggered via interpreter and JIT, from Daniel.

    Please not that once you merge net into net-next at some point, there
    is a minor merge conflict in test_verifier.c since test cases had
    been added at the end in both trees. Resolution is trivial: keep all
    the test cases from both trees.
    ====================

    Signed-off-by: David S. Miller

    David S. Miller
     

01 Mar, 2018

2 commits

  • Pull dma-mapping fix from Christoph Hellwig:
    "A single fix for a memory leak regression in the dma-debug code"

    * tag 'dma-mapping-4.16-3' of git://git.infradead.org/users/hch/dma-mapping:
    dma-debug: fix memory leak in debug_dma_alloc_coherent

    Linus Torvalds
     
  • For tests that are using the maximal number of BPF instruction, each
    run takes 20 usec. Looping 10,000 times on them totals 200 ms, which
    is bad when the loop is not preemptible.

    test_bpf: #264 BPF_MAXINSNS: Call heavy transformations jited:1 19248
    18548 PASS
    test_bpf: #269 BPF_MAXINSNS: ld_abs+get_processor_id jited:1 20896 PASS

    Lets divide by ten the number of iterations, so that max latency is
    20ms. We could use need_resched() to break the loop earlier if we
    believe 20 ms is too much.

    Signed-off-by: Eric Dumazet
    Signed-off-by: Daniel Borkmann

    Eric Dumazet
     

27 Feb, 2018

2 commits

  • test_bpf() is taking 1.6 seconds nowadays, it is time
    to add a schedule point in it.

    Signed-off-by: Eric Dumazet
    Signed-off-by: Daniel Borkmann

    Eric Dumazet
     
  • Khalid reported that the kernel selftests are currently failing:

    selftests: test_bpf.sh
    ========================================
    test_bpf: [FAIL]
    not ok 1..8 selftests: test_bpf.sh [FAIL]

    He bisected it to 6ce711f2750031d12cec91384ac5cfa0a485b60a ("idr: Make
    1-based IDRs more efficient").

    The root cause is doing a signed comparison in idr_alloc_u32() instead
    of an unsigned comparison. I went looking for any similar problems and
    found a couple (which would each result in the failure to warn in two
    situations that aren't supposed to happen).

    I knocked up a few test-cases to prove that I was right and added them
    to the test-suite.

    Reported-by: Khalid Aziz
    Tested-by: Khalid Aziz
    Signed-off-by: Matthew Wilcox

    Matthew Wilcox
     

24 Feb, 2018

2 commits


23 Feb, 2018

1 commit

  • Marty reported a memory leakage introduced by commit 3aaabbf1c39e
    ("lib/dma-debug.c: fix incorrect pfn calculation"). Fix it
    by checking the virtual address before allocating the entry.

    This patch also use virt_addr_valid() instead of virt_to_page()
    to check if a virtual address is linear.

    Fixes: 3aaabbf1 ("lib/dma-debug.c: fix incorrect pfn calculation")
    Reported-by: Marty Faltesek
    Signed-off-by: Miles Chen
    Acked-by: Robin Murphy
    Signed-off-by: Christoph Hellwig

    Miles Chen
     

22 Feb, 2018

2 commits

  • Commit d3deafaa8b5c ("lib/: make RUNTIME_TESTS a menuconfig to ease
    disabling it all") causes a regression when using runtime tests due to
    it defaults RUNTIME_TESTING_MENU to not set.

    Link: http://lkml.kernel.org/r/20180214133015.10090-1-anders.roxell@linaro.org
    Fixes: d3deafaa8b5c ("lib/: make RUNTIME_TESTS a menuconfig to easedisabling it all")
    Signed-off-by: Anders Roxell
    Cc: Vincent Legoll
    Cc: Ingo Molnar
    Cc: Byungchul Park
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Anders Roxell
     
  • As far as I can tell, the only place the per-cpu ida_bitmap is populated
    is in ida_pre_get. The pre-allocated element is stolen in two places in
    ida_get_new_above, in both cases immediately followed by a memset(0).

    Since ida_get_new_above is called with locks held, do the zeroing in
    ida_pre_get, or rather let kmalloc() do it. Also, apparently gcc
    generates ~44 bytes of code to do a memset(, 0, 128):

    $ scripts/bloat-o-meter vmlinux.{0,1}
    add/remove: 0/0 grow/shrink: 2/1 up/down: 5/-88 (-83)
    Function old new delta
    ida_pre_get 115 119 +4
    vermagic 27 28 +1
    ida_get_new_above 715 627 -88

    Link: http://lkml.kernel.org/r/20180108225634.15340-1-linux@rasmusvillemoes.dk
    Signed-off-by: Rasmus Villemoes
    Acked-by: Matthew Wilcox
    Cc: Eric Biggers
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rasmus Villemoes
     

20 Feb, 2018

1 commit


13 Feb, 2018

1 commit

  • uevent_net_init() and uevent_net_exit() create and
    destroy netlink socket, and these actions serialized
    in netlink code.

    Parallel execution with other pernet_operations
    makes the socket disappear earlier from uevent_sock_list
    on ->exit. As userspace can't be interested in broadcast
    messages of dying net, and, as I see, no one in kernel
    listen them, we may safely make uevent_net_ops async.

    Signed-off-by: Kirill Tkhai
    Acked-by: Andrei Vagin
    Signed-off-by: David S. Miller

    Kirill Tkhai
     

12 Feb, 2018

2 commits


10 Feb, 2018

3 commits

  • Pull more Kbuild updates from Masahiro Yamada:
    "Makefile changes:
    - enable unused-variable warning that was wrongly disabled for clang

    Kconfig changes:
    - warn about blank 'help' and fix existing instances
    - fix 'choice' behavior to not write out invisible symbols
    - fix misc weirdness

    Coccinell changes:
    - fix false positive of free after managed memory alloc detection
    - improve performance of NULL dereference detection"

    * tag 'kbuild-v4.16-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (21 commits)
    kconfig: remove const qualifier from sym_expand_string_value()
    kconfig: add xrealloc() helper
    kconfig: send error messages to stderr
    kconfig: echo stdin to stdout if either is redirected
    kconfig: remove check_stdin()
    kconfig: remove 'config*' pattern from .gitignnore
    kconfig: show '?' prompt even if no help text is available
    kconfig: do not write choice values when their dependency becomes n
    coccinelle: deref_null: avoid useless computation
    coccinelle: devm_free: reduce false positives
    kbuild: clang: disable unused variable warnings only when constant
    kconfig: Warn if help text is blank
    nios2: kconfig: Remove blank help text
    arm: vt8500: kconfig: Remove blank help text
    MIPS: kconfig: Remove blank help text
    MIPS: BCM63XX: kconfig: Remove blank help text
    lib/Kconfig.debug: Remove blank help text
    Staging: rtl8192e: kconfig: Remove blank help text
    Staging: rtl8192u: kconfig: Remove blank help text
    mmc: kconfig: Remove blank help text
    ...

    Linus Torvalds
     
  • Pull networking fixes from David Miller:

    1) Make allocations less aggressive in x_tables, from Minchal Hocko.

    2) Fix netfilter flowtable Kconfig deps, from Pablo Neira Ayuso.

    3) Fix connection loss problems in rtlwifi, from Larry Finger.

    4) Correct DRAM dump length for some chips in ath10k driver, from Yu
    Wang.

    5) Fix ABORT handling in rxrpc, from David Howells.

    6) Add SPDX tags to Sun networking drivers, from Shannon Nelson.

    7) Some ipv6 onlink handling fixes, from David Ahern.

    8) Netem packet scheduler interval calcualtion fix from Md. Islam.

    9) Don't put crypto buffers on-stack in rxrpc, from David Howells.

    10) Fix handling of error non-delivery status in netlink multicast
    delivery over multiple namespaces, from Nicolas Dichtel.

    11) Missing xdp flush in tuntap driver, from Jason Wang.

    12) Synchonize RDS protocol netns/module teardown with rds object
    management, from Sowini Varadhan.

    13) Add nospec annotations to mpls, from Dan Williams.

    14) Fix SKB truesize handling in TIPC, from Hoang Le.

    15) Interrupt masking fixes in stammc from Niklas Cassel.

    16) Don't allow ptr_ring objects to be sized outside of kmalloc's
    limits, from Jason Wang.

    17) Don't allow SCTP chunks to be built which will have a length
    exceeding the chunk header's 16-bit length field, from Alexey
    Kodanev.

    * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (82 commits)
    ibmvnic: Remove skb->protocol checks in ibmvnic_xmit
    bpf: fix rlimit in reuseport net selftest
    sctp: verify size of a new chunk in _sctp_make_chunk()
    s390/qeth: fix SETIP command handling
    s390/qeth: fix underestimated count of buffer elements
    ptr_ring: try vmalloc() when kmalloc() fails
    ptr_ring: fail early if queue occupies more than KMALLOC_MAX_SIZE
    net: stmmac: remove redundant enable of PMT irq
    net: stmmac: rename GMAC_INT_DEFAULT_MASK for dwmac4
    net: stmmac: discard disabled flags in interrupt status register
    ibmvnic: Reset long term map ID counter
    tools/libbpf: handle issues with bpf ELF objects containing .eh_frames
    selftests/bpf: add selftest that use test_libbpf_open
    selftests/bpf: add test program for loading BPF ELF files
    tools/libbpf: improve the pr_debug statements to contain section numbers
    bpf: Sync kernel ABI header with tooling header for bpf_common.h
    net: phy: fix phy_start to consider PHY_IGNORE_INTERRUPT
    net: thunder: change q_len's type to handle max ring size
    tipc: fix skb truesize/datasize ratio control
    net/sched: cls_u32: fix cls_u32 on filter replace
    ...

    Linus Torvalds
     
  • Daniel Borkmann says:

    ====================
    pull-request: bpf 2018-02-09

    The following pull-request contains BPF updates for your *net* tree.

    The main changes are:

    1) Two fixes for BPF sockmap in order to break up circular map references
    from programs attached to sockmap, and detaching related sockets in
    case of socket close() event. For the latter we get rid of the
    smap_state_change() and plug into ULP infrastructure, which will later
    also be used for additional features anyway such as TX hooks. For the
    second issue, dependency chain is broken up via map release callback
    to free parse/verdict programs, all from John.

    2) Fix a libbpf relocation issue that was found while implementing XDP
    support for Suricata project. Issue was that when clang was invoked
    with default target instead of bpf target, then various other e.g.
    debugging relevant sections are added to the ELF file that contained
    relocation entries pointing to non-BPF related sections which libbpf
    trips over instead of skipping them. Test cases for libbpf are added
    as well, from Jesper.

    3) Various misc fixes for bpftool and one for libbpf: a small addition
    to libbpf to make sure it recognizes all standard section prefixes.
    Then, the Makefile in bpftool/Documentation is improved to explicitly
    check for rst2man being installed on the system as we otherwise risk
    installing empty man pages; the man page for bpftool-map is corrected
    and a set of missing bash completions added in order to avoid shipping
    bpftool where the completions are only partially working, from Quentin.

    4) Fix applying the relocation to immediate load instructions in the
    nfp JIT which were missing a shift, from Jakub.

    5) Two fixes for the BPF kernel selftests: handle CONFIG_BPF_JIT_ALWAYS_ON=y
    gracefully in test_bpf.ko module and mark them as FLAG_EXPECTED_FAIL
    in this case; and explicitly delete the veth devices in the two tests
    test_xdp_{meta,redirect}.sh before dismantling the netnses as when
    selftests are run in batch mode, then workqueue to handle destruction
    might not have finished yet and thus veth creation in next test under
    same dev name would fail, from Yonghong.

    6) Fix test_kmod.sh to check the test_bpf.ko module path before performing
    an insmod, and fallback to modprobe. Especially the latter is useful
    when having a device under test that has the modules installed instead,
    from Naresh.
    ====================

    Signed-off-by: David S. Miller

    David S. Miller
     

09 Feb, 2018

1 commit

  • Pull idr updates from Matthew Wilcox:

    - test-suite improvements

    - replace the extended API by improving the normal API

    - performance improvement for IDRs which are 1-based rather than
    0-based

    - add documentation

    * 'idr-2018-02-06' of git://git.infradead.org/users/willy/linux-dax:
    idr: Add documentation
    idr: Make 1-based IDRs more efficient
    idr: Warn if old iterators see large IDs
    idr: Rename idr_for_each_entry_ext
    idr: Remove idr_alloc_ext
    cls_u32: Convert to idr_alloc_u32
    cls_u32: Reinstate cyclic allocation
    cls_flower: Convert to idr_alloc_u32
    cls_bpf: Convert to use idr_alloc_u32
    cls_basic: Convert to use idr_alloc_u32
    cls_api: Convert to idr_alloc_u32
    net sched actions: Convert to use idr_alloc_u32
    idr: Add idr_alloc_u32 helper
    idr: Delete idr_find_ext function
    idr: Delete idr_replace_ext function
    idr: Delete idr_remove_ext function
    IDR test suite: Check handling negative end correctly
    idr test suite: Fix ida_test_random()
    radix tree test suite: Remove ARRAY_SIZE

    Linus Torvalds
     

08 Feb, 2018

1 commit

  • Like %pK already does, print "00000000" instead.

    This confused people -- the convention is that "(null)" means you tried to
    dereference a null pointer as opposed to printing the address.

    Link: http://lkml.kernel.org/r/20180204174521.21383-1-kilobyte@angband.pl
    To: Sergey Senozhatsky
    To: Steven Rostedt
    To: linux-kernel@vger.kernel.org
    Cc: Andrew Morton
    Cc: Joe Perches
    Cc: Kees Cook
    Cc: "Roberts, William C"
    Cc: Linus Torvalds
    Cc: David Laight
    Cc: Randy Dunlap
    Cc: Geert Uytterhoeven
    Signed-off-by: Adam Borowski
    Signed-off-by: Petr Mladek

    Adam Borowski
     

07 Feb, 2018

19 commits

  • Merge misc updates from Andrew Morton:

    - kasan updates

    - procfs

    - lib/bitmap updates

    - other lib/ updates

    - checkpatch tweaks

    - rapidio

    - ubsan

    - pipe fixes and cleanups

    - lots of other misc bits

    * emailed patches from Andrew Morton : (114 commits)
    Documentation/sysctl/user.txt: fix typo
    MAINTAINERS: update ARM/QUALCOMM SUPPORT patterns
    MAINTAINERS: update various PALM patterns
    MAINTAINERS: update "ARM/OXNAS platform support" patterns
    MAINTAINERS: update Cortina/Gemini patterns
    MAINTAINERS: remove ARM/CLKDEV SUPPORT file pattern
    MAINTAINERS: remove ANDROID ION pattern
    mm: docs: add blank lines to silence sphinx "Unexpected indentation" errors
    mm: docs: fix parameter names mismatch
    mm: docs: fixup punctuation
    pipe: read buffer limits atomically
    pipe: simplify round_pipe_size()
    pipe: reject F_SETPIPE_SZ with size over UINT_MAX
    pipe: fix off-by-one error when checking buffer limits
    pipe: actually allow root to exceed the pipe buffer limits
    pipe, sysctl: remove pipe_proc_fn()
    pipe, sysctl: drop 'min' parameter from pipe-max-size converter
    kasan: rework Kconfig settings
    crash_dump: is_kdump_kernel can be boolean
    kernel/mutex: mutex_is_locked can be boolean
    ...

    Linus Torvalds
     
  • We get a lot of very large stack frames using gcc-7.0.1 with the default
    -fsanitize-address-use-after-scope --param asan-stack=1 options, which can
    easily cause an overflow of the kernel stack, e.g.

    drivers/gpu/drm/i915/gvt/handlers.c:2434:1: warning: the frame size of 46176 bytes is larger than 3072 bytes
    drivers/net/wireless/ralink/rt2x00/rt2800lib.c:5650:1: warning: the frame size of 23632 bytes is larger than 3072 bytes
    lib/atomic64_test.c:250:1: warning: the frame size of 11200 bytes is larger than 3072 bytes
    drivers/gpu/drm/i915/gvt/handlers.c:2621:1: warning: the frame size of 9208 bytes is larger than 3072 bytes
    drivers/media/dvb-frontends/stv090x.c:3431:1: warning: the frame size of 6816 bytes is larger than 3072 bytes
    fs/fscache/stats.c:287:1: warning: the frame size of 6536 bytes is larger than 3072 bytes

    To reduce this risk, -fsanitize-address-use-after-scope is now split out
    into a separate CONFIG_KASAN_EXTRA Kconfig option, leading to stack
    frames that are smaller than 2 kilobytes most of the time on x86_64. An
    earlier version of this patch also prevented combining KASAN_EXTRA with
    KASAN_INLINE, but that is no longer necessary with gcc-7.0.1.

    All patches to get the frame size below 2048 bytes with CONFIG_KASAN=y
    and CONFIG_KASAN_EXTRA=n have been merged by maintainers now, so we can
    bring back that default now. KASAN_EXTRA=y still causes lots of
    warnings but now defaults to !COMPILE_TEST to disable it in
    allmodconfig, and it remains disabled in all other defconfigs since it
    is a new option. I arbitrarily raise the warning limit for KASAN_EXTRA
    to 3072 to reduce the noise, but an allmodconfig kernel still has around
    50 warnings on gcc-7.

    I experimented a bit more with smaller stack frames and have another
    follow-up series that reduces the warning limit for 64-bit architectures
    to 1280 bytes (without CONFIG_KASAN).

    With earlier versions of this patch series, I also had patches to address
    the warnings we get with KASAN and/or KASAN_EXTRA, using a
    "noinline_if_stackbloat" annotation.

    That annotation now got replaced with a gcc-8 bugfix (see
    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81715) and a workaround for
    older compilers, which means that KASAN_EXTRA is now just as bad as
    before and will lead to an instant stack overflow in a few extreme
    cases.

    This reverts parts of commit 3f181b4d8652 ("lib/Kconfig.debug: disable
    -Wframe-larger-than warnings with KASAN=y"). Two patches in linux-next
    should be merged first to avoid introducing warnings in an allmodconfig
    build:
    3cd890dbe2a4 ("media: dvb-frontends: fix i2c access helpers for KASAN")
    16c3ada89cff ("media: r820t: fix r820t_write_reg for KASAN")

    Do we really need to backport this?

    I think we do: without this patch, enabling KASAN will lead to
    unavoidable kernel stack overflow in certain device drivers when built
    with gcc-7 or higher on linux-4.10+ or any version that contains a
    backport of commit c5caf21ab0cf8. Most people are probably still on
    older compilers, but it will get worse over time as they upgrade their
    distros.

    The warnings we get on kernels older than this should all be for code
    that uses dangerously large stack frames, though most of them do not
    cause an actual stack overflow by themselves.The asan-stack option was
    added in linux-4.0, and commit 3f181b4d8652 ("lib/Kconfig.debug:
    disable -Wframe-larger-than warnings with KASAN=y") effectively turned
    off the warning for allmodconfig kernels, so I would like to see this
    fix backported to any kernels later than 4.0.

    I have done dozens of fixes for individual functions with stack frames
    larger than 2048 bytes with asan-stack, and I plan to make sure that
    all those fixes make it into the stable kernels as well (most are
    already there).

    Part of the complication here is that asan-stack (from 4.0) was
    originally assumed to always require much larger stacks, but that
    turned out to be a combination of multiple gcc bugs that we have now
    worked around and fixed, but sanitize-address-use-after-scope (from
    v4.10) has a much higher inherent stack usage and also suffers from at
    least three other problems that we have analyzed but not yet fixed
    upstream, each of them makes the stack usage more severe than it should
    be.

    Link: http://lkml.kernel.org/r/20171221134744.2295529-1-arnd@arndb.de
    Signed-off-by: Arnd Bergmann
    Acked-by: Andrey Ryabinin
    Cc: Mauro Carvalho Chehab
    Cc: Andrey Ryabinin
    Cc: Alexander Potapenko
    Cc: Dmitry Vyukov
    Cc: Andrey Konovalov
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arnd Bergmann
     
  • Similarly to type mismatch checks, new GCC 8.x and Clang also changed for
    ABI for returns_nonnull checks. While we can update our code to conform
    the new ABI it's more reasonable to just remove it. Because it's just
    dead code, we don't have any single user of returns_nonnull attribute in
    the whole kernel.

    And AFAIU the advantage that this attribute could bring would be mitigated
    by -fno-delete-null-pointer-checks cflag that we use to build the kernel.
    So it's unlikely we will have a lot of returns_nonnull attribute in
    future.

    So let's just remove the code, it has no use.

    [aryabinin@virtuozzo.com: fix warning]
    Link: http://lkml.kernel.org/r/20180122165711.11510-1-aryabinin@virtuozzo.com
    Link: http://lkml.kernel.org/r/20180119152853.16806-2-aryabinin@virtuozzo.com
    Signed-off-by: Andrey Ryabinin
    Cc: Sodagudi Prasad
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrey Ryabinin
     
  • UBSAN=y fails to build with new GCC/clang:

    arch/x86/kernel/head64.o: In function `sanitize_boot_params':
    arch/x86/include/asm/bootparam_utils.h:37: undefined reference to `__ubsan_handle_type_mismatch_v1'

    because Clang and GCC 8 slightly changed ABI for 'type mismatch' errors.
    Compiler now uses new __ubsan_handle_type_mismatch_v1() function with
    slightly modified 'struct type_mismatch_data'.

    Let's add new 'struct type_mismatch_data_common' which is independent from
    compiler's layout of 'struct type_mismatch_data'. And make
    __ubsan_handle_type_mismatch[_v1]() functions transform compiler-dependent
    type mismatch data to our internal representation. This way, we can
    support both old and new compilers with minimal amount of change.

    Link: http://lkml.kernel.org/r/20180119152853.16806-1-aryabinin@virtuozzo.com
    Signed-off-by: Andrey Ryabinin
    Reported-by: Sodagudi Prasad
    Cc: [4.5+]
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrey Ryabinin
     
  • A vist from the spelling fairy.

    Cc: David Laight
    Cc: Andrey Ryabinin
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     
  • test_sort.c performs array-based and linked list sort test. Code allows
    to compile either as a loadable modules or builtin into the kernel.

    Current code is not allow to unload the test_sort.ko module after
    successful completion.

    This patch adds support to unload the "test_sort.ko" module by adding
    module_exit support.

    Previous patch was implemented auto unload support by returning -EAGAIN
    from module_init() function on successful case, but this approach is not
    ideal.

    The auto-unload might seem like a nice optimization, but it encourages
    inconsistent behaviour. And behaviour that is different from all other
    normal modules.

    Link: http://lkml.kernel.org/r/1513967133-6843-1-git-send-email-pravin.shedge4linux@gmail.com
    Signed-off-by: Pravin Shedge
    Cc: Kostenzer Felix
    Cc: Andy Shevchenko
    Cc: Geert Uytterhoeven
    Cc: Paul Gortmaker
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Pravin Shedge
     
  • No need to get into the submenu to disable all related config entries.

    This makes it easier to disable all RUNTIME_TESTS config options without
    entering the submenu. It will also enable one to see that en/dis-abled
    state from the outside menu.

    This is only intended to change menuconfig UI, not change the config
    dependencies.

    Link: http://lkml.kernel.org/r/20171209162742.7363-1-vincent.legoll@gmail.com
    Signed-off-by: Vincent Legoll
    Cc: Ingo Molnar
    Cc: Byungchul Park
    Cc: Peter Zijlstra
    Cc: "Paul E. McKenney"
    Cc: Josh Poimboeuf
    Cc: Geert Uytterhoeven
    Cc: Randy Dunlap
    Cc: "Luis R. Rodriguez"
    Cc: Nicholas Piggin
    Cc: Thomas Gleixner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Vincent Legoll
     
  • We've measured that we spend ~0.6% of sys cpu time in cpumask_next_and().
    It's essentially a joined iteration in search for a non-zero bit, which is
    currently implemented as a lookup join (find a nonzero bit on the lhs,
    lookup the rhs to see if it's set there).

    Implement a direct join (find a nonzero bit on the incrementally built
    join). Also add generic bitmap benchmarks in the new `test_find_bit`
    module for new function (see `find_next_and_bit` in [2] and [3] below).

    For cpumask_next_and, direct benchmarking shows that it's 1.17x to 14x
    faster with a geometric mean of 2.1 on 32 CPUs [1]. No impact on memory
    usage. Note that on Arm, the new pure-C implementation still outperforms
    the old one that uses a mix of C and asm (`find_next_bit`) [3].

    [1] Approximate benchmark code:

    ```
    unsigned long src1p[nr_cpumask_longs] = {pattern1};
    unsigned long src2p[nr_cpumask_longs] = {pattern2};
    for (/*a bunch of repetitions*/) {
    for (int n = -1; n ]
    Link: http://lkml.kernel.org/r/1512556816-28627-1-git-send-email-geert@linux-m68k.org
    Link: http://lkml.kernel.org/r/20171128131334.23491-1-courbet@google.com
    Signed-off-by: Clement Courbet
    Signed-off-by: Geert Uytterhoeven
    Cc: Yury Norov
    Cc: Geert Uytterhoeven
    Cc: Alexey Dobriyan
    Cc: Rasmus Villemoes
    Signed-off-by: Andrew Morton

    Signed-off-by: Linus Torvalds

    Clement Courbet
     
  • As suggested in review comments:
    * printk: align numbers using whitespaces instead of tabs;
    * return error value from init() to avoid calling rmmod if testing again;
    * use ktime_get instead of get_cycles as some arches don't support it;

    The output in dmesg (on QEMU arm64):
    [ 38.823430] Start testing find_bit() with random-filled bitmap
    [ 38.845358] find_next_bit: 20138448 ns, 163968 iterations
    [ 38.856217] find_next_zero_bit: 10615328 ns, 163713 iterations
    [ 38.863564] find_last_bit: 7111888 ns, 163967 iterations
    [ 40.944796] find_first_bit: 2081007216 ns, 163968 iterations
    [ 40.944975]
    [ 40.944975] Start testing find_bit() with sparse bitmap
    [ 40.945268] find_next_bit: 73216 ns, 656 iterations
    [ 40.967858] find_next_zero_bit: 22461008 ns, 327025 iterations
    [ 40.968047] find_last_bit: 62320 ns, 656 iterations
    [ 40.978060] find_first_bit: 9889360 ns, 656 iterations

    Link: http://lkml.kernel.org/r/20171124143040.a44jvhmnaiyedg2i@yury-thinkpad
    Signed-off-by: Yury Norov
    Tested-by: Geert Uytterhoeven
    Cc: Alexey Dobriyan
    Cc: Clement Courbet
    Cc: Matthew Wilcox
    Cc: Rasmus Villemoes
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Yury Norov
     
  • As suggested in review comments, rename test_find_bit.c to
    find_bit_benchmark.c.

    Link: http://lkml.kernel.org/r/20171124143040.a44jvhmnaiyedg2i@yury-thinkpad
    Signed-off-by: Yury Norov
    Tested-by: Geert Uytterhoeven
    Cc: Alexey Dobriyan
    Cc: Clement Courbet
    Cc: Matthew Wilcox
    Cc: Rasmus Villemoes
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Yury Norov
     
  • stackdepot used to call memcmp(), which compiler tools normally
    instrument, therefore every lookup used to unnecessarily call instrumented
    code. This is somewhat ok in the case of KASAN, but under KMSAN a lot of
    time was spent in the instrumentation.

    Link: http://lkml.kernel.org/r/20171117172149.69562-1-glider@google.com
    Signed-off-by: Alexander Potapenko
    Cc: Andrey Ryabinin
    Cc: Dmitry Vyukov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexander Potapenko
     
  • Since we have separate explicit test cases for bitmap_zero() /
    bitmap_clear() and bitmap_fill() / bitmap_set(), clean up
    test_zero_fill_copy() to only test bitmap_copy() functionality and thus
    rename a function to reflect the changes.

    While here, replace bitmap_fill() by bitmap_set() with proper values.

    Link: http://lkml.kernel.org/r/20180109172430.87452-3-andriy.shevchenko@linux.intel.com
    Signed-off-by: Andy Shevchenko
    Reviewed-by: Yury Norov
    Cc: Randy Dunlap
    Cc: Rasmus Villemoes
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Shevchenko
     
  • Explicitly test bitmap_fill() and bitmap_set() functions.

    For bitmap_fill() we expect a consistent behaviour as in bitmap_zero(),
    i.e. the trailing bits will be set up to unsigned long boundary.

    Link: http://lkml.kernel.org/r/20180109172430.87452-2-andriy.shevchenko@linux.intel.com
    Signed-off-by: Andy Shevchenko
    Reviewed-by: Yury Norov
    Cc: Randy Dunlap
    Cc: Rasmus Villemoes
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Shevchenko
     
  • Explicitly test bitmap_zero() and bitmap_clear() functions.

    Link: http://lkml.kernel.org/r/20180109172430.87452-1-andriy.shevchenko@linux.intel.com
    Signed-off-by: Andy Shevchenko
    Reviewed-by: Yury Norov
    Cc: Rasmus Villemoes
    Cc: Randy Dunlap
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Shevchenko
     
  • with bitmap_{from,to}_arr32 over the kernel. Additionally to it:
    * __check_eq_bitmap() now takes single nbits argument.
    * __check_eq_u32_array is not used in new test but may be used in
    future. So I don't remove it here, but annotate as __used.

    Tested on arm64 and 32-bit BE mips.

    [arnd@arndb.de: perf: arm_dsu_pmu: convert to bitmap_from_arr32]
    Link: http://lkml.kernel.org/r/20180201172508.5739-2-ynorov@caviumnetworks.com
    [ynorov@caviumnetworks.com: fix net/core/ethtool.c]
    Link: http://lkml.kernel.org/r/20180205071747.4ekxtsbgxkj5b2fz@yury-thinkpad
    Link: http://lkml.kernel.org/r/20171228150019.27953-2-ynorov@caviumnetworks.com
    Signed-off-by: Yury Norov
    Signed-off-by: Arnd Bergmann
    Cc: Ben Hutchings
    Cc: David Decotigny ,
    Cc: David S. Miller ,
    Cc: Geert Uytterhoeven
    Cc: Matthew Wilcox
    Cc: Rasmus Villemoes
    Cc: Heiner Kallweit
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Yury Norov
     
  • This patchset replaces bitmap_{to,from}_u32array with more simple and
    standard looking copy-like functions.

    bitmap_from_u32array() takes 4 arguments (bitmap_to_u32array is similar):
    - unsigned long *bitmap, which is destination;
    - unsigned int nbits, the length of destination bitmap, in bits;
    - const u32 *buf, the source; and
    - unsigned int nwords, the length of source buffer in ints.

    In description to the function it is detailed like:
    * copy min(nbits, 32*nwords) bits from @buf to @bitmap, remaining
    * bits between nword and nbits in @bitmap (if any) are cleared.

    Having two size arguments looks unneeded and potentially dangerous.

    It is unneeded because normally user of copy-like function should take
    care of the size of destination and make it big enough to fit source
    data.

    And it is dangerous because function may hide possible error if user
    doesn't provide big enough bitmap, and data becomes silently dropped.

    That's why all copy-like functions have 1 argument for size of copying
    data, and I don't see any reason to make bitmap_from_u32array()
    different.

    One exception that comes in mind is strncpy() which also provides size
    of destination in arguments, but it's strongly argued by the possibility
    of taking broken strings in source. This is not the case of
    bitmap_{from,to}_u32array().

    There is no many real users of bitmap_{from,to}_u32array(), and they all
    very clearly provide size of destination matched with the size of
    source, so additional functionality is not used in fact. Like this:
    bitmap_from_u32array(to->link_modes.supported,
    __ETHTOOL_LINK_MODE_MASK_NBITS,
    link_usettings.link_modes.supported,
    __ETHTOOL_LINK_MODE_MASK_NU32);
    Where:
    #define __ETHTOOL_LINK_MODE_MASK_NU32 \
    DIV_ROUND_UP(__ETHTOOL_LINK_MODE_MASK_NBITS, 32)

    In this patch, bitmap_copy_safe and bitmap_{from,to}_arr32 are introduced.

    'Safe' in bitmap_copy_safe() stands for clearing unused bits in bitmap
    beyond last bit till the end of last word. It is useful for hardening
    API when bitmap is assumed to be exposed to userspace.

    bitmap_{from,to}_arr32 functions are replacements for
    bitmap_{from,to}_u32array. They don't take unneeded nwords argument, and
    so simpler in implementation and understanding.

    This patch suggests optimization for 32-bit systems - aliasing
    bitmap_{from,to}_arr32 to bitmap_copy_safe.

    Other possible optimization is aliasing 64-bit LE bitmap_{from,to}_arr32 to
    more generic function(s). But I didn't end up with the function that would
    be helpful by itself, and can be used to alias 64-bit LE
    bitmap_{from,to}_arr32, like bitmap_copy_safe() does. So I preferred to
    leave things as is.

    The following patch switches kernel to new API and introduces test for it.

    Discussion is here: https://lkml.org/lkml/2017/11/15/592

    [ynorov@caviumnetworks.com: rename bitmap_copy_safe to bitmap_copy_clear_tail]
    Link: http://lkml.kernel.org/r/20180201172508.5739-3-ynorov@caviumnetworks.com
    Link: http://lkml.kernel.org/r/20171228150019.27953-1-ynorov@caviumnetworks.com
    Signed-off-by: Yury Norov
    Cc: Ben Hutchings
    Cc: David Decotigny ,
    Cc: David S. Miller ,
    Cc: Geert Uytterhoeven
    Cc: Matthew Wilcox
    Cc: Rasmus Villemoes
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Yury Norov
     
  • Variable real_size is initialized with a value that is never read, it is
    re-assigned a new value later on, hence the initialization is redundant
    and can be removed.

    Cleans up clang warning:

    lib/test_kasan.c:422:21: warning: Value stored to 'real_size' during its initialization is never read

    Link: http://lkml.kernel.org/r/20180206144950.32457-1-colin.king@canonical.com
    Signed-off-by: Colin Ian King
    Acked-by: Andrey Ryabinin
    Reviewed-by: Andrew Morton
    Cc: Alexander Potapenko
    Cc: Dmitry Vyukov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Colin Ian King
     
  • Detect frees of pointers into middle of heap objects.

    Link: http://lkml.kernel.org/r/cb569193190356beb018a03bb8d6fbae67e7adbc.1514378558.git.dvyukov@google.com
    Signed-off-by: Dmitry Vyukov
    Cc: Andrey Ryabinin a
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Dmitry Vyukov
     
  • Patch series "kasan: detect invalid frees".

    KASAN detects double-frees, but does not detect invalid-frees (when a
    pointer into a middle of heap object is passed to free). We recently had
    a very unpleasant case in crypto code which freed an inner object inside
    of a heap allocation. This left unnoticed during free, but totally
    corrupted heap and later lead to a bunch of random crashes all over kernel
    code.

    Detect invalid frees.

    This patch (of 5):

    Detect frees of pointers into middle of large heap objects.

    I dropped const from kasan_kfree_large() because it starts propagating
    through a bunch of functions in kasan_report.c, slab/slub nearest_obj(),
    all of their local variables, fixup_red_left(), etc.

    Link: http://lkml.kernel.org/r/1b45b4fe1d20fc0de1329aab674c1dd973fee723.1514378558.git.dvyukov@google.com
    Signed-off-by: Dmitry Vyukov
    Cc: Andrey Ryabinin a
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Dmitry Vyukov