This patchset contains everything needed to integrate KASAN and KUnit.
KUnit will be able to:
(1) Fail tests when an unexpected KASAN error occurs
(2) Pass tests when an expected KASAN error occurs
Convert KASAN tests to KUnit with the exception of copy_user_test
because KUnit is unable to test those.
Add documentation on how to run the KASAN tests with KUnit and what to
expect when running these tests.
This patchset depends on:
- "kunit: extend kunit resources API" [1]
- "Fix some incompatibilites between KASAN and FORTIFY_SOURCE" [2]
- This is already upstream for 5.8[3,4]
Changes from v7:
- Rebased on top of kselftest/kunit
- Rebased on top of v4 of the kunit resources API[1]
- Rebased on top of v4 of the FORTIFY_SOURCE fix[2,3,4]
- Updated the Kconfig entry to support KUNIT_ALL_TESTS
Changes from v6:
- Rebased on top of kselftest/kunit
- Rebased on top of Daniel Axtens' fix for FORTIFY_SOURCE
incompatibilites [2]
- Removed a redundant report_enabled() check.
- Fixed some places with out of date Kconfig names in the
documentation.
Changes from v5:
- Split out the panic_on_warn changes to a separate patch.
- Fix documentation to fewer to the new Kconfig names.
- Fix some changes which were in the wrong patch.
- Rebase on top of kselftest/kunit (currently identical to 5.7-rc1)
Changes from v4:
- KASAN no longer will panic on errors if both panic_on_warn and
kasan_multishot are enabled.
- As a result, the KASAN tests will no-longer disable panic_on_warn.
- This also means panic_on_warn no-longer needs to be exported.
- The use of temporary "kasan_data" variables has been cleaned up
somewhat.
- A potential refcount/resource leak should multiple KASAN errors
appear during an assertion was fixed.
- Some wording changes to the KASAN test Kconfig entries.
Changes from v3:
- KUNIT_SET_KASAN_DATA and KUNIT_DO_EXPECT_KASAN_FAIL have been
combined and included in KUNIT_DO_EXPECT_KASAN_FAIL() instead.
- Reordered logic in kasan_update_kunit_status() in report.c to be
easier to read.
- Added comment to not use the name "kasan_data" for any kunit tests
outside of KUNIT_EXPECT_KASAN_FAIL().
Changes since v2:
- Due to Alan's changes in [1], KUnit can be built as a module.
- The name of the tests that could not be run with KUnit has been
changed to be more generic: test_kasan_module.
- Documentation on how to run the new KASAN tests and what to expect
when running them has been added.
- Some variables and functions are now static.
- Now save/restore panic_on_warn in a similar way to kasan_multi_shot
and renamed the init/exit functions to be more generic to accommodate.
- Due to [4] in kasan_strings, kasan_memchr, and
kasan_memcmp will fail if CONFIG_AMD_MEM_ENCRYPT is enabled so return
early and print message explaining this circumstance.
- Changed preprocessor checks to C checks where applicable.
Changes since v1:
- Make use of Alan Maguire's suggestion to use his patch that allows
static resources for integration instead of adding a new attribute to
the kunit struct
- All KUNIT_EXPECT_KASAN_FAIL statements are local to each test
- The definition of KUNIT_EXPECT_KASAN_FAIL is local to the
test_kasan.c file since it seems this is the only place this will
be used.
- Integration relies on KUnit being builtin
- copy_user_test has been separated into its own file since KUnit
is unable to test these. This can be run as a module just as before,
using CONFIG_TEST_KASAN_USER
- The addition to the current task has been separated into its own
patch as this is a significant enough change to be on its own.
[1] https://lore.kernel.org/linux-kselftest/CAFd5g46Uu_5TG89uOm0Dj5CMq+11cwjBns…
[2] https://lore.kernel.org/linux-mm/20200424145521.8203-1-dja@axtens.net/
[3] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?…
[4] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?…
[5] https://bugzilla.kernel.org/show_bug.cgi?id=206337
David Gow (1):
mm: kasan: Do not panic if both panic_on_warn and kasan_multishot set
Patricia Alfonso (4):
Add KUnit Struct to Current Task
KUnit: KASAN Integration
KASAN: Port KASAN Tests to KUnit
KASAN: Testing Documentation
Documentation/dev-tools/kasan.rst | 70 +++
include/kunit/test.h | 5 +
include/linux/kasan.h | 6 +
include/linux/sched.h | 4 +
lib/Kconfig.kasan | 19 +-
lib/Makefile | 3 +-
lib/kunit/test.c | 13 +-
lib/test_kasan.c | 688 +++++++++++++-----------------
lib/test_kasan_module.c | 76 ++++
mm/kasan/report.c | 34 +-
10 files changed, 515 insertions(+), 403 deletions(-)
create mode 100644 lib/test_kasan_module.c
--
2.27.0.278.ge193c7cf3a9-goog
When using BPF_PROG_ATTACH to attach a program to a cgroup in
BPF_F_ALLOW_MULTI mode, it is not possible to replace a program
with itself. This is because the check for duplicate programs
doesn't take the replacement program into account.
Replacing a program with itself might seem weird, but it has
some uses: first, it allows resetting the associated cgroup storage.
Second, it makes the API consistent with the non-ALLOW_MULTI usage,
where it is possible to replace a program with itself. Third, it
aligns BPF_PROG_ATTACH with bpf_link, where replacing itself is
also supported.
Sice this code has been refactored a few times this change will
only apply to v5.7 and later. Adjustments could be made to
commit 1020c1f24a94 ("bpf: Simplify __cgroup_bpf_attach") and
commit d7bf2c10af05 ("bpf: allocate cgroup storage entries on attaching bpf programs")
as well as commit 324bda9e6c5a ("bpf: multi program support for cgroup+bpf")
Signed-off-by: Lorenz Bauer <lmb(a)cloudflare.com>
Fixes: af6eea57437a ("bpf: Implement bpf_link-based cgroup BPF program attachment")
---
kernel/bpf/cgroup.c | 2 +-
.../testing/selftests/bpf/prog_tests/cgroup_attach_multi.c | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c
index fdf7836750a3..4d76f16524cc 100644
--- a/kernel/bpf/cgroup.c
+++ b/kernel/bpf/cgroup.c
@@ -378,7 +378,7 @@ static struct bpf_prog_list *find_attach_entry(struct list_head *progs,
}
list_for_each_entry(pl, progs, node) {
- if (prog && pl->prog == prog)
+ if (prog && pl->prog == prog && prog != replace_prog)
/* disallow attaching the same prog twice */
return ERR_PTR(-EINVAL);
if (link && pl->link == link)
diff --git a/tools/testing/selftests/bpf/prog_tests/cgroup_attach_multi.c b/tools/testing/selftests/bpf/prog_tests/cgroup_attach_multi.c
index 139f8e82c7c6..b549fcfacc0b 100644
--- a/tools/testing/selftests/bpf/prog_tests/cgroup_attach_multi.c
+++ b/tools/testing/selftests/bpf/prog_tests/cgroup_attach_multi.c
@@ -230,6 +230,13 @@ void test_cgroup_attach_multi(void)
"prog_replace", "errno=%d\n", errno))
goto err;
+ /* replace program with itself */
+ attach_opts.replace_prog_fd = allow_prog[6];
+ if (CHECK(bpf_prog_attach_xattr(allow_prog[6], cg1,
+ BPF_CGROUP_INET_EGRESS, &attach_opts),
+ "prog_replace", "errno=%d\n", errno))
+ goto err;
+
value = 0;
CHECK_FAIL(bpf_map_update_elem(map_fd, &key, &value, 0));
CHECK_FAIL(system(PING_CMD));
--
2.25.1
Hi Linus,
Please pull the Kunit update for Linux 5.8-rc1.
This Kunit update for Linux 5.8-rc1 consists of:
- Several config fragment fixes from Anders Roxell to improve
test coverage.
- Improvements to kunit run script to use defconfig as default and
restructure the code for config/build/exec/parse from Vitor Massaru Iha
and David Gow.
- Miscellaneous documentation warn fix.
diff is attached.
thanks,
-- Shuah
----------------------------------------------------------------
The following changes since commit 2ef96a5bb12be62ef75b5828c0aab838ebb29cb8:
Linux 5.7-rc5 (2020-05-10 15:16:58 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
tags/linux-kselftest-kunit-5.8-rc1
for you to fetch changes up to 6d6861d45e38d42a7df9db244c871ee3856acf57:
security: apparmor: default KUNIT_* fragments to KUNIT_ALL_TESTS
(2020-06-01 14:25:15 -0600)
----------------------------------------------------------------
linux-kselftest-kunit-5.8-rc1
This Kunit update for Linux 5.8-rc1 consists of:
- Several config fragment fixes from Anders Roxell to improve
test coverage.
- Improvements to kunit run script to use defconfig as default and
restructure the code for config/build/exec/parse from Vitor Massaru Iha
and David Gow.
- Miscellaneous documentation warn fix.
----------------------------------------------------------------
Anders Roxell (6):
kunit: Kconfig: enable a KUNIT_ALL_TESTS fragment
kunit: default KUNIT_* fragments to KUNIT_ALL_TESTS
lib: Kconfig.debug: default KUNIT_* fragments to KUNIT_ALL_TESTS
drivers: base: default KUNIT_* fragments to KUNIT_ALL_TESTS
fs: ext4: default KUNIT_* fragments to KUNIT_ALL_TESTS
security: apparmor: default KUNIT_* fragments to KUNIT_ALL_TESTS
David Gow (1):
kunit: kunit_tool: Separate out config/build/exec/parse
Lothar Rubusch (1):
Documentation: test.h - fix warnings
Vitor Massaru Iha (3):
kunit: use --build_dir=.kunit as default
kunit: use KUnit defconfig by default
kunit: Fix TabError, remove defconfig code and handle when there
is no kunitconfig
Documentation/dev-tools/kunit/start.rst | 13 +-
Documentation/dev-tools/kunit/usage.rst | 4 +-
drivers/base/Kconfig | 3 +-
drivers/base/test/Kconfig | 3 +-
fs/ext4/Kconfig | 3 +-
include/kunit/test.h | 12 +-
lib/Kconfig.debug | 6 +-
lib/kunit/Kconfig | 23 ++-
security/apparmor/Kconfig | 3 +-
tools/testing/kunit/kunit.py | 307
+++++++++++++++++++++++++-------
tools/testing/kunit/kunit_tool_test.py | 63 ++++++-
11 files changed, 351 insertions(+), 89 deletions(-)
----------------------------------------------------------------
Hi Linus,
Please pull the following Kselftest update for Linux 5.8-rc1.
This Kselftest update for Linux 5.8-rc1 consists of:
- Several fixes from Masami Hiramatsu to improve coverage for
lib and sysctl tests.
- Clean up to vdso test and a new test for getcpu() from Mark Brown.
- Add new gen_tar selftests Makefile target generate selftest package
running "make gen_tar" in selftests directory from Veronika Kabatova.
- Other miscellaneous fixes to timens, exec, tpm2 tests.
diff is attached.
Please note that there is a conflict in
tools/testing/selftests/sysctl/sysctl.sh
between commit:
eee470e0739a ("selftests/sysctl: Fix to load test_sysctl module")
from the kselftest tree and patch:
"tools/testing/selftests/sysctl/sysctl.sh: support CONFIG_TEST_SYSCTL=y"
Stephen fixed this up in linux-next. Masami double checked the fix.
Please let me know if you see any problems and would like me to
address them.
thanks,
-- Shuah
----------------------------------------------------------------
The following changes since commit 2ef96a5bb12be62ef75b5828c0aab838ebb29cb8:
Linux 5.7-rc5 (2020-05-10 15:16:58 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
tags/linux-kselftest-5.8-rc1
for you to fetch changes up to 382561a0f11c4995d48ab82670412f8d6c418430:
selftests/sysctl: Make sysctl test driver as a module (2020-06-02
10:27:02 -0600)
----------------------------------------------------------------
linux-kselftest-5.8-rc1
This Kselftest update for Linux 5.8-rc1 consists of:
- Several fixes from Masami Hiramatsu to improve coverage for
lib and sysctl tests.
- Clean up to vdso test and a new test for getcpu() from Mark Brown.
- Add new gen_tar selftests Makefile target generate selftest package
running "make gen_tar" in selftests directory from Veronika Kabatova.
- Other miscellaneous fixes to timens, exec, tpm2 tests.
----------------------------------------------------------------
Andrei Vagin (1):
selftests/timens: handle a case when alarm clocks are not supported
Kees Cook (1):
selftests/exec: Verify execve of non-regular files fail
Mark Brown (3):
selftests: vdso: Rename vdso_test to vdso_test_gettimeofday
selftests: vdso: Use a header file to prototype parse_vdso API
selftests: vdso: Add a selftest for vDSO getcpu()
Masami Hiramatsu (6):
selftests/ftrace: Use printf for backslash included command
selftests/ftrace: Return unsupported if no error_log file
lib: Make prime number generator independently selectable
lib: Make test_sysctl initialized as module
selftests/sysctl: Fix to load test_sysctl module
selftests/sysctl: Make sysctl test driver as a module
Nikita Sobolev (1):
Kernel selftests: Add check if TPM devices are supported
Veronika Kabatova (1):
selftests: introduce gen_tar Makefile target
Documentation/dev-tools/kselftest.rst | 23 +++++++++
lib/math/Kconfig | 7 ++-
lib/test_sysctl.c | 2 +-
tools/testing/selftests/Makefile | 9 +++-
tools/testing/selftests/exec/.gitignore | 1 +
tools/testing/selftests/exec/Makefile | 2 +-
tools/testing/selftests/exec/execveat.c | 8 ++++
.../ftrace/test.d/ftrace/tracing-error-log.tc | 2 +
tools/testing/selftests/ftrace/test.d/functions | 8 ++--
.../ftrace/test.d/kprobe/kprobe_syntax_errors.tc | 4 +-
tools/testing/selftests/gen_kselftest_tar.sh | 5 ++
tools/testing/selftests/sysctl/config | 2 +-
tools/testing/selftests/sysctl/sysctl.sh | 13 +-----
tools/testing/selftests/timens/clock_nanosleep.c | 2 +-
tools/testing/selftests/timens/timens.c | 2 +-
tools/testing/selftests/timens/timens.h | 13 +++++-
tools/testing/selftests/timens/timer.c | 5 ++
tools/testing/selftests/timens/timerfd.c | 5 ++
tools/testing/selftests/tpm2/test_smoke.sh | 5 ++
tools/testing/selftests/tpm2/test_space.sh | 5 ++
tools/testing/selftests/vDSO/.gitignore | 2 +
tools/testing/selftests/vDSO/Makefile | 5 +-
tools/testing/selftests/vDSO/parse_vdso.c | 24 +---------
tools/testing/selftests/vDSO/parse_vdso.h | 31 +++++++++++++
.../selftests/vDSO/vdso_standalone_test_x86.c | 4 +-
tools/testing/selftests/vDSO/vdso_test_getcpu.c | 54
++++++++++++++++++++++
.../vDSO/{vdso_test.c => vdso_test_gettimeofday.c} | 10 ++--
27 files changed, 196 insertions(+), 57 deletions(-)
create mode 100644 tools/testing/selftests/vDSO/parse_vdso.h
create mode 100644 tools/testing/selftests/vDSO/vdso_test_getcpu.c
rename tools/testing/selftests/vDSO/{vdso_test.c =>
vdso_test_gettimeofday.c} (84%)
----------------------------------------------------------------
From: Tom Rix <trix(a)redhat.com>
repo : linux-next
tag : next-20200608
Start applying selftests to drivers/fpga.
While testing out this upcoming change on linux-fpga
'Add interrupt support to FPGA DFL drivers'
I did not see any existing fpga tests.
So I added one.
Tom Rix (1):
selftests: fpga: dfl: A test for afu interrupt support
tools/testing/selftests/Makefile | 1 +
tools/testing/selftests/drivers/fpga/Makefile | 9 +++++
.../testing/selftests/drivers/fpga/afu_intr.c | 38 +++++++++++++++++++
tools/testing/selftests/drivers/fpga/config | 1 +
4 files changed, 49 insertions(+)
create mode 100644 tools/testing/selftests/drivers/fpga/Makefile
create mode 100644 tools/testing/selftests/drivers/fpga/afu_intr.c
create mode 100644 tools/testing/selftests/drivers/fpga/config
--
2.18.1
Currently, drivers can only tell whether the link is up/down,
but no additional information is given.
This patch set provides an infrastructure that allows drivers to expose
to the user more information in addition to the link state.
This information can save users time which will not be wasted
trying to understand why the link is not up for example.
Expand the existing LINKSTATE_GET command with attributes for extended
state.
>From userspace, user can see the extended state like:
$ ethtool ethX
...
Link detected: no (No cable)
In addition, when drivers have another information about the general
extended state, it can be passed also using substate field.
>From userspace:
$ ethtool ethX
...
Link detected: no (Autoneg failure, No partner detected)
In the future the infrastructure can be used for example by PHY drivers to
report whether a downshift to a lower speed occurred, something like:
$ ethtool ethX
...
Link detected: yes (downshifted)
Patches #1-#3 Move mlxsw ethtool code to separate file
Patches #4-#5 Add infrastructure in ethtool
Patches #6-#7 Add support of extended state in mlxsw driver
Patches #8-#10 Add tests cases
Amit Cohen (10):
mlxsw: spectrum_dcb: Rename mlxsw_sp_port_headroom_set()
mlxsw: Move ethtool_ops to spectrum_ethtool.c
mlxsw: spectrum_ethtool: Move mlxsw_sp_port_type_speed_ops structs
ethtool: Add link extended state
Documentation: networking: ethtool-netlink: Add link extended state
mlxsw: reg: Port Diagnostics Database Register
mlxsw: spectrum_ethtool: Add link extended state
selftests: forwarding: ethtool: Move different_speeds_get() to
ethtool_lib
selftests: forwarding: forwarding.config.sample: Add port with no
cable connected
selftests: forwarding: Add tests for ethtool extended state
Documentation/networking/ethtool-netlink.rst | 56 +-
drivers/net/ethernet/mellanox/mlxsw/Makefile | 3 +-
drivers/net/ethernet/mellanox/mlxsw/reg.h | 51 +
.../net/ethernet/mellanox/mlxsw/spectrum.c | 1540 +---------------
.../net/ethernet/mellanox/mlxsw/spectrum.h | 45 +
.../ethernet/mellanox/mlxsw/spectrum_dcb.c | 6 +-
.../mellanox/mlxsw/spectrum_ethtool.c | 1641 +++++++++++++++++
include/linux/ethtool.h | 22 +
include/uapi/linux/ethtool.h | 70 +
include/uapi/linux/ethtool_netlink.h | 2 +
net/ethtool/linkstate.c | 40 +
.../selftests/net/forwarding/ethtool.sh | 17 -
.../net/forwarding/ethtool_extended_state.sh | 103 ++
.../selftests/net/forwarding/ethtool_lib.sh | 17 +
.../net/forwarding/forwarding.config.sample | 3 +
15 files changed, 2057 insertions(+), 1559 deletions(-)
create mode 100644 drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c
create mode 100755 tools/testing/selftests/net/forwarding/ethtool_extended_state.sh
--
2.20.1