Infiniband test fixes/improvements
cover Infiniband test fixes/improvements
Add missing policy rule needed on systems with strict resource limits, add another missing rule to reduce AVC noise, and simplify how IB tests are activated.
Tested on an aarch64 machine with an IB device and RHEL-8.7 installed.
v2: add comments explaining the newly added policy rules
Ondrej Mosnacek (3):
policy: make sure test_ibpkey_access_t can lock enough memory
policy: allow test_ibpkey_access_t to use RDMA netlink sockets tests/infiniband*: simplify test activation
Vagrantfile | 1 + policy/test_ibpkey.te | 8 +++++++ tests/Makefile | 11 ++------- tests/infiniband_endport/test | 39 ++++++++++++++++++------------- tests/infiniband_pkey/test | 44 ++++++++++++++++++++--------------- 5 files changed, 59 insertions(+), 44 deletions(-)
Signature · 1 line
2.39.2
PATCH 1/3 policy: make sure test_ibpkey_access_t can lock enough memory
The ibv_create_cq() operation requires the caller to be able to lock enough memory (RLIMIT_MEMLOCK). In some environments (such as RHEL-8) the default resource limits may not be enough, requiring CAP_IPC_LOCK to go above the limit. To make sure the test works also under stricter resource limits, grant CAP_IPC_LOCK to test_ibpkey_access_t.
--- policy/test_ibpkey.te | 4 ++++ 1 file changed, 4 insertions(+)
policy/test_ibpkey.te +4 -0
@@ -10,6 +10,10 @@ type test_ibpkey_access_t; testsuite_domain_type(test_ibpkey_access_t) typeattribute test_ibpkey_access_t ibpkeydomain; +# ibv_create_cq(3) locks some memory - make sure the domain can do that +# even with strict resource limits. +allow test_ibpkey_access_t self:capability ipc_lock; + dev_rw_infiniband_dev(test_ibpkey_access_t) dev_rw_sysfs(test_ibpkey_access_t)
Signature · 1 line
2.39.2
PATCH 2/3 policy: allow test_ibpkey_access_t to use RDMA netlink sockets
In reply to Ondrej MosnacekSince rdma-core version 25, ibv_get_device_list(3) first tries to get the device list via netlink and only if that fails it falls back to getting it from sysfs. Currently the policy denies getting it from netlink, generating some denials. Allow test_ibpkey_access_t the necessary permissions so it can do it the preferred way and doesn't generate audit AVC noise.
--- policy/test_ibpkey.te | 4 ++++ 1 file changed, 4 insertions(+)
policy/test_ibpkey.te +4 -0
@@ -14,6 +14,10 @@ typeattribute test_ibpkey_access_t ibpkeydomain; # even with strict resource limits. allow test_ibpkey_access_t self:capability ipc_lock; +# ibv_get_device_list(3) wants to list the devices via netlink by default +# (if denied it falls back to listing them via sysfs). +allow test_ibpkey_access_t self:netlink_rdma_socket create_socket_perms; + dev_rw_infiniband_dev(test_ibpkey_access_t) dev_rw_sysfs(test_ibpkey_access_t)
Signature · 1 line
2.39.2
PATCH 3/3 tests/infiniband*: simplify test activation
In reply to Ondrej MosnacekUse Test::More and skip_all to enable/disable these tests if they are configured instead of doing this in the Makefile via grep.
--- Vagrantfile | 1 + tests/Makefile | 11 ++------- tests/infiniband_endport/test | 39 ++++++++++++++++++------------- tests/infiniband_pkey/test | 44 ++++++++++++++++++++--------------- 4 files changed, 51 insertions(+), 44 deletions(-)
Vagrantfile +1 -0
@@ -89,6 +89,7 @@ EOF e2fsprogs \ jfsutils \ dosfstools \ + rdma-core-devel \ #{kernel_pkgs} #{extra_commands}
tests/Makefile +2 -9
@@ -27,7 +27,8 @@ SUBDIRS:= domain_trans entrypoint execshare exectrace execute_no_trans \ task_setnice task_setscheduler task_getscheduler task_getsid \ task_getpgid task_setpgid file ioctl capable_file capable_net \ capable_sys dyntrans dyntrace bounds nnp_nosuid mmap unix_socket \ - inet_socket overlay checkreqprot mqueue mac_admin atsecure + inet_socket overlay checkreqprot mqueue mac_admin atsecure \ + infiniband_endport infiniband_pkey ifeq ($(shell grep -q cap_userns $(POLDEV)/include/support/all_perms.spt && echo true),true) ifneq ($(shell ./kvercmp $$(uname -r) 4.7),-1)
@@ -82,14 +83,6 @@ endif # POL_VERS endif # POL_TYPE endif # MAX_KERNEL_POLICY -ifeq ($(shell grep "^SELINUX_INFINIBAND_ENDPORT_TEST=" infiniband_endport/ibendport_test.conf | cut -d'=' -f 2),1) -SUBDIRS += infiniband_endport -endif - -ifeq ($(shell grep "^SELINUX_INFINIBAND_PKEY_TEST=" infiniband_pkey/ibpkey_test.conf | cut -d'=' -f 2),1) -SUBDIRS += infiniband_pkey -endif - ifneq ($(shell ./kvercmp $$(uname -r) 5.2),-1) SUBDIRS += cgroupfs_label endif
tests/infiniband_endport/test +23 -16
@@ -1,25 +1,32 @@ #!/usr/bin/perl -use Test; +use Test::More; -BEGIN { plan tests => 3 } +my %conf; -$basedir = $0; -$basedir =~ s|(.*)/[^/]*|$1|; +BEGIN { + $basedir = $0; + $basedir =~ s|(.*)/[^/]*|$1|; + + $confpath = $basedir . "/ibendport_test.conf"; + open( $f, $confpath ) or die("Couldn't open $confpath"); + while ( $r = <$f> ) { + if ( $r =~ /^\s*#/ || $r =~ /^\s*$/ ) { next; } + chomp $r; + ( $k, $v ) = split( /=/, $r ); + $conf{$k} = $v; + } + close($f); -my %conf; -my $confpath = $basedir . "/ibendport_test.conf"; -open( $f, $confpath ) or die("Couldn't open ibtest.conf"); -while ( $r = <$f> ) { - if ( $r =~ /^\s*#/ || $r =~ /^\s*$/ ) { next; } - chomp $r; - ( $k, $v ) = split( /=/, $r ); - $conf{$k} = $v; + # Verify that we really want to run these tests. + if ( $conf{SELINUX_INFINIBAND_ENDPORT_TEST} eq 1 ) { + plan tests => 2; + } + else { + plan skip_all => "test not configured"; + } } -# verify that we really want to run these tests -ok( $conf{SELINUX_INFINIBAND_ENDPORT_TEST} eq 1 ); - @allowed_device_port = split( /,/, $conf{SELINUX_INFINIBAND_ENDPORT_TEST_ALLOWED} ); @denied_device_port =
@@ -36,7 +43,7 @@ foreach (@allowed_device_port) { last; } } -ok( $result, 0 ); +ok( $result eq 0 ); foreach (@denied_device_port) { @dev_port_pair = split( / /, $_ );
tests/infiniband_pkey/test +25 -19
71 lines not on this page · raw message
Signature · 1 line
2.39.2
Quoted 21 lines · Ondrej Mosnacek
Add missing policy rule needed on systems with strict resource limits, add another missing rule to reduce AVC noise, and simplify how IB tests are activated.
Tested on an aarch64 machine with an IB device and RHEL-8.7 installed.
v2: add comments explaining the newly added policy rules
Ondrej Mosnacek (3):
policy: make suretest_ibpkey_access_tcan lock enough memory
policy: allowtest_ibpkey_access_tto use RDMA netlink sockets tests/infiniband*: simplify test activationVagrantfile | 1 + policy/test_ibpkey.te | 8 +++++++ tests/Makefile | 11 ++------- tests/infiniband_endport/test | 39 ++++++++++++++++++------------- tests/infiniband_pkey/test | 44 ++++++++++++++++++++--------------- 5 files changed, 59 insertions(+), 44 deletions(-)
Quoted 3 lines
--
2.39.2
Forgot to add v2 into the subject... Please imagine it's there :)
--
Ondrej Mosnacek
Senior Software Engineer, Linux Security - SELinux kernel Red Hat, Inc.
Quoted 23 lines · Ondrej Mosnacek
Quoted 21 lines · Ondrej Mosnacek
Add missing policy rule needed on systems with strict resource limits, add another missing rule to reduce AVC noise, and simplify how IB tests are activated.
Tested on an aarch64 machine with an IB device and RHEL-8.7 installed.
v2: add comments explaining the newly added policy rules
Ondrej Mosnacek (3):
policy: make suretest_ibpkey_access_tcan lock enough memory
policy: allowtest_ibpkey_access_tto use RDMA netlink sockets tests/infiniband*: simplify test activationVagrantfile | 1 + policy/test_ibpkey.te | 8 +++++++ tests/Makefile | 11 ++------- tests/infiniband_endport/test | 39 ++++++++++++++++++------------- tests/infiniband_pkey/test | 44 ++++++++++++++++++++--------------- 5 files changed, 59 insertions(+), 44 deletions(-)
Quoted 5 lines
Quoted 3 lines
--
2.39.2Forgot to add v2 into the subject... Please imagine it's there :)
The v2 is now applied.
Signature · 3 lines
Ondrej Mosnacek Senior Software Engineer, Linux Security - SELinux kernel Red Hat, Inc.