17 Apr, 2019

1 commit

  • [ Upstream commit fae2708174ae95d98d19f194e03d6e8f688ae195 ]

    the control path of 'sample' action does not validate the value of 'rate'
    provided by the user, but then it uses it as divisor in the traffic path.
    Validate it in tcf_sample_init(), and return -EINVAL with a proper extack
    message in case that value is zero, to fix a splat with the script below:

    # tc f a dev test0 egress matchall action sample rate 0 group 1 index 2
    # tc -s a s action sample
    total acts 1

    action order 0: sample rate 1/0 group 1 pipe
    index 2 ref 1 bind 1 installed 19 sec used 19 sec
    Action statistics:
    Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
    backlog 0b 0p requeues 0
    # ping 192.0.2.1 -I test0 -c1 -q

    divide error: 0000 [#1] SMP PTI
    CPU: 1 PID: 6192 Comm: ping Not tainted 5.1.0-rc2.diag2+ #591
    Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011
    RIP: 0010:tcf_sample_act+0x9e/0x1e0 [act_sample]
    Code: 6a f1 85 c0 74 0d 80 3d 83 1a 00 00 00 0f 84 9c 00 00 00 4d 85 e4 0f 84 85 00 00 00 e8 9b d7 9c f1 44 8b 8b e0 00 00 00 31 d2 f7 f1 85 d2 75 70 f6 85 83 00 00 00 10 48 8b 45 10 8b 88 08 01
    RSP: 0018:ffffae320190ba30 EFLAGS: 00010246
    RAX: 00000000b0677d21 RBX: ffff8af1ed9ec000 RCX: 0000000059a9fe49
    RDX: 0000000000000000 RSI: 000000000c7e33b7 RDI: ffff8af23daa0af0
    RBP: ffff8af1ee11b200 R08: 0000000074fcaf7e R09: 0000000000000000
    R10: 0000000000000050 R11: ffffffffb3088680 R12: ffff8af232307f80
    R13: 0000000000000003 R14: ffff8af1ed9ec000 R15: 0000000000000000
    FS: 00007fe9c6d2f740(0000) GS:ffff8af23da80000(0000) knlGS:0000000000000000
    CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 00007fff6772f000 CR3: 00000000746a2004 CR4: 00000000001606e0
    Call Trace:
    tcf_action_exec+0x7c/0x1c0
    tcf_classify+0x57/0x160
    __dev_queue_xmit+0x3dc/0xd10
    ip_finish_output2+0x257/0x6d0
    ip_output+0x75/0x280
    ip_send_skb+0x15/0x40
    raw_sendmsg+0xae3/0x1410
    sock_sendmsg+0x36/0x40
    __sys_sendto+0x10e/0x140
    __x64_sys_sendto+0x24/0x30
    do_syscall_64+0x60/0x210
    entry_SYSCALL_64_after_hwframe+0x49/0xbe
    [...]
    Kernel panic - not syncing: Fatal exception in interrupt

    Add a TDC selftest to document that 'rate' is now being validated.

    Reported-by: Matteo Croce
    Fixes: 5c5670fae430 ("net/sched: Introduce sample tc action")
    Signed-off-by: Davide Caratti
    Acked-by: Yotam Gigi
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Davide Caratti
     

06 Apr, 2019

2 commits

  • [ Upstream commit 8184d44c9a577a2f1842ed6cc844bfd4a9981d8e ]

    Use recently introduced bpf_probe_prog_type() to skip tests in the
    test_verifier() if bpf_verify_program() fails. The skipped test is
    indicated in the output.

    Example:

    ...
    679/p bpf_get_stack return R0 within range SKIP (unsupported program
    type 5)
    680/p ld_abs: invalid op 1 OK
    ...
    Summary: 863 PASSED, 165 SKIPPED, 3 FAILED

    Signed-off-by: Stanislav Fomichev
    Signed-off-by: Daniel Borkmann
    Signed-off-by: Sasha Levin

    Stanislav Fomichev
     
  • [ Upstream commit 3aa415dd2128e478ea3225b59308766de0e94d6b ]

    The get_metadata() test requires real root, so let's skip it if we're not
    real root.

    Note that I used XFAIL here because that's what the test does later if
    CONFIG_CHEKCKPOINT_RESTORE happens to not be enabled. After looking at the
    code, there doesn't seem to be a nice way to skip tests defined as TEST(),
    since there's no return code (I tried exit(KSFT_SKIP), but that didn't work
    either...). So let's do it this way to be consistent, and easier to fix
    when someone comes along and fixes it.

    Signed-off-by: Tycho Andersen
    Acked-by: Kees Cook
    Signed-off-by: Shuah Khan
    Signed-off-by: Sasha Levin

    Tycho Andersen
     

24 Mar, 2019

2 commits

  • [ Upstream commit af548a27b158d548d41e56255e6eaca1658cc3be ]

    Just like commit e2ba732a1681 ("selftests: fib_tests: sleep after
    changing carrier"), wait one second to allow linkwatch to propagate the
    carrier change to the stack.

    There are two sets of carrier tests. The first slept after the carrier
    was set to off, and when the second set ran, it was likely that the
    linkwatch would be able to run again without much delay, reducing the
    likelihood of a race. However, if you run 'fib_tests.sh -t carrier' on a
    loop, you will quickly notice the failures.

    Sleeping on the second set of tests make the failures go away.

    Cc: David Ahern
    Signed-off-by: Thadeu Lima de Souza Cascardo
    Reviewed-by: David Ahern
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Thadeu Lima de Souza Cascardo
     
  • [ Upstream commit 7c0cdf0b3940f63d9777c3fcf250a2f83859ca54 ]

    trie_delete_elem() was deleting an entry even though it was not matching
    if the prefixlen was correct. This patch adds a check on matchlen.

    Reproducer:

    $ sudo bpftool map create /sys/fs/bpf/mylpm type lpm_trie key 8 value 1 entries 128 name mylpm flags 1
    $ sudo bpftool map update pinned /sys/fs/bpf/mylpm key hex 10 00 00 00 aa bb cc dd value hex 01
    $ sudo bpftool map dump pinned /sys/fs/bpf/mylpm
    key: 10 00 00 00 aa bb cc dd value: 01
    Found 1 element
    $ sudo bpftool map delete pinned /sys/fs/bpf/mylpm key hex 10 00 00 00 ff ff ff ff
    $ echo $?
    0
    $ sudo bpftool map dump pinned /sys/fs/bpf/mylpm
    Found 0 elements

    A similar reproducer is added in the selftests.

    Without the patch:

    $ sudo ./tools/testing/selftests/bpf/test_lpm_map
    test_lpm_map: test_lpm_map.c:485: test_lpm_delete: Assertion `bpf_map_delete_elem(map_fd, key) == -1 && errno == ENOENT' failed.
    Aborted

    With the patch: test_lpm_map runs without errors.

    Fixes: e454cf595853 ("bpf: Implement map_delete_elem for BPF_MAP_TYPE_LPM_TRIE")
    Cc: Craig Gallek
    Signed-off-by: Alban Crequy
    Acked-by: Craig Gallek
    Signed-off-by: Daniel Borkmann
    Signed-off-by: Sasha Levin

    Alban Crequy
     

14 Mar, 2019

7 commits

  • [ Upstream commit 98bfc3414bda335dbd7fec58bde6266f991801d7 ]

    Check basic nat/redirect/masquerade for ipv4 and ipv6.

    Signed-off-by: Florian Westphal
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Sasha Levin

    Florian Westphal
     
  • [ Upstream commit 952b72f89ae23b316da8c1021b18d0c388ad6cc4 ]

    In selftests the config fragment for netfilter was added as
    NF_TABLES_INET=y and this patch correct it as CONFIG_NF_TABLES_INET=y

    Signed-off-by: Naresh Kamboju
    Acked-by: Florian Westphal
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Sasha Levin

    Naresh Kamboju
     
  • [ Upstream commit 1bb54c4071f585ebef56ce8fdfe6026fa2cbcddd ]

    Previously, bpf_num_possible_cpus() had a bug when calculating a
    number of possible CPUs in the case of sparse CPU allocations, as
    it was considering only the first range or element of
    /sys/devices/system/cpu/possible.

    E.g. in the case of "0,2-3" (CPU 1 is not available), the function
    returned 1 instead of 3.

    This patch fixes the function by making it parse all CPU ranges and
    elements.

    Signed-off-by: Martynas Pumputis
    Acked-by: Yonghong Song
    Signed-off-by: Daniel Borkmann
    Signed-off-by: Sasha Levin

    Martynas Pumputis
     
  • [ Upstream commit 1fde6f21d90f8ba5da3cb9c54ca991ed72696c43 ]

    /proc entries under /proc/net/* can't be cached into dcache because
    setns(2) can change current net namespace.

    [akpm@linux-foundation.org: coding-style fixes]
    [akpm@linux-foundation.org: avoid vim miscolorization]
    [adobriyan@gmail.com: write test, add dummy ->d_revalidate hook: necessary if /proc/net/* is pinned at setns time]
    Link: http://lkml.kernel.org/r/20190108192350.GA12034@avx2
    Link: http://lkml.kernel.org/r/20190107162336.GA9239@avx2
    Fixes: 1da4d377f943fe4194ffb9fb9c26cc58fad4dd24 ("proc: revalidate misc dentries")
    Signed-off-by: Alexey Dobriyan
    Reported-by: Mateusz Stępień
    Reported-by: Ahmad Fatoum
    Cc: Al Viro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Sasha Levin

    Alexey Dobriyan
     
  • [ Upstream commit 7d4e591bc051d3382c45caaa2530969fb42ed23d ]

    posix_timers fails to build due to undefined reference errors:

    aarch64-linaro-linux-gcc --sysroot=/build/tmp-rpb-glibc/sysroots/hikey
    -O2 -pipe -g -feliminate-unused-debug-types -O3 -Wl,-no-as-needed -Wall
    -DKTEST -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -lrt -lpthread
    posix_timers.c
    -o /build/tmp-rpb-glibc/work/hikey-linaro-linux/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/timers/posix_timers
    /tmp/cc1FTZzT.o: In function `check_timer_create':
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/timers/posix_timers.c:157:
    undefined reference to `timer_create'
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/timers/posix_timers.c:170:
    undefined reference to `timer_settime'
    collect2: error: ld returned 1 exit status

    It's GNU Make and linker specific.

    The default Makefile rule looks like:

    $(CC) $(CFLAGS) $(LDFLAGS) $@ $^ $(LDLIBS)

    When linking is done by gcc itself, no issue, but when it needs to be passed
    to proper ld, only LDLIBS follows and then ld cannot know what libs to link
    with.

    More detail:
    https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html

    LDFLAGS
    Extra flags to give to compilers when they are supposed to invoke the linker,
    ‘ld’, such as -L. Libraries (-lfoo) should be added to the LDLIBS variable
    instead.

    LDLIBS
    Library flags or names given to compilers when they are supposed to invoke the
    linker, ‘ld’. LOADLIBES is a deprecated (but still supported) alternative to
    LDLIBS. Non-library linker flags, such as -L, should go in the LDFLAGS
    variable.

    https://lkml.org/lkml/2010/2/10/362

    tools/perf: libraries must come after objects

    Link order matters, use LDLIBS instead of LDFLAGS to properly link against
    libpthread.

    Signed-off-by: Denys Dmytriyenko
    Signed-off-by: Fathi Boudra
    Signed-off-by: Shuah Khan
    Signed-off-by: Sasha Levin

    Fathi Boudra
     
  • [ Upstream commit 870f193d48c25a97d61a8e6c04e3c29a2c606850 ]

    reuseport_bpf_numa fails to build due to undefined reference errors:

    aarch64-linaro-linux-gcc
    --sysroot=/build/tmp-rpb-glibc/sysroots/hikey -Wall
    -Wl,--no-as-needed -O2 -g -I../../../../usr/include/ -Wl,-O1
    -Wl,--hash-style=gnu -Wl,--as-needed -lnuma reuseport_bpf_numa.c
    -o
    /build/tmp-rpb-glibc/work/hikey-linaro-linux/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/net/reuseport_bpf_numa
    /tmp/ccfUuExT.o: In function `send_from_node':
    /build/tmp-rpb-glibc/work/hikey-linaro-linux/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/net/reuseport_bpf_numa.c:138:
    undefined reference to `numa_run_on_node'
    /tmp/ccfUuExT.o: In function `main':
    /build/tmp-rpb-glibc/work/hikey-linaro-linux/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/net/reuseport_bpf_numa.c:230:
    undefined reference to `numa_available'
    /build/tmp-rpb-glibc/work/hikey-linaro-linux/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/net/reuseport_bpf_numa.c:233:
    undefined reference to `numa_max_node'

    It's GNU Make and linker specific.

    The default Makefile rule looks like:

    $(CC) $(CFLAGS) $(LDFLAGS) $@ $^ $(LDLIBS)

    When linking is done by gcc itself, no issue, but when it needs to be passed
    to proper ld, only LDLIBS follows and then ld cannot know what libs to link
    with.

    More detail:
    https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html

    LDFLAGS
    Extra flags to give to compilers when they are supposed to invoke the linker,
    ‘ld’, such as -L. Libraries (-lfoo) should be added to the LDLIBS variable
    instead.

    LDLIBS
    Library flags or names given to compilers when they are supposed to invoke the
    linker, ‘ld’. LOADLIBES is a deprecated (but still supported) alternative to
    LDLIBS. Non-library linker flags, such as -L, should go in the LDFLAGS
    variable.

    https://lkml.org/lkml/2010/2/10/362

    tools/perf: libraries must come after objects

    Link order matters, use LDLIBS instead of LDFLAGS to properly link against
    libnuma.

    Signed-off-by: Fathi Boudra
    Signed-off-by: Shuah Khan
    Signed-off-by: Sasha Levin

    Fathi Boudra
     
  • [ Upstream commit 2b531b6137834a55857a337ac17510d6436b6fbb ]

    The cpu-hotplug test assumes that we can offline the maximum CPU as
    described by /sys/devices/system/cpu/offline. However, in the case
    where the number of CPUs exceeds like kernel configuration then
    the offline count can be greater than the present count and we end
    up trying to test the offlining of a CPU that is not available to
    offline. Fix this by testing the maximum present CPU instead.

    Also, the test currently offlines the CPU and does not online it,
    so fix this by onlining the CPU after the test.

    Fixes: d89dffa976bc ("fault-injection: add selftests for cpu and memory hotplug")
    Signed-off-by: Colin Ian King
    Signed-off-by: Shuah Khan
    Signed-off-by: Sasha Levin

    Colin Ian King
     

10 Mar, 2019

1 commit

  • commit 344c0152d878922365464b7140c74c2a5e073d99 upstream.

    commit a6a9be9270c87 ("selftests: firmware: return Kselftest Skip code
    for skipped tests") by Shuah modified failures to return the special
    error code of $ksft_skip (4). We have a corner case issue where we
    *do* want to verify_reqs().

    Cc: # >= 4.18
    Fixes: a6a9be9270c87 ("selftests: firmware: return Kselftest Skip code for for skipped tests")
    Signed-off-by: Greg Kroah-Hartman
    Signed-off-by: Greg Kroah-Hartman

    Luis Chamberlain
     

06 Mar, 2019

6 commits

  • [ Upstream commit 94a980c39c8e3f8abaff5d3b5bbcd4ccf1c02c4f ]

    Fix a call to userspace_mem_region_find to conform to its spec of
    taking an inclusive, inclusive range. It was previously being called
    with an inclusive, exclusive range. Also remove a redundant region bounds
    check in vm_userspace_mem_region_add. Region overlap checking is already
    performed by the call to userspace_mem_region_find.

    Tested: Compiled tools/testing/selftests/kvm with -static
    Ran all resulting test binaries on an Intel Haswell test machine
    All tests passed

    Signed-off-by: Ben Gardon
    Reviewed-by: Jim Mattson
    Signed-off-by: Paolo Bonzini
    Signed-off-by: Sasha Levin

    Ben Gardon
     
  • [ Upstream commit 508cacd7da6659ae7b7bdd0a335f675422277758 ]

    With gcc 7.3.0:

    gpio-mockup-chardev.c: In function ‘get_debugfs’:
    gpio-mockup-chardev.c:62:3: warning: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Wunused-result]
    asprintf(path, "%s/gpio", mnt_fs_get_target(fs));
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Handle asprintf() failures to fix this.

    Signed-off-by: Geert Uytterhoeven
    Signed-off-by: Shuah Khan
    Signed-off-by: Sasha Levin

    Geert Uytterhoeven
     
  • [ Upstream commit 5bbc73a841d7f0bbe025a342146dde462a796a5a ]

    seccomp_bpf fails to build due to undefined reference errors:

    aarch64-linaro-linux-gcc --sysroot=/build/tmp-rpb-glibc/sysroots/hikey
    -O2 -pipe -g -feliminate-unused-debug-types -Wl,-no-as-needed -Wall
    -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -lpthread seccomp_bpf.c -o
    /build/tmp-rpb-glibc/work/hikey-linaro-linux/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf
    /tmp/ccrlR3MW.o: In function `tsync_sibling':
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1920: undefined reference to `sem_post'
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1920: undefined reference to `sem_post'
    /tmp/ccrlR3MW.o: In function `TSYNC_setup':
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1863: undefined reference to `sem_init'
    /tmp/ccrlR3MW.o: In function `TSYNC_teardown':
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1904: undefined reference to `sem_destroy'
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1897: undefined reference to `pthread_kill'
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1898: undefined reference to `pthread_cancel'
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1899: undefined reference to `pthread_join'
    /tmp/ccrlR3MW.o: In function `tsync_start_sibling':
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
    /tmp/ccrlR3MW.o: In function `TSYNC_siblings_fail_prctl':
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1978: undefined reference to `sem_wait'
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1990: undefined reference to `pthread_join'
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1992: undefined reference to `pthread_join'
    /tmp/ccrlR3MW.o: In function `tsync_start_sibling':
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
    /tmp/ccrlR3MW.o: In function `TSYNC_two_siblings_with_ancestor':
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2016: undefined reference to `sem_wait'
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2032: undefined reference to `pthread_join'
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2034: undefined reference to `pthread_join'
    /tmp/ccrlR3MW.o: In function `tsync_start_sibling':
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
    /tmp/ccrlR3MW.o: In function `TSYNC_two_sibling_want_nnp':
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2046: undefined reference to `sem_wait'
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2058: undefined reference to `pthread_join'
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2060: undefined reference to `pthread_join'
    /tmp/ccrlR3MW.o: In function `tsync_start_sibling':
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
    /tmp/ccrlR3MW.o: In function `TSYNC_two_siblings_with_no_filter':
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2073: undefined reference to `sem_wait'
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2098: undefined reference to `pthread_join'
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2100: undefined reference to `pthread_join'
    /tmp/ccrlR3MW.o: In function `tsync_start_sibling':
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
    /tmp/ccrlR3MW.o: In function `TSYNC_two_siblings_with_one_divergence':
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2125: undefined reference to `sem_wait'
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2143: undefined reference to `pthread_join'
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2145: undefined reference to `pthread_join'
    /tmp/ccrlR3MW.o: In function `tsync_start_sibling':
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
    /tmp/ccrlR3MW.o: In function `TSYNC_two_siblings_not_under_filter':
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2169: undefined reference to `sem_wait'
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2202: undefined reference to `pthread_join'
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2227: undefined reference to `pthread_join'
    /tmp/ccrlR3MW.o: In function `tsync_start_sibling':
    /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'

    It's GNU Make and linker specific.

    The default Makefile rule looks like:

    $(CC) $(CFLAGS) $(LDFLAGS) $@ $^ $(LDLIBS)

    When linking is done by gcc itself, no issue, but when it needs to be passed
    to proper ld, only LDLIBS follows and then ld cannot know what libs to link
    with.

    More detail:
    https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html

    LDFLAGS
    Extra flags to give to compilers when they are supposed to invoke the linker,
    ‘ld’, such as -L. Libraries (-lfoo) should be added to the LDLIBS variable
    instead.

    LDLIBS
    Library flags or names given to compilers when they are supposed to invoke the
    linker, ‘ld’. LOADLIBES is a deprecated (but still supported) alternative to
    LDLIBS. Non-library linker flags, such as -L, should go in the LDFLAGS
    variable.

    https://lkml.org/lkml/2010/2/10/362

    tools/perf: libraries must come after objects

    Link order matters, use LDLIBS instead of LDFLAGS to properly link against
    libpthread.

    Signed-off-by: Fathi Boudra
    Acked-by: Kees Cook
    Signed-off-by: Shuah Khan
    Signed-off-by: Sasha Levin

    Fathi Boudra
     
  • [ Upstream commit 91cd63d320f84dcbf21d4327f31f7e1f85adebd0 ]

    An expansion field was added to the kernel copy of this structure for
    future use. See mm/gup_benchmark.c.

    Add the same expansion field here, so that the IOCTL command decodes
    correctly. Otherwise, it fails with EINVAL.

    Signed-off-by: Alison Schofield
    Acked-by: Kirill A. Shutemov
    Signed-off-by: Shuah Khan
    Signed-off-by: Sasha Levin

    Alison Schofield
     
  • [ Upstream commit 7b3027728f4d4f6763f4d7e771acfc9424cdd0e6 ]

    Unfortunately, some RTC don't have a second resolution for alarm so also
    test for alarm on a minute boundary.

    Signed-off-by: Alexandre Belloni
    Signed-off-by: Shuah Khan
    Signed-off-by: Sasha Levin

    Alexandre Belloni
     
  • [ Upstream commit fdac94489c4d247088b3885875b39b3e1eb621ef ]

    Return values for select are not checked properly and timeouts may not be
    detected.

    Signed-off-by: Alexandre Belloni
    Signed-off-by: Shuah Khan
    Signed-off-by: Sasha Levin

    Alexandre Belloni
     

27 Feb, 2019

7 commits

  • [ Upstream commit 479a2b761d61c04e2ae97325aa391a8a8c99c23e ]

    Test that externally learned FDB entries can roam, but not age out.

    Signed-off-by: Ido Schimmel
    Reviewed-by: Petr Machata
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Ido Schimmel
     
  • [ Upstream commit f67ad87ab3120e82845521b18a2b99273a340308 ]

    While running test_progs in a loop I found out that I'm sometimes hitting
    "Didn't find expected build ID from the map" error.

    Looking at stack_map_get_build_id_offset() it seems that it is racy (by
    design) and can sometimes return BPF_STACK_BUILD_ID_IP (i.e. can't trylock
    current->mm->mmap_sem).

    Let's retry this test a single time.

    Fixes: 13790d1cc72c ("bpf: add selftest for stackmap with build_id in NMI context")
    Acked-by: Song Liu
    Signed-off-by: Stanislav Fomichev
    Signed-off-by: Daniel Borkmann
    Signed-off-by: Sasha Levin

    Stanislav Fomichev
     
  • [ Upstream commit 91fa038d9446b5bf5ea80822790af7dd9bcbb5a2 ]

    In iproute2 commit 90c5c969f0b9 ("fix print_0xhex on 32 bit"), the format
    specifier for the ife type changed from 0x%X to %#llX, causing systematic
    failures in the following TDC test cases:

    7682 - Create valid ife encode action with mark and pass control
    ef47 - Create valid ife encode action with mark and pipe control
    df43 - Create valid ife encode action with mark and continue control
    e4cf - Create valid ife encode action with mark and drop control
    ccba - Create valid ife encode action with mark and reclassify control
    a1cf - Create valid ife encode action with mark and jump control
    cb3d - Create valid ife encode action with mark value at 32-bit maximum
    95ed - Create valid ife encode action with prio and pass control
    aa17 - Create valid ife encode action with prio and pipe control
    74c7 - Create valid ife encode action with prio and continue control
    7a97 - Create valid ife encode action with prio and drop control
    f66b - Create valid ife encode action with prio and reclassify control
    3056 - Create valid ife encode action with prio and jump control
    7dd3 - Create valid ife encode action with prio value at 32-bit maximum
    05bb - Create valid ife encode action with tcindex and pass control
    ce65 - Create valid ife encode action with tcindex and pipe control
    09cd - Create valid ife encode action with tcindex and continue control
    8eb5 - Create valid ife encode action with tcindex and continue control
    451a - Create valid ife encode action with tcindex and drop control
    d76c - Create valid ife encode action with tcindex and reclassify control
    e731 - Create valid ife encode action with tcindex and jump control
    b7b8 - Create valid ife encode action with tcindex value at 16-bit maximum
    2a9c - Create valid ife encode action with mac src parameter
    cf5c - Create valid ife encode action with mac dst parameter
    2353 - Create valid ife encode action with mac src and mac dst parameters
    552c - Create valid ife encode action with mark and type parameters
    0421 - Create valid ife encode action with prio and type parameters
    4017 - Create valid ife encode action with tcindex and type parameters
    fac3 - Create valid ife encode action with index at 32-bit maximnum
    7c25 - Create valid ife decode action with pass control
    dccb - Create valid ife decode action with pipe control
    7bb9 - Create valid ife decode action with continue control
    d9ad - Create valid ife decode action with drop control
    219f - Create valid ife decode action with reclassify control
    8f44 - Create valid ife decode action with jump control
    b330 - Create ife encode action with cookie

    Change 'matchPattern' values, allowing '0' and '0x0' if ife type is equal
    to 0, and accepting both '0x' and '0X' otherwise, to let these tests pass
    both with old and new tc binaries.
    While at it, fix a small typo in test case fac3 ('maximnum'->'maximum').

    Signed-off-by: Davide Caratti
    Acked-by: Stephen Hemminger
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Davide Caratti
     
  • [ Upstream commit 5216bd77798e2ed773ecd45f3f368dcaec63e5dd ]

    After commit 1c25324caf82 ("net/sched: act_tunnel_key: Don't dump dst port
    if it wasn't set"), act_tunnel_key doesn't dump anymore the destination
    port, unless it was explicitly configured. This caused systematic failures
    in the following TDC test case:

    7a88 - Add tunnel_key action with cookie parameter

    Avoid matching zero values of TCA_TUNNEL_KEY_ENC_DST_PORT to let the test
    pass again.

    Signed-off-by: Davide Caratti
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Davide Caratti
     
  • [ Upstream commit e413615502a3324daba038f529932ba9a5248af0 ]

    After merge of commit 80ef0f22ceda ("net/sched: act_tunnel_key: Allow
    key-less tunnels"), act_tunnel_key does not reject anymore requests to
    install 'set' rules where the key id is missing. Therefore, drop the
    following TDC testcase:

    ba4e - Add tunnel_key set action with missing mandatory id parameter

    because it's going to become a systematic fail as soon as userspace
    iproute2 will start supporting key-less tunnels.

    Signed-off-by: Davide Caratti
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Davide Caratti
     
  • [ Upstream commit 4fabf3bf93a194c7fa5288da3e0af37e4b943cf3 ]

    Add a VLAN on a bridge port, delete it and make sure the PVID VLAN is
    not affected.

    Signed-off-by: Ido Schimmel
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Ido Schimmel
     
  • [ Upstream commit 976b4f3a4646fbf0d189caca25f91f82e4be4b5a ]

    Test that sys_sendmsg BPF hook doesn't break sys_sendmsg behaviour to
    rewrite destination IPv6 = [::] with [::1] (BSD'ism).

    Two test cases are added:

    1) User passes dst IPv6 = [::] and BPF_CGROUP_UDP6_SENDMSG program
    doesn't touch it.

    2) User passes dst IPv6 != [::], but BPF_CGROUP_UDP6_SENDMSG program
    rewrites it with [::].

    In both cases [::1] is used by sys_sendmsg code eventually and datagram
    is sent successfully for unconnected UDP socket.

    Example of relevant output:
    Test case: sendmsg6: set dst IP = [::] (BSD'ism) .. [PASS]
    Test case: sendmsg6: preserve dst IP = [::] (BSD'ism) .. [PASS]

    Signed-off-by: Andrey Ignatov
    Signed-off-by: Alexei Starovoitov
    Signed-off-by: Sasha Levin

    Andrey Ignatov
     

13 Feb, 2019

1 commit

  • [ Upstream commit a0517a0f7ef23550b4484c37e2b9c2d32abebf64 ]

    For some reason, my older GCC (< 4.8) isn't smart enough to optimize the
    !__builtin_constant_p() branch in bpf_htons, I see:
    error: implicit declaration of function '__builtin_bswap16'

    Let's use __bpf_constant_htons as suggested by Daniel Borkmann.

    I tried to use simple htons, but it produces the following:
    test_progs.c:54:17: error: braced-group within expression allowed only
    inside a function
    .eth.h_proto = htons(ETH_P_IP),

    Signed-off-by: Stanislav Fomichev
    Signed-off-by: Daniel Borkmann
    Signed-off-by: Alexei Starovoitov
    Signed-off-by: Sasha Levin

    Stanislav Fomichev
     

07 Feb, 2019

1 commit

  • commit ed5f13261cb65b02c611ae9971677f33581d4286 upstream.

    Passing EPERM during syscall skipping was confusing since the test wasn't
    actually exercising the errno evaluation -- it was just passing a literal
    "1" (EPERM). Instead, expand the tests to check both direct value returns
    (positive, 45000 in this case), and errno values (negative, -ESRCH in this
    case) to check both fake success and fake failure during syscall skipping.

    Reported-by: Colin Ian King
    Fixes: a33b2d0359a0 ("selftests/seccomp: Add tests for basic ptrace actions")
    Cc: stable@vger.kernel.org
    Signed-off-by: Kees Cook
    Signed-off-by: Shuah Khan
    Signed-off-by: Greg Kroah-Hartman

    Kees Cook
     

31 Jan, 2019

1 commit

  • commit e1812933b17be7814f51b6c310c5d1ced7a9a5f5 upstream.

    There was a bug where the per-mm pkey state was not being preserved across
    fork() in the child. fork() is performed in the pkey selftests, but all of
    the pkey activity is performed in the parent. The child does not perform
    any actions sensitive to pkey state.

    To make the test more sensitive to these kinds of bugs, add a fork() where
    the parent exits, and execution continues in the child.

    To achieve this let the key exhaustion test not terminate at the first
    allocation failure and fork after 2*NR_PKEYS loops and continue in the
    child.

    Signed-off-by: Dave Hansen
    Signed-off-by: Thomas Gleixner
    Cc: bp@alien8.de
    Cc: hpa@zytor.com
    Cc: peterz@infradead.org
    Cc: mpe@ellerman.id.au
    Cc: will.deacon@arm.com
    Cc: luto@kernel.org
    Cc: jroedel@suse.de
    Cc: stable@vger.kernel.org
    Cc: Borislav Petkov
    Cc: "H. Peter Anvin"
    Cc: Peter Zijlstra
    Cc: Michael Ellerman
    Cc: Will Deacon
    Cc: Andy Lutomirski
    Cc: Joerg Roedel
    Link: https://lkml.kernel.org/r/20190102215657.585704B7@viggo.jf.intel.com
    Signed-off-by: Greg Kroah-Hartman

    Dave Hansen
     

26 Jan, 2019

3 commits

  • [ Upstream commit e434b8cdf788568ba65a0a0fd9f3cb41f3ca1803 ]

    Currently, the destination register is marked as unknown for 32-bit
    sub-register move (BPF_MOV | BPF_ALU) whenever the source register type is
    SCALAR_VALUE.

    This is too conservative that some valid cases will be rejected.
    Especially, this may turn a constant scalar value into unknown value that
    could break some assumptions of verifier.

    For example, test_l4lb_noinline.c has the following C code:

    struct real_definition *dst

    1: if (!get_packet_dst(&dst, &pckt, vip_info, is_ipv6))
    2: return TC_ACT_SHOT;
    3:
    4: if (dst->flags & F_IPV6) {

    get_packet_dst is responsible for initializing "dst" into valid pointer and
    return true (1), otherwise return false (0). The compiled instruction
    sequence using alu32 will be:

    412: (54) (u32) r7 &= (u32) 1
    413: (bc) (u32) r0 = (u32) r7
    414: (95) exit

    insn 413, a BPF_MOV | BPF_ALU, however will turn r0 into unknown value even
    r7 contains SCALAR_VALUE 1.

    This causes trouble when verifier is walking the code path that hasn't
    initialized "dst" inside get_packet_dst, for which case 0 is returned and
    we would then expect verifier concluding line 1 in the above C code pass
    the "if" check, therefore would skip fall through path starting at line 4.
    Now, because r0 returned from callee has became unknown value, so verifier
    won't skip analyzing path starting at line 4 and "dst->flags" requires
    dereferencing the pointer "dst" which actually hasn't be initialized for
    this path.

    This patch relaxed the code marking sub-register move destination. For a
    SCALAR_VALUE, it is safe to just copy the value from source then truncate
    it into 32-bit.

    A unit test also included to demonstrate this issue. This test will fail
    before this patch.

    This relaxation could let verifier skipping more paths for conditional
    comparison against immediate. It also let verifier recording a more
    accurate/strict value for one register at one state, if this state end up
    with going through exit without rejection and it is used for state
    comparison later, then it is possible an inaccurate/permissive value is
    better. So the real impact on verifier processed insn number is complex.
    But in all, without this fix, valid program could be rejected.

    >From real benchmarking on kernel selftests and Cilium bpf tests, there is
    no impact on processed instruction number when tests ares compiled with
    default compilation options. There is slightly improvements when they are
    compiled with -mattr=+alu32 after this patch.

    Also, test_xdp_noinline/-mattr=+alu32 now passed verification. It is
    rejected before this fix.

    Insn processed before/after this patch:

    default -mattr=+alu32

    Kernel selftest

    ===
    test_xdp.o 371/371 369/369
    test_l4lb.o 6345/6345 5623/5623
    test_xdp_noinline.o 2971/2971 rejected/2727
    test_tcp_estates.o 429/429 430/430

    Cilium bpf
    ===
    bpf_lb-DLB_L3.o: 2085/2085 1685/1687
    bpf_lb-DLB_L4.o: 2287/2287 1986/1982
    bpf_lb-DUNKNOWN.o: 690/690 622/622
    bpf_lxc.o: 95033/95033 N/A
    bpf_netdev.o: 7245/7245 N/A
    bpf_overlay.o: 2898/2898 3085/2947

    NOTE:
    - bpf_lxc.o and bpf_netdev.o compiled by -mattr=+alu32 are rejected by
    verifier due to another issue inside verifier on supporting alu32
    binary.
    - Each cilium bpf program could generate several processed insn number,
    above number is sum of them.

    v1->v2:
    - Restrict the change on SCALAR_VALUE.
    - Update benchmark numbers on Cilium bpf tests.

    Signed-off-by: Jiong Wang
    Signed-off-by: Alexei Starovoitov
    Signed-off-by: Sasha Levin

    Jiong Wang
     
  • [ Upstream commit b708a3cc9600390ccaa2b68a88087dd265154b2b ]

    I've stumbled over the current macro-expand behaviour of the test
    harness:

    $ gcc -Wall -xc - <:4:global.macro:Expected 0 (0) != (((signed char) (((status) & 0x7f) + 1) >> 1) > 0) (0)
    global.macro: Test terminated by assertion
    [ FAIL ] global.macro
    [==========] 0 / 1 tests passed.
    [ FAILED ]

    With this change the output of the same test looks much more
    comprehensible:

    [==========] Running 1 tests from 1 test cases.
    [ RUN ] global.macro
    :4:global.macro:Expected 0 (0) != WIFSIGNALED(status) (0)
    global.macro: Test terminated by assertion
    [ FAIL ] global.macro
    [==========] 0 / 1 tests passed.
    [ FAILED ]

    The issue is very similar to the bug fixed in glibc assert(3)
    three years ago:
    https://sourceware.org/bugzilla/show_bug.cgi?id=18604

    Cc: Shuah Khan
    Cc: Kees Cook
    Cc: Andy Lutomirski
    Cc: Will Drewry
    Cc: linux-kselftest@vger.kernel.org
    Signed-off-by: Dmitry V. Levin
    Acked-by: Kees Cook
    Signed-off-by: Shuah Khan
    Signed-off-by: Sasha Levin

    Dmitry V. Levin
     
  • [ Upstream commit f96afa767baffba7645f5e10998f5178948bb9aa ]

    libbpf is now able to load successfully test_l4lb_noinline.o and
    samples/bpf/tracex3_kern.o.

    For the test_l4lb_noinline, uncomment related tests from test_libbpf.c
    and remove the associated "TODO".

    For tracex3_kern.o, instead of loading a program from samples/bpf/ that
    might not have been compiled at this stage, try loading a program from
    BPF selftests. Since this test case is about loading a program compiled
    without the "-target bpf" flag, change the Makefile to compile one
    program accordingly (instead of passing the flag for compiling all
    programs).

    Regarding test_xdp_noinline.o: in its current shape the program fails to
    load because it provides no version section, but the loader needs one.
    The test was added to make sure that libbpf could load XDP programs even
    if they do not provide a version number in a dedicated section. But
    libbpf is already capable of doing that: in our case loading fails
    because the loader does not know that this is an XDP program (it does
    not need to, since it does not attach the program). So trying to load
    test_xdp_noinline.o does not bring much here: just delete this subtest.

    For the record, the error message obtained with tracex3_kern.o was
    fixed by commit e3d91b0ca523 ("tools/libbpf: handle issues with bpf ELF
    objects containing .eh_frames")

    I have not been abled to reproduce the "libbpf: incorrect bpf_call
    opcode" error for test_l4lb_noinline.o, even with the version of libbpf
    present at the time when test_libbpf.sh and test_libbpf_open.c were
    created.

    RFC -> v1:
    - Compile test_xdp without the "-target bpf" flag, and try to load it
    instead of ../../samples/bpf/tracex3_kern.o.
    - Delete test_xdp_noinline.o subtest.

    Cc: Jesper Dangaard Brouer
    Signed-off-by: Quentin Monnet
    Acked-by: Jakub Kicinski
    Acked-by: Jesper Dangaard Brouer
    Signed-off-by: Daniel Borkmann
    Signed-off-by: Sasha Levin

    Quentin Monnet
     

23 Jan, 2019

1 commit

  • commit 211929fd3f7c8de4d541b1cc243b82830e5ea1e8 upstream.

    Commit b2d35fa5fc80 ("selftests: add headers_install to lib.mk") added
    khdr target to run headers_install target from the main Makefile. The
    logic uses KSFT_KHDR_INSTALL and top_srcdir as controls to initialize
    variables and include files to run headers_install from the top level
    Makefile. There are a few problems with this logic.

    1. Exposes top_srcdir to all tests
    2. Common logic impacts all tests
    3. Uses KSFT_KHDR_INSTALL, top_srcdir, and khdr in an adhoc way. Tests
    add "khdr" dependency in their Makefiles to TEST_PROGS_EXTENDED in
    some cases, and STATIC_LIBS in other cases. This makes this framework
    confusing to use.

    The common logic that runs for all tests even when KSFT_KHDR_INSTALL
    isn't defined by the test. top_srcdir is initialized to a default value
    when test doesn't initialize it. It works for all tests without a sub-dir
    structure and tests with sub-dir structure fail to build.

    e.g: make -C sparc64/drivers/ or make -C drivers/dma-buf

    ../../lib.mk:20: ../../../../scripts/subarch.include: No such file or directory
    make: *** No rule to make target '../../../../scripts/subarch.include'. Stop.

    There is no reason to require all tests to define top_srcdir and there is
    no need to require tests to add khdr dependency using adhoc changes to
    TEST_* and other variables.

    Fix it with a consistent use of KSFT_KHDR_INSTALL and top_srcdir from tests
    that have the dependency on headers_install.

    Change common logic to include khdr target define and "all" target with
    dependency on khdr when KSFT_KHDR_INSTALL is defined.

    Only tests that have dependency on headers_install have to define just
    the KSFT_KHDR_INSTALL, and top_srcdir variables and there is no need to
    specify khdr dependency in the test Makefiles.

    Fixes: b2d35fa5fc80 ("selftests: add headers_install to lib.mk")
    Cc: stable@vger.kernel.org
    Signed-off-by: Shuah Khan
    Signed-off-by: Greg Kroah-Hartman

    Shuah Khan
     

13 Jan, 2019

2 commits

  • commit a95c90f1e2c253b280385ecf3d4ebfe476926b28 upstream.

    The last step before devm_memremap_pages() returns success is to allocate
    a release action, devm_memremap_pages_release(), to tear the entire setup
    down. However, the result from devm_add_action() is not checked.

    Checking the error from devm_add_action() is not enough. The api
    currently relies on the fact that the percpu_ref it is using is killed by
    the time the devm_memremap_pages_release() is run. Rather than continue
    this awkward situation, offload the responsibility of killing the
    percpu_ref to devm_memremap_pages_release() directly. This allows
    devm_memremap_pages() to do the right thing relative to init failures and
    shutdown.

    Without this change we could fail to register the teardown of
    devm_memremap_pages(). The likelihood of hitting this failure is tiny as
    small memory allocations almost always succeed. However, the impact of
    the failure is large given any future reconfiguration, or disable/enable,
    of an nvdimm namespace will fail forever as subsequent calls to
    devm_memremap_pages() will fail to setup the pgmap_radix since there will
    be stale entries for the physical address range.

    An argument could be made to require that the ->kill() operation be set in
    the @pgmap arg rather than passed in separately. However, it helps code
    readability, tracking the lifetime of a given instance, to be able to grep
    the kill routine directly at the devm_memremap_pages() call site.

    Link: http://lkml.kernel.org/r/154275558526.76910.7535251937849268605.stgit@dwillia2-desk3.amr.corp.intel.com
    Signed-off-by: Dan Williams
    Fixes: e8d513483300 ("memremap: change devm_memremap_pages interface...")
    Reviewed-by: "Jérôme Glisse"
    Reported-by: Logan Gunthorpe
    Reviewed-by: Logan Gunthorpe
    Reviewed-by: Christoph Hellwig
    Cc: Balbir Singh
    Cc: Michal Hocko
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    Dan Williams
     
  • commit 808153e1187fa77ac7d7dad261ff476888dcf398 upstream.

    devm_memremap_pages() is a facility that can create struct page entries
    for any arbitrary range and give drivers the ability to subvert core
    aspects of page management.

    Specifically the facility is tightly integrated with the kernel's memory
    hotplug functionality. It injects an altmap argument deep into the
    architecture specific vmemmap implementation to allow allocating from
    specific reserved pages, and it has Linux specific assumptions about page
    structure reference counting relative to get_user_pages() and
    get_user_pages_fast(). It was an oversight and a mistake that this was
    not marked EXPORT_SYMBOL_GPL from the outset.

    Again, devm_memremap_pagex() exposes and relies upon core kernel internal
    assumptions and will continue to evolve along with 'struct page', memory
    hotplug, and support for new memory types / topologies. Only an in-kernel
    GPL-only driver is expected to keep up with this ongoing evolution. This
    interface, and functionality derived from this interface, is not suitable
    for kernel-external drivers.

    Link: http://lkml.kernel.org/r/154275557457.76910.16923571232582744134.stgit@dwillia2-desk3.amr.corp.intel.com
    Signed-off-by: Dan Williams
    Reviewed-by: Christoph Hellwig
    Acked-by: Michal Hocko
    Cc: "Jérôme Glisse"
    Cc: Balbir Singh
    Cc: Logan Gunthorpe
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    Dan Williams
     

21 Dec, 2018

4 commits

  • [ Upstream commit e3f5df762d4a6ef6326c3c09bc9f89ea8a2eab2c ]

    In preparation for libnvdimm growing new restrictions to detect section
    conflicts between persistent memory regions, enable nfit_test to
    allocate aligned resources. Use a gen_pool to allocate nfit_test's fake
    resources in a separate address space from the virtual translation of
    the same.

    Reviewed-by: Vishal Verma
    Tested-by: Vishal Verma
    Signed-off-by: Dan Williams
    Signed-off-by: Sasha Levin

    Dan Williams
     
  • [ Upstream commit c01ac66b38660f2b507ccd0b75d28e3002d56fbb ]

    The message got changed a lot time ago.

    This was responsible for 36 test case failures on sparc64.

    Fixes: f1174f77b50c ("bpf/verifier: rework value tracking")
    Signed-off-by: David S. Miller
    Signed-off-by: Alexei Starovoitov
    Signed-off-by: Sasha Levin

    David Miller
     
  • [ Upstream commit d08489125e04a9f73d9323caea43270fd22d395f ]

    The following additional unit testcases are added to test_btf:
    ...
    BTF raw test[42] (typedef (invalid name, name_off = 0)): OK
    BTF raw test[43] (typedef (invalid name, invalid identifier)): OK
    BTF raw test[44] (ptr type (invalid name, name_off <> 0)): OK
    BTF raw test[45] (volatile type (invalid name, name_off <> 0)): OK
    BTF raw test[46] (const type (invalid name, name_off <> 0)): OK
    BTF raw test[47] (restrict type (invalid name, name_off <> 0)): OK
    BTF raw test[48] (fwd type (invalid name, name_off = 0)): OK
    BTF raw test[49] (fwd type (invalid name, invalid identifier)): OK
    BTF raw test[50] (array type (invalid name, name_off <> 0)): OK
    BTF raw test[51] (struct type (name_off = 0)): OK
    BTF raw test[52] (struct type (invalid name, invalid identifier)): OK
    BTF raw test[53] (struct member (name_off = 0)): OK
    BTF raw test[54] (struct member (invalid name, invalid identifier)): OK
    BTF raw test[55] (enum type (name_off = 0)): OK
    BTF raw test[56] (enum type (invalid name, invalid identifier)): OK
    BTF raw test[57] (enum member (invalid name, name_off = 0)): OK
    BTF raw test[58] (enum member (invalid name, invalid identifier)): OK
    ...

    Fixes: c0fa1b6c3efc ("bpf: btf: Add BTF tests")
    Acked-by: Martin KaFai Lau
    Signed-off-by: Yonghong Song
    Signed-off-by: Alexei Starovoitov
    Signed-off-by: Sasha Levin

    Yonghong Song
     
  • [ Upstream commit 8800cd031af085807028656c6ba7eb7908d78262 ]

    There are two unit test cases, which should encode
    TYPEDEF type, but instead encode PTR type.
    The error is flagged out after enforcing name
    checking in the previous patch.

    Fixes: c0fa1b6c3efc ("bpf: btf: Add BTF tests")
    Signed-off-by: Martin KaFai Lau
    Signed-off-by: Yonghong Song
    Signed-off-by: Alexei Starovoitov
    Signed-off-by: Sasha Levin

    Martin KaFai Lau
     

17 Dec, 2018

1 commit

  • commit afd594240806acc138cf696c09f2f4829d55d02f upstream.

    When patching in a new sequence for the first insn of a subprog, the start
    of that subprog does not change (it's the first insn of the sequence), so
    adjust_subprog_starts should check start < off).
    Also added a test to test_verifier.c (it's essentially the syz reproducer).

    Fixes: cc8b0b92a169 ("bpf: introduce function calls (function boundaries)")
    Reported-by: syzbot+4fc427c7af994b0948be@syzkaller.appspotmail.com
    Signed-off-by: Edward Cree
    Acked-by: Yonghong Song
    Signed-off-by: Alexei Starovoitov
    Signed-off-by: Greg Kroah-Hartman

    Edward Cree