05 Mar, 2020

2 commits

  • commit b9167c8078c3527de6da241c8a1a75a9224ed90a upstream.

    Commit 852c8cbf34d3 ("selftests/kselftest/runner.sh: Add 45 second
    timeout per test") added a 45 second timeout for tests, and also added
    a way for tests to customise the timeout via a settings file.

    For example the ftrace tests take multiple minutes to run, so they
    were given longer in commit b43e78f65b1d ("tracing/selftests: Turn off
    timeout setting").

    This works when the tests are run from the source tree. However if the
    tests are installed with "make -C tools/testing/selftests install",
    the settings files are not copied into the install directory. When the
    tests are then run from the install directory the longer timeouts are
    not applied and the tests timeout incorrectly.

    So add the settings files to TEST_FILES of the appropriate Makefiles
    to cause the settings files to be installed using the existing install
    logic.

    Fixes: 852c8cbf34d3 ("selftests/kselftest/runner.sh: Add 45 second timeout per test")
    Signed-off-by: Michael Ellerman
    Signed-off-by: Shuah Khan
    Signed-off-by: Greg Kroah-Hartman

    Michael Ellerman
     
  • [ Upstream commit e404b8c7cfb31654c9024d497cec58a501501692 ]

    After commit 27596472473a ("ipv6: fix ECMP route replacement") it is no
    longer possible to replace an ECMP-able route by a non ECMP-able route.
    For example,
    ip route add 2001:db8::1/128 via fe80::1 dev dummy0
    ip route replace 2001:db8::1/128 dev dummy0
    does not work as expected.

    Tweak the replacement logic so that point 3 in the log of the above commit
    becomes:
    3. If the new route is not ECMP-able, and no matching non-ECMP-able route
    exists, replace matching ECMP-able route (if any) or add the new route.

    We can now summarize the entire replace semantics to:
    When doing a replace, prefer replacing a matching route of the same
    "ECMP-able-ness" as the replace argument. If there is no such candidate,
    fallback to the first route found.

    Fixes: 27596472473a ("ipv6: fix ECMP route replacement")
    Signed-off-by: Benjamin Poirier
    Reviewed-by: Michal Kubecek
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Benjamin Poirier
     

29 Feb, 2020

1 commit

  • commit f2e97dc126b712c0d21219ed0c42710006c1cf52 upstream.

    Fix following build error. We could push a tcp.h header into one of the
    include paths, but I think its easy enough to simply pull in the three
    defines we need here. If we end up using more of tcp.h at some point
    we can pull it in later.

    /home/john/git/bpf/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c: In function ‘connected_socket_v4’:
    /home/john/git/bpf/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c:20:11: error: ‘TCP_REPAIR_ON’ undeclared (first use in this function)
    repair = TCP_REPAIR_ON;
    ^
    /home/john/git/bpf/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c:20:11: note: each undeclared identifier is reported only once for each function it appears in
    /home/john/git/bpf/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c:29:11: error: ‘TCP_REPAIR_OFF_NO_WP’ undeclared (first use in this function)
    repair = TCP_REPAIR_OFF_NO_WP;

    Then with fix,

    $ ./test_progs -n 44
    #44/1 sockmap create_update_free:OK
    #44/2 sockhash create_update_free:OK
    #44 sockmap_basic:OK

    Fixes: 5d3919a953c3c ("selftests/bpf: Test freeing sockmap/sockhash with a socket in it")
    Signed-off-by: John Fastabend
    Signed-off-by: Alexei Starovoitov
    Reviewed-by: Jakub Sitnicki
    Link: https://lore.kernel.org/bpf/158131347731.21414.12120493483848386652.stgit@john-Precision-5820-Tower
    Signed-off-by: Greg Kroah-Hartman

    John Fastabend
     

24 Feb, 2020

5 commits

  • [ Upstream commit 414f50434aa2463202a5b35e844f4125dd1a7101 ]

    Some newer cards supported by aacraid can take up to 40s to recover
    after an EEH event. This causes spurious failures in the basic EEH
    self-test since the current maximim timeout is only 30s.

    Fix the immediate issue by bumping the timeout to a default of 60s,
    and allow the wait time to be specified via an environmental variable
    (EEH_MAX_WAIT).

    Reported-by: Steve Best
    Suggested-by: Douglas Miller
    Signed-off-by: Oliver O'Halloran
    Signed-off-by: Michael Ellerman
    Link: https://lore.kernel.org/r/20200122031125.25991-1-oohall@gmail.com
    Signed-off-by: Sasha Levin

    Oliver O'Halloran
     
  • [ Upstream commit 51bad0f05616c43d6d34b0a19bcc9bdab8e8fb39 ]

    Currently, there is a lot of false positives if a single reuseport test
    fails. This is because expected_results and the result map are not cleared.

    Zero both after individual test runs, which fixes the mentioned false
    positives.

    Fixes: 91134d849a0e ("bpf: Test BPF_PROG_TYPE_SK_REUSEPORT")
    Signed-off-by: Lorenz Bauer
    Signed-off-by: Daniel Borkmann
    Reviewed-by: Jakub Sitnicki
    Acked-by: Martin KaFai Lau
    Acked-by: John Fastabend
    Link: https://lore.kernel.org/bpf/20200124112754.19664-5-lmb@cloudflare.com
    Signed-off-by: Sasha Levin

    Lorenz Bauer
     
  • [ Upstream commit ea6a547669b37453f2b1a5d85188d75b3613dfaa ]

    The SO_TXTIME test depends on accurate timers. In some virtualized
    environments the test has been reported to be flaky. This is easily
    reproduced by disabling kvm acceleration in Qemu.

    Allow greater variance in a run and retry to further reduce flakiness.

    Observed errors are one of two kinds: either the packet arrives too
    early or late at recv(), or it was dropped in the qdisc itself and the
    recv() call times out.

    In the latter case, the qdisc queues a notification to the error
    queue of the send socket. Also explicitly report this cause.

    Link: https://lore.kernel.org/netdev/CA+FuTSdYOnJCsGuj43xwV1jxvYsaoa_LzHQF9qMyhrkLrivxKw@mail.gmail.com
    Reported-by: Naresh Kamboju
    Signed-off-by: Willem de Bruijn
    Signed-off-by: Jakub Kicinski
    Signed-off-by: Sasha Levin

    Willem de Bruijn
     
  • [ Upstream commit ac87813d4372f4c005264acbe3b7f00c1dee37c4 ]

    Commit 852c8cbf34d3 ("selftests/kselftest/runner.sh: Add 45 second
    timeout per test") adds support for a new per-test-directory "settings"
    file. But this only works for tests not in a sub-subdirectories, e.g.

    - tools/testing/selftests/rtc (rtc) is OK,
    - tools/testing/selftests/net/mptcp (net/mptcp) is not.

    We have to increase the timeout for net/mptcp tests which are not
    upstreamed yet but this fix is valid for other tests if they need to add
    a "settings" file, see the full list with:

    tools/testing/selftests/*/*/**/Makefile

    Note that this patch changes the text header message printed at the end
    of the execution but this text is modified only for the tests that are
    in sub-subdirectories, e.g.

    ok 1 selftests: net/mptcp: mptcp_connect.sh

    Before we had:

    ok 1 selftests: mptcp: mptcp_connect.sh

    But showing the full target name is probably better, just in case a
    subsubdir has the same name as another one in another subdirectory.

    Fixes: 852c8cbf34d3 (selftests/kselftest/runner.sh: Add 45 second timeout per test)
    Signed-off-by: Matthieu Baerts
    Reviewed-by: Kees Cook
    Signed-off-by: Shuah Khan
    Signed-off-by: Sasha Levin

    Matthieu Baerts
     
  • [ Upstream commit 6b64a650f0b2ae3940698f401732988699eecf7a ]

    It was observed[1] on arm64 that __builtin_strlen led to an infinite
    loop in the get_size selftest. This is because __builtin_strlen (and
    other builtins) may sometimes result in a call to the C library
    function. The C library implementation of strlen uses an IFUNC
    resolver to load the most efficient strlen implementation for the
    underlying machine and hence has a PLT indirection even for static
    binaries. Because this binary avoids the C library startup routines,
    the PLT initialization never happens and hence the program gets stuck
    in an infinite loop.

    On x86_64 the __builtin_strlen just happens to expand inline and avoid
    the call but that is not always guaranteed.

    Further, while testing on x86_64 (Fedora 31), it was observed that the
    test also failed with a segfault inside write() because the generated
    code for the write function in glibc seems to access TLS before the
    syscall (probably due to the cancellation point check) and fails
    because TLS is not initialised.

    To mitigate these problems, this patch reduces the interface with the
    C library to just the syscall function. The syscall function still
    sets errno on failure, which is undesirable but for now it only
    affects cases where syscalls fail.

    [1] https://bugs.linaro.org/show_bug.cgi?id=5479

    Signed-off-by: Siddhesh Poyarekar
    Reported-by: Masami Hiramatsu
    Tested-by: Masami Hiramatsu
    Reviewed-by: Tim Bird
    Signed-off-by: Shuah Khan
    Signed-off-by: Sasha Levin

    Siddhesh Poyarekar
     

15 Feb, 2020

1 commit

  • commit 5d3919a953c3c96c02fc7a337f8376cde43ae31f upstream.

    Commit 7e81a3530206 ("bpf: Sockmap, ensure sock lock held during tear
    down") introduced sleeping issues inside RCU critical sections and while
    holding a spinlock on sockmap/sockhash tear-down. There has to be at least
    one socket in the map for the problem to surface.

    This adds a test that triggers the warnings for broken locking rules. Not a
    fix per se, but rather tooling to verify the accompanying fixes. Run on a
    VM with 1 vCPU to reproduce the warnings.

    Fixes: 7e81a3530206 ("bpf: Sockmap, ensure sock lock held during tear down")
    Signed-off-by: Jakub Sitnicki
    Signed-off-by: Daniel Borkmann
    Acked-by: John Fastabend
    Link: https://lore.kernel.org/bpf/20200206111652.694507-4-jakub@cloudflare.com
    Signed-off-by: Greg Kroah-Hartman

    Jakub Sitnicki
     

11 Feb, 2020

6 commits

  • commit 8bec4f665e0baecb5f1b683379fc10b3745eb612 upstream.

    The reuseport tests currently suffer from a race condition: FIN
    packets count towards DROP_ERR_SKB_DATA, since they don't contain
    a valid struct cmd. Tests will spuriously fail depending on whether
    check_results is called before or after the FIN is processed.

    Exit the BPF program early if FIN is set.

    Fixes: 91134d849a0e ("bpf: Test BPF_PROG_TYPE_SK_REUSEPORT")
    Signed-off-by: Lorenz Bauer
    Signed-off-by: Daniel Borkmann
    Reviewed-by: Jakub Sitnicki
    Acked-by: Martin KaFai Lau
    Acked-by: John Fastabend
    Link: https://lore.kernel.org/bpf/20200124112754.19664-3-lmb@cloudflare.com
    Signed-off-by: Greg Kroah-Hartman

    Lorenz Bauer
     
  • commit c31dbb1e41d1857b403f9bf58c87f5898519a0bc upstream.

    Use a proper temporary file for sendpage tests. This means that running
    the tests doesn't clutter the working directory, and allows running the
    test on read-only filesystems.

    Fixes: 16962b2404ac ("bpf: sockmap, add selftests")
    Signed-off-by: Lorenz Bauer
    Signed-off-by: Daniel Borkmann
    Reviewed-by: Jakub Sitnicki
    Acked-by: Martin KaFai Lau
    Acked-by: John Fastabend
    Link: https://lore.kernel.org/bpf/20200124112754.19664-2-lmb@cloudflare.com
    Signed-off-by: Greg Kroah-Hartman

    Lorenz Bauer
     
  • commit f1c3656c6d9c147d07d16614455aceb34932bdeb upstream.

    The same with commit 4e59afbbed96 ("selftests/bpf: skip nmi test when perf
    hw events are disabled"), it would make more sense to skip the
    test_stacktrace_build_id_nmi test if the setup (e.g. virtual machines) has
    disabled hardware perf events.

    Fixes: 13790d1cc72c ("bpf: add selftest for stackmap with build_id in NMI context")
    Signed-off-by: Hangbin Liu
    Signed-off-by: Daniel Borkmann
    Acked-by: John Fastabend
    Link: https://lore.kernel.org/bpf/20200117100656.10359-1-liuhangbin@gmail.com
    Signed-off-by: Greg Kroah-Hartman

    Hangbin Liu
     
  • commit 580205dd4fe800b1e95be8b6df9e2991f975a8ad upstream.

    Fix two issues in test_attach_probe:

    1. it was not able to parse /proc/self/maps beyond the first line,
    since %s means parse string until white space.
    2. offset has to be accounted for otherwise uprobed address is incorrect.

    Fixes: 1e8611bbdfc9 ("selftests/bpf: add kprobe/uprobe selftests")
    Signed-off-by: Alexei Starovoitov
    Signed-off-by: Daniel Borkmann
    Acked-by: Yonghong Song
    Acked-by: Andrii Nakryiko
    Link: https://lore.kernel.org/bpf/20191219020442.1922617-1-ast@kernel.org
    Signed-off-by: Greg Kroah-Hartman

    Alexei Starovoitov
     
  • commit 7145fcfffef1fad4266aaf5ca96727696916edb7 upstream.

    when the following command is done on a fresh clone of the kernel tree,

    [root@f31 tc-testing]# ./tdc.py -c bpf

    test cases that need to build the eBPF sample program fail systematically,
    because 'buildebpfPlugin' is unable to install the kernel headers (i.e, the
    'khdr' target fails). Pass the correct environment to 'make', in place of
    ENVIR, to allow running these tests.

    Fixes: 4c2d39bd40c1 ("tc-testing: use a plugin to build eBPF program")
    Signed-off-by: Davide Caratti
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Davide Caratti
     
  • commit 91cbdf740a476cf2c744169bf407de2e3ac1f3cf upstream.

    Fix up perf_buffer.c selftest to take into account offline/missing CPUs.

    Fixes: ee5cf82ce04a ("selftests/bpf: test perf buffer API")
    Signed-off-by: Andrii Nakryiko
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20191212013621.1691858-1-andriin@fb.com
    Signed-off-by: Greg Kroah-Hartman

    Andrii Nakryiko
     

01 Feb, 2020

1 commit

  • [ Upstream commit a53ba15d81995868651dd28a85d8045aef3d4e20 ]

    Due to a quirky C syntax of declaring pointers to array or function
    prototype, existing __type() macro doesn't work with map key/value types
    that are array or function prototype. One has to create a typedef first
    and use it to specify key/value type for a BPF map. By using typeof(),
    pointer to type is now handled uniformly for all kinds of types. Convert
    one of self-tests as a demonstration.

    Signed-off-by: Andrii Nakryiko
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20191004040211.2434033-1-andriin@fb.com
    Signed-off-by: Sasha Levin

    Andrii Nakryiko
     

26 Jan, 2020

2 commits

  • [ Upstream commit d671fa6393d6788fc65555d4643b71cb3a361f36 ]

    It is necessary to set fd to -1 when inotify_add_watch() fails in
    cg_prepare_for_wait. Otherwise the fd which has been closed in
    cg_prepare_for_wait may be misused in other functions such as
    cg_enter_and_wait_for_frozen and cg_freeze_wait.

    Fixes: 5313bfe425c8 ("selftests: cgroup: add freezer controller self-tests")
    Signed-off-by: Hewenliang
    Signed-off-by: Tejun Heo
    Signed-off-by: Sasha Levin

    Hewenliang
     
  • [ Upstream commit ea1bf0bb18c0bd627d7b551196453ff2fff44225 ]

    The default installation location for gen_kselftest_tar.sh was still
    "kselftest/" which collides with the existing directory. Instead, this
    moves the installation target into "kselftest_install/kselftest/" and
    adjusts the tar creation accordingly. This also adjusts indentation and
    logic to be consistent.

    Fixes: 42d46e57ec97 ("selftests: Extract single-test shell logic from lib.mk")
    Signed-off-by: Kees Cook
    Signed-off-by: Shuah Khan
    Signed-off-by: Sasha Levin

    Kees Cook
     

23 Jan, 2020

1 commit

  • commit fef6d6704944c7be72fd2b77c021f1aed3d5df0d upstream.

    Mausezahn does not recognize "own" as a keyword on source IP address. As a
    result, the MC stream is not running at all, and therefore no UC
    degradation can be observed even in principle.

    Fix the invocation, and tighten the test: due to the minimum shaper
    configured at the MC TCs, we always expect about 20% degradation. Fail the
    test if it is lower.

    Fixes: 573363a68f27 ("selftests: mlxsw: Add qos_lib.sh")
    Signed-off-by: Petr Machata
    Reported-by: Amit Cohen
    Signed-off-by: Ido Schimmel
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Petr Machata
     

18 Jan, 2020

3 commits

  • [ Upstream commit af9cb29c5488381083b0b5ccdfb3cd931063384a ]

    As the rseq selftests can run for a long period of time, disable the
    timeout that the general selftests have.

    Signed-off-by: Mathieu Desnoyers
    Cc: Shuah Khan
    Cc: Thomas Gleixner
    Cc: Peter Zijlstra (Intel)
    Cc: "Paul E. McKenney"
    Cc: Boqun Feng
    Cc: "H . Peter Anvin"
    Cc: Paul Turner
    Cc: Dmitry Vyukov
    Signed-off-by: Shuah Khan
    Signed-off-by: Sasha Levin

    Mathieu Desnoyers
     
  • [ Upstream commit c65e41538b04e0d64a673828745a00cb68a24371 ]

    firmware attempts to load test modules that require root access
    and fail. Fix it to check for root uid and exit with skip code
    instead.

    Before this fix:

    selftests: firmware: fw_run_tests.sh
    modprobe: ERROR: could not insert 'test_firmware': Operation not permitted
    You must have the following enabled in your kernel:
    CONFIG_TEST_FIRMWARE=y
    CONFIG_FW_LOADER=y
    CONFIG_FW_LOADER_USER_HELPER=y
    CONFIG_IKCONFIG=y
    CONFIG_IKCONFIG_PROC=y
    not ok 1 selftests: firmware: fw_run_tests.sh # SKIP

    With this fix:

    selftests: firmware: fw_run_tests.sh
    skip all tests: must be run as root
    not ok 1 selftests: firmware: fw_run_tests.sh # SKIP

    Signed-off-by: Shuah Khan
    Reviwed-by: Greg Kroah-Hartman
    Signed-off-by: Shuah Khan
    Signed-off-by: Sasha Levin

    Shuah Khan
     
  • commit cc7e3f63d7299dd1119be39aa187b867d6f8aa17 upstream.

    The loopback feature is only supported on a few drivers like broadcom,
    mellanox, etc. The default veth driver has not supported it yet. To avoid
    returning failed and making the runner feel confused, let's just skip
    the test on drivers that not support loopback.

    Fixes: ad11340994d5 ("selftests: Add loopback test")
    Signed-off-by: Hangbin Liu
    Reviewed-by: Simon Horman
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Hangbin Liu
     

12 Jan, 2020

11 commits

  • [ Upstream commit 152044775d0b9a9ed9509caed40efcba2677951d ]

    There is no a_r3, a_r4 in the testing topology.
    It should be b_r1, b_r2. Also b_r1 mtu is 1400 and b_r2 mtu is 1500.

    Fixes: e44e428f59e4 ("selftests: pmtu: add basic IPv4 and IPv6 PMTU tests")
    Signed-off-by: Hangbin Liu
    Acked-by: Stefano Brivio
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Hangbin Liu
     
  • [ Upstream commit 4eac734486fd431e0756cc5e929f140911a36a53 ]

    On an old perl such as v5.10.1, `kselftest/prefix.pl` gives below error
    message:

    Can't locate object method "autoflush" via package "IO::Handle" at kselftest/prefix.pl line 10.

    This commit fixes the error by explicitly specifying the use of the
    `IO::Handle` package.

    Signed-off-by: SeongJae Park
    Acked-by: Kees Cook
    Signed-off-by: Shuah Khan
    Signed-off-by: Sasha Levin

    SeongJae Park
     
  • [ Upstream commit d187801d1a46519d2a322f879f7c8f85c685372e ]

    If a timeout failure occurs, kselftest kills the test process and prints
    the timeout log. If the test process has killed while printing a log
    that ends with new line, the timeout log can be printed in middle of the
    test process output so that it can be seems like a comment, as below:

    # test_process_log not ok 3 selftests: timers: nsleep-lat # TIMEOUT

    This commit avoids such problem by printing one more line before the
    TIMEOUT failure log.

    Signed-off-by: SeongJae Park
    Acked-by: Kees Cook
    Signed-off-by: Shuah Khan
    Signed-off-by: Sasha Levin

    SeongJae Park
     
  • [ Upstream commit 8ef1ec0ca32c6f8a87f5b4c24b1db26da67c5609 ]

    Fix Makefile to set safesetid-test.sh to TEST_PROGS instead
    of non existing run_tests.sh.

    Without this fix, I got following error.
    ----
    TAP version 13
    1..1
    # selftests: safesetid: run_tests.sh
    # Warning: file run_tests.sh is missing!
    not ok 1 selftests: safesetid: run_tests.sh
    ----

    Fixes: c67e8ec03f3f ("LSM: SafeSetID: add selftest")
    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Shuah Khan
    Signed-off-by: Sasha Levin

    Masami Hiramatsu
     
  • [ Upstream commit 295c4e21cf27ac9af542140e3e797df9e0cf7b5f ]

    Check the return value of setuid() and setgid().
    This fixes the following warnings and improves test result.

    safesetid-test.c: In function ‘main’:
    safesetid-test.c:294:2: warning: ignoring return value of ‘setuid’, declared with attribute warn_unused_result [-Wunused-result]
    setuid(NO_POLICY_USER);
    ^~~~~~~~~~~~~~~~~~~~~~
    safesetid-test.c:295:2: warning: ignoring return value of ‘setgid’, declared with attribute warn_unused_result [-Wunused-result]
    setgid(NO_POLICY_USER);
    ^~~~~~~~~~~~~~~~~~~~~~
    safesetid-test.c:309:2: warning: ignoring return value of ‘setuid’, declared with attribute warn_unused_result [-Wunused-result]
    setuid(RESTRICTED_PARENT);
    ^~~~~~~~~~~~~~~~~~~~~~~~~
    safesetid-test.c:310:2: warning: ignoring return value of ‘setgid’, declared with attribute warn_unused_result [-Wunused-result]
    setgid(RESTRICTED_PARENT);
    ^~~~~~~~~~~~~~~~~~~~~~~~~
    safesetid-test.c: In function ‘test_setuid’:
    safesetid-test.c:216:3: warning: ignoring return value of ‘setuid’, declared with attribute warn_unused_result [-Wunused-result]
    setuid(child_uid);
    ^~~~~~~~~~~~~~~~~

    Fixes: c67e8ec03f3f ("LSM: SafeSetID: add selftest")
    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Shuah Khan
    Signed-off-by: Sasha Levin

    Masami Hiramatsu
     
  • [ Upstream commit be12252212fa3dfed6e75112865095c484c0ce87 ]

    Move -lcap to LDLIBS from CFLAGS because it is a library
    to be linked.

    Without this, safesetid failed to build with link error
    as below.

    ----
    /usr/bin/ld: /tmp/ccL8rZHT.o: in function `drop_caps':
    safesetid-test.c:(.text+0xe7): undefined reference to `cap_get_proc'
    /usr/bin/ld: safesetid-test.c:(.text+0x107): undefined reference to `cap_set_flag'
    /usr/bin/ld: safesetid-test.c:(.text+0x10f): undefined reference to `cap_set_proc'
    /usr/bin/ld: safesetid-test.c:(.text+0x117): undefined reference to `cap_free'
    /usr/bin/ld: safesetid-test.c:(.text+0x136): undefined reference to `cap_clear'
    collect2: error: ld returned 1 exit status
    ----

    Fixes: c67e8ec03f3f ("LSM: SafeSetID: add selftest")
    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Shuah Khan
    Signed-off-by: Sasha Levin

    Masami Hiramatsu
     
  • [ Upstream commit 5cc6c8d4a99d0ee4d5466498e258e593df1d3eb6 ]

    Fix multiple kprobe event testcase to work it correctly.
    There are 2 bugfixes.
    - Since `wc -l FILE` returns not only line number but also
    FILE filename, following "if" statement always failed.
    Fix this bug by replacing it with 'cat FILE | wc -l'
    - Since "while do-done loop" block with pipeline becomes a
    subshell, $N local variable is not update outside of
    the loop.
    Fix this bug by using actual target number (256) instead
    of $N.

    Signed-off-by: Masami Hiramatsu
    Reviewed-by: Steven Rostedt (VMware)
    Signed-off-by: Shuah Khan
    Signed-off-by: Sasha Levin

    Masami Hiramatsu
     
  • [ Upstream commit ba1b9c5048e43716921abe3a1db19cebebf4a5f5 ]

    Use relative path to trigger file instead of absolute debugfs path,
    because if the user uses tracefs instead of debugfs, it can be
    mounted at /sys/kernel/tracing.
    Anyway, since the ftracetest is designed to be run at the tracing
    directory, user doesn't need to use absolute path.

    Signed-off-by: Masami Hiramatsu
    Reviewed-by: Steven Rostedt (VMware)
    Signed-off-by: Shuah Khan
    Signed-off-by: Sasha Levin

    Masami Hiramatsu
     
  • [ Upstream commit 25deae098e748d8d36bc35129a66734b8f6925c9 ]

    Since dynamic function tracer can be disabled, set_ftrace_filter
    can be disappeared. Test cases which depends on it, must check
    whether the set_ftrace_filter exists or not before testing
    and if not, return as unsupported.

    Also, if the function tracer itself is disabled, we can not
    set "function" to current_tracer. Test cases must check it
    before testing, and return as unsupported.

    Signed-off-by: Masami Hiramatsu
    Reviewed-by: Steven Rostedt (VMware)
    Signed-off-by: Shuah Khan
    Signed-off-by: Sasha Levin

    Masami Hiramatsu
     
  • [ Upstream commit fd1baf6ca2ea3550ea47f2bb0bdcf34ec764a779 ]

    If we run ftracetest on the kernel with CONFIG_DYNAMIC_FTRACE=n,
    there is no set_ftrace_filter and all test cases are failed, because
    reset_ftrace_filter() returns an error.
    Let's check whether set_ftrace_filter exists in reset_ftrace_filter()
    and clean up only set_ftrace_notrace in initialize_ftrace().

    Signed-off-by: Masami Hiramatsu
    Reviewed-by: Steven Rostedt (VMware)
    Signed-off-by: Shuah Khan
    Signed-off-by: Sasha Levin

    Masami Hiramatsu
     
  • [ Upstream commit 5a2e6af81807d4616f9839ad0ae7d1313b45c64d ]

    Using ns0, ns1, etc. isn't a good idea, they might exist already.
    Use a random suffix.

    Also, older nft versions don't support "-" as alias for stdin, so
    use /dev/stdin instead.

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

    Florian Westphal
     

09 Jan, 2020

3 commits

  • commit 8df34c56321479bfa1ec732c675b686c2b4df412 upstream.

    glibc 2.30 introduces gettid() in public headers, which clashes with
    the internal static definition within rseq selftests.

    Rename gettid() to rseq_gettid() to eliminate this symbol name clash.

    Reported-by: Tommi T. Rantala
    Signed-off-by: Mathieu Desnoyers
    Cc: Shuah Khan
    Cc: Tommi T. Rantala
    Cc: Thomas Gleixner
    Cc: Peter Zijlstra (Intel)
    Cc: "Paul E. McKenney"
    Cc: Boqun Feng
    Cc: "H . Peter Anvin"
    Cc: Paul Turner
    Cc: Dmitry Vyukov
    Cc: # v4.18+
    Signed-off-by: Shuah Khan
    Signed-off-by: Greg Kroah-Hartman

    Mathieu Desnoyers
     
  • commit e4ab5ccc357b978999328fadae164e098c26fa40 upstream.

    This adds logic to the user_notification_basic test to set a member
    of struct seccomp_notif to an invalid value to ensure that the kernel
    returns EINVAL if any of the struct seccomp_notif members are set to
    invalid values.

    Signed-off-by: Sargun Dhillon
    Suggested-by: Christian Brauner
    Link: https://lore.kernel.org/r/20191230203811.4996-1-sargun@sargun.me
    Fixes: 6a21cc50f0c7 ("seccomp: add a return code to trap to userspace")
    Cc: stable@vger.kernel.org
    Signed-off-by: Kees Cook
    Signed-off-by: Greg Kroah-Hartman

    Sargun Dhillon
     
  • commit 88c13f8bd71472fbab5338b01d99122908c77e53 upstream.

    The seccomp_notif structure should be zeroed out prior to calling the
    SECCOMP_IOCTL_NOTIF_RECV ioctl. Previously, the kernel did not check
    whether these structures were zeroed out or not, so these worked.

    This patch zeroes out the seccomp_notif data structure prior to calling
    the ioctl.

    Signed-off-by: Sargun Dhillon
    Reviewed-by: Tycho Andersen
    Reviewed-by: Christian Brauner
    Link: https://lore.kernel.org/r/20191229062451.9467-1-sargun@sargun.me
    Fixes: 6a21cc50f0c7 ("seccomp: add a return code to trap to userspace")
    Cc: stable@vger.kernel.org
    Signed-off-by: Kees Cook
    Signed-off-by: Greg Kroah-Hartman

    Sargun Dhillon
     

05 Jan, 2020

3 commits

  • [ Upstream commit 746dd4012d215b53152f0001a48856e41ea31730 ]

    When running test_vmalloc.sh smoke the following print out states that
    the fragment is missing.

    # ./test_vmalloc.sh: You must have the following enabled in your kernel:
    # CONFIG_TEST_VMALLOC=m

    Rework to add the fragment 'CONFIG_TEST_VMALLOC=m' to the config file.

    Link: http://lkml.kernel.org/r/20190916095217.19665-1-anders.roxell@linaro.org
    Fixes: a05ef00c9790 ("selftests/vm: add script helper for CONFIG_TEST_VMALLOC_MODULE")
    Signed-off-by: Anders Roxell
    Cc: Shuah Khan
    Cc: "Uladzislau Rezki (Sony)"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Sasha Levin

    Anders Roxell
     
  • [ Upstream commit 505127068d9b705a6cf335143239db91bfe7bbe2 ]

    On systems where TM (Transactional Memory) is disabled the
    tm-signal-sigreturn-nt test causes a SIGILL:

    test: tm_signal_sigreturn_nt
    tags: git_version:7c202575ef63
    !! child died by signal 4
    failure: tm_signal_sigreturn_nt

    We should skip the test if TM is not available.

    Fixes: 34642d70ac7e ("selftests/powerpc: Add checks for transactional sigreturn")
    Signed-off-by: Michael Ellerman
    Link: https://lore.kernel.org/r/20191104233524.24348-1-mpe@ellerman.id.au
    Signed-off-by: Sasha Levin

    Michael Ellerman
     
  • [ Upstream commit a02cbc7ffe529ed58b6bbe54652104fc2c88bd77 ]

    Some of our TM (Transactional Memory) tests, list "r1" (the stack
    pointer) as a clobbered register.

    GCC >= 9 doesn't accept this, and the build breaks:

    ptrace-tm-spd-tar.c: In function 'tm_spd_tar':
    ptrace-tm-spd-tar.c:31:2: error: listing the stack pointer register 'r1' in a clobber list is deprecated [-Werror=deprecated]
    31 | asm __volatile__(
    | ^~~
    ptrace-tm-spd-tar.c:31:2: note: the value of the stack pointer after an 'asm' statement must be the same as it was before the statement

    We do have some fairly large inline asm blocks in these tests, and
    some of them do change the value of r1. However they should all return
    to C with the value in r1 restored, so I think it's legitimate to say
    r1 is not clobbered.

    As Segher points out, the r1 clobbers may have been added because of
    the use of `or 1,1,1`, however that doesn't actually clobber r1.

    Segher also points out that some of these tests do clobber LR, because
    they call functions, and that is not listed in the clobbers, so add
    that where appropriate.

    Signed-off-by: Michael Ellerman
    Link: https://lore.kernel.org/r/20191029095324.14669-1-mpe@ellerman.id.au
    Signed-off-by: Sasha Levin

    Michael Ellerman
     

31 Dec, 2019

1 commit

  • [ Upstream commit 6dd504b0fd1039c6e5d391e97cf5c4ee592aefcb ]

    This test only works when [1] is applied, which was rejected.

    Basically, the errors are reported and cleared. In this particular case of
    tls sockets, following reads will block.

    The test case was originally submitted with the rejected patch, but, then,
    was included as part of a different patchset, possibly by mistake.

    [1] https://lore.kernel.org/netdev/20191007035323.4360-2-jakub.kicinski@netronome.com/#t

    Thanks Paolo Pisati for pointing out the original patchset where this
    appeared.

    Fixes: 65190f77424d (selftests/tls: add a test for fragmented messages)
    Reported-by: Paolo Pisati
    Signed-off-by: Thadeu Lima de Souza Cascardo
    Signed-off-by: Jakub Kicinski
    Signed-off-by: Sasha Levin

    Thadeu Lima de Souza Cascardo