Skip to contentSkip to conversation

Infiniband test fixes/improvements

PATCH In review Ondrej Mosnacek 3 participants 13 messages Feb 28, 2023 – Mar 6, 2023 SELinux security module

lore
Share & tools
lore
#0 lore raw

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.

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         |  3 +++
 tests/Makefile                | 11 ++-------
 tests/infiniband_endport/test | 39 ++++++++++++++++++-------------
 tests/infiniband_pkey/test    | 44 ++++++++++++++++++++---------------
 5 files changed, 54 insertions(+), 44 deletions(-)
Signature · 1 line
2.39.2
#1 lore raw

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 | 2 ++
 1 file changed, 2 insertions(+)
policy/test_ibpkey.te +2 -0
index 863ff16..97f0c3c 100644
@@ -10,6 +10,8 @@ type test_ibpkey_access_t;
 testsuite_domain_type(test_ibpkey_access_t)
 typeattribute test_ibpkey_access_t ibpkeydomain;
 
+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
maintainer
#2 lore raw

Re: [PATCH testsuite 1/3] policy: make sure test_ibpkey_access_t can lock enough memory

Quoted 18 lines · Ondrej Mosnacek

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 | 2 ++
 1 file changed, 2 insertions(+)
policy/test_ibpkey.te +0 -0
index 863ff16..97f0c3c 100644

policy/test_ibpkey.te type test_ibpkey_access_t; · line 13

Quoted 4 lines
policy/test_ibpkey.te +1 -0
@@ -10,6 +10,8 @@ type test_ibpkey_access_t;
 testsuite_domain_type(test_ibpkey_access_t)
 typeattribute test_ibpkey_access_t ibpkeydomain;
 
+allow test_ibpkey_access_t self:capability ipc_lock;

FWIW, I brought this up back in 2019 and have been carrying a local selinux-testsuite patch for this ever since (it's the only way to get a clean run of the IB tests). While it can be fixed in the selinux-testsuite policy, I believe this is a more general problem and should probably be fixed in refpol.

https://lore.kernel.org/selinux/CAHC9VhTuYi+W0RukEV4WNrP5X_AFeouaWMsdbgxSL1v04mouWw@mail.gmail.com/

Quoted 5 lines
policy/test_ibpkey.te +0 -1
 dev_rw_infiniband_dev(test_ibpkey_access_t)
 dev_rw_sysfs(test_ibpkey_access_t)
 
--

2.39.2

Signature · 1 line
paul-moore.com
#3 lore raw

Re: [PATCH testsuite 1/3] policy: make sure test_ibpkey_access_t can lock enough memory

Quoted 22 lines · Paul Moore
Quoted 21 lines · Ondrej Mosnacek

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 | 2 ++
 1 file changed, 2 insertions(+)
policy/test_ibpkey.te +0 -0
index 863ff16..97f0c3c 100644
@@ -10,6 +10,8 @@ type test_ibpkey_access_t;
 testsuite_domain_type(test_ibpkey_access_t)
 typeattribute test_ibpkey_access_t ibpkeydomain;
 
Quoted 5 lines

policy/test_ibpkey.te type test_ibpkey_access_t; · line 13

Quoted 1 line
policy/test_ibpkey.te +1 -0
+allow test_ibpkey_access_t self:capability ipc_lock;

FWIW, I brought this up back in 2019 and have been carrying a local selinux-testsuite patch for this ever since (it's the only way to get a clean run of the IB tests).

Confirmed, with this change the SELinux infiniband tests are now working on stable linux-4.19.y.

Quoted 8 lines

While it can be fixed in the
selinux-testsuite policy, I believe this is a more general problem and should probably be fixed in refpol.

https://lore.kernel.org/selinux/CAHC9VhTuYi+W0RukEV4WNrP5X_AFeouaWMsdbgxSL1v04mouWw@mail.gmail.com/

Quoted 2 lines
policy/test_ibpkey.te +0 -0
 dev_rw_infiniband_dev(test_ibpkey_access_t)
 dev_rw_sysfs(test_ibpkey_access_t)
Signature · 3 lines
thanks,

Mimi
#4 lore raw

Re: [PATCH testsuite 1/3] policy: make sure test_ibpkey_access_t can lock enough memory

In reply to Paul Moore
Quoted 30 lines · Paul Moore
Quoted 18 lines · Ondrej Mosnacek

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 | 2 ++
 1 file changed, 2 insertions(+)
policy/test_ibpkey.te +0 -0
index 863ff16..97f0c3c 100644

policy/test_ibpkey.te type test_ibpkey_access_t; · line 13

Quoted 4 lines
policy/test_ibpkey.te +1 -0
@@ -10,6 +10,8 @@ type test_ibpkey_access_t;
 testsuite_domain_type(test_ibpkey_access_t)
 typeattribute test_ibpkey_access_t ibpkeydomain;
 
+allow test_ibpkey_access_t self:capability ipc_lock;

FWIW, I brought this up back in 2019 and have been carrying a local selinux-testsuite patch for this ever since (it's the only way to get a clean run of the IB tests). While it can be fixed in the selinux-testsuite policy, I believe this is a more general problem and should probably be fixed in refpol.

Quoted 1 line

https://lore.kernel.org/selinux/CAHC9VhTuYi+W0RukEV4WNrP5X_AFeouaWMsdbgxSL1v04mouWw@mail.gmail.com/

I don't understand how you'd like this to be fixed in the system policy... I don't think there is any policy interface that would semantically match "any users of the SELinux IB hooks" or "callers of ibv_create_cq()" that we could stick the capability rule into. At least the testsuite policy doesn't use any such interface. Closest to it would be dev_rw_infiniband_dev(), but that doesn't seem like the right place.

Not to mention that the fact whether the capability is required or not depends on the resource limits imposed on the process. If its RLIMIT_MEMLOCK limit is sufficient, a process is perfectly able to create the cq without CAP_IPC_LOCK. Automatically granting it to all domains that use InfiniBand in some way "just in case" would potentially grant it also to domains that don't actually need it, violating the principle of least privilege.

--
Ondrej Mosnacek
Senior Software Engineer, Linux Security - SELinux kernel Red Hat, Inc.

maintainer
#5 lore raw

Re: [PATCH testsuite 1/3] policy: make sure test_ibpkey_access_t can lock enough memory

Quoted 33 lines · Ondrej Mosnacek
Quoted 30 lines · Paul Moore
Quoted 18 lines · Ondrej Mosnacek

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 | 2 ++
 1 file changed, 2 insertions(+)
policy/test_ibpkey.te +0 -0
index 863ff16..97f0c3c 100644

policy/test_ibpkey.te type test_ibpkey_access_t; · line 13

Quoted 4 lines
policy/test_ibpkey.te +1 -0
@@ -10,6 +10,8 @@ type test_ibpkey_access_t;
 testsuite_domain_type(test_ibpkey_access_t)
 typeattribute test_ibpkey_access_t ibpkeydomain;
 
+allow test_ibpkey_access_t self:capability ipc_lock;

FWIW, I brought this up back in 2019 and have been carrying a local selinux-testsuite patch for this ever since (it's the only way to get a clean run of the IB tests). While it can be fixed in the selinux-testsuite policy, I believe this is a more general problem and should probably be fixed in refpol.

Quoted 1 line

https://lore.kernel.org/selinux/CAHC9VhTuYi+W0RukEV4WNrP5X_AFeouaWMsdbgxSL1v04mouWw@mail.gmail.com/

Quoted 7 lines

I don't understand how you'd like this to be fixed in the system policy... I don't think there is any policy interface that would semantically match "any users of the SELinux IB hooks" or "callers of ibv_create_cq()" that we could stick the capability rule into. At least the testsuite policy doesn't use any such interface. Closest to it would be dev_rw_infiniband_dev(), but that doesn't seem like the right place.

Look at it this way, the selinux-testsuite is not doing anything particularly unusual with respect to talking over IB; if the tests need that permission it seems reasonable that normal IB users would also need these permissions.

Quoted 7 lines

Not to mention that the fact whether the capability is required or not depends on the resource limits imposed on the process. If its RLIMIT_MEMLOCK limit is sufficient, a process is perfectly able to create the cq without CAP_IPC_LOCK. Automatically granting it to all domains that use InfiniBand in some way "just in case" would potentially grant it also to domains that don't actually need it, violating the principle of least privilege.

Once again, the selinux-testsuite is not doing anything particularly unusual so if we are hitting this it seems reasonable that other users are hitting this as well. If you're concerned about granting CAP_IPC_LOCK you could always put it in a dedicated IB/RDMA refpol interface as I believe this is just an issue with the IB/RDMA verb interface involving CQs/QPs and not the underlying IB protocol layer. Say something like "dev_rw_infiniband_rdma()"* which would call "dev_rw_infiniband()"* and add the CAP_IPC_LOCK permission.

It would be good to hear Chris' take on this.

* Upstream refpol appears to have shortened the interface to "dev_rw_infiniband()".

Signature · 1 line
paul-moore.com
#6 lore raw

Re: [PATCH testsuite 1/3] policy: make sure test_ibpkey_access_t can lock enough memory

Quoted 64 lines · Paul Moore
Quoted 33 lines · Ondrej Mosnacek
Quoted 30 lines · Paul Moore
Quoted 18 lines · Ondrej Mosnacek

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 | 2 ++
 1 file changed, 2 insertions(+)
policy/test_ibpkey.te +0 -0
index 863ff16..97f0c3c 100644

policy/test_ibpkey.te type test_ibpkey_access_t; · line 13

Quoted 4 lines
policy/test_ibpkey.te +1 -0
@@ -10,6 +10,8 @@ type test_ibpkey_access_t;
 testsuite_domain_type(test_ibpkey_access_t)
 typeattribute test_ibpkey_access_t ibpkeydomain;
 
+allow test_ibpkey_access_t self:capability ipc_lock;

FWIW, I brought this up back in 2019 and have been carrying a local selinux-testsuite patch for this ever since (it's the only way to get a clean run of the IB tests). While it can be fixed in the selinux-testsuite policy, I believe this is a more general problem and should probably be fixed in refpol.

Quoted 1 line

https://lore.kernel.org/selinux/CAHC9VhTuYi+W0RukEV4WNrP5X_AFeouaWMsdbgxSL1v04mouWw@mail.gmail.com/

Quoted 7 lines

I don't understand how you'd like this to be fixed in the system policy... I don't think there is any policy interface that would semantically match "any users of the SELinux IB hooks" or "callers of ibv_create_cq()" that we could stick the capability rule into. At least the testsuite policy doesn't use any such interface. Closest to it would be dev_rw_infiniband_dev(), but that doesn't seem like the right place.

Look at it this way, the selinux-testsuite is not doing anything particularly unusual with respect to talking over IB; if the tests need that permission it seems reasonable that normal IB users would also need these permissions.

Quoted 7 lines

Not to mention that the fact whether the capability is required or not depends on the resource limits imposed on the process. If its RLIMIT_MEMLOCK limit is sufficient, a process is perfectly able to create the cq without CAP_IPC_LOCK. Automatically granting it to all domains that use InfiniBand in some way "just in case" would potentially grant it also to domains that don't actually need it, violating the principle of least privilege.

Once again, the selinux-testsuite is not doing anything particularly unusual so if we are hitting this it seems reasonable that other users are hitting this as well. If you're concerned about granting CAP_IPC_LOCK you could always put it in a dedicated IB/RDMA refpol interface as I believe this is just an issue with the IB/RDMA verb interface involving CQs/QPs and not the underlying IB protocol layer. Say something like "dev_rw_infiniband_rdma()"* which would call "dev_rw_infiniband()"* and add the CAP_IPC_LOCK permission.

Quoted 1 line

It would be good to hear Chris' take on this.

Okay, so I guess you addressed your comments more towards refpolicy maintainer/contributors than to me as the submitter/testsuite maintainer and I didn't have to react so defensively...

I agree that having better semantic interfaces for RDMA users in refpolicy and Fedora policy would be nice, but I also wouldn't block having a working testsuite on that. I'll be happy to switch any new appropriate interfaces (and replicate them in Fedora policy) once they are available.

Quoted 7 lines

* Upstream refpol appears to have shortened the interface to "dev_rw_infiniband()".

--
paul-moore.com

--
Ondrej Mosnacek
Senior Software Engineer, Linux Security - SELinux kernel Red Hat, Inc.

maintainer
#7 lore raw

Re: [PATCH testsuite 1/3] policy: make sure test_ibpkey_access_t can lock enough memory

Quoted 71 lines · Ondrej Mosnacek
Quoted 64 lines · Paul Moore
Quoted 33 lines · Ondrej Mosnacek
Quoted 30 lines · Paul Moore
Quoted 18 lines · Ondrej Mosnacek

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 | 2 ++
 1 file changed, 2 insertions(+)
policy/test_ibpkey.te +0 -0
index 863ff16..97f0c3c 100644

policy/test_ibpkey.te type test_ibpkey_access_t; · line 13

Quoted 4 lines
policy/test_ibpkey.te +1 -0
@@ -10,6 +10,8 @@ type test_ibpkey_access_t;
 testsuite_domain_type(test_ibpkey_access_t)
 typeattribute test_ibpkey_access_t ibpkeydomain;
 
+allow test_ibpkey_access_t self:capability ipc_lock;

FWIW, I brought this up back in 2019 and have been carrying a local selinux-testsuite patch for this ever since (it's the only way to get a clean run of the IB tests). While it can be fixed in the selinux-testsuite policy, I believe this is a more general problem and should probably be fixed in refpol.

Quoted 1 line

https://lore.kernel.org/selinux/CAHC9VhTuYi+W0RukEV4WNrP5X_AFeouaWMsdbgxSL1v04mouWw@mail.gmail.com/

Quoted 7 lines

I don't understand how you'd like this to be fixed in the system policy... I don't think there is any policy interface that would semantically match "any users of the SELinux IB hooks" or "callers of ibv_create_cq()" that we could stick the capability rule into. At least the testsuite policy doesn't use any such interface. Closest to it would be dev_rw_infiniband_dev(), but that doesn't seem like the right place.

Look at it this way, the selinux-testsuite is not doing anything particularly unusual with respect to talking over IB; if the tests need that permission it seems reasonable that normal IB users would also need these permissions.

Quoted 7 lines

Not to mention that the fact whether the capability is required or not depends on the resource limits imposed on the process. If its RLIMIT_MEMLOCK limit is sufficient, a process is perfectly able to create the cq without CAP_IPC_LOCK. Automatically granting it to all domains that use InfiniBand in some way "just in case" would potentially grant it also to domains that don't actually need it, violating the principle of least privilege.

Once again, the selinux-testsuite is not doing anything particularly unusual so if we are hitting this it seems reasonable that other users are hitting this as well. If you're concerned about granting CAP_IPC_LOCK you could always put it in a dedicated IB/RDMA refpol interface as I believe this is just an issue with the IB/RDMA verb interface involving CQs/QPs and not the underlying IB protocol layer. Say something like "dev_rw_infiniband_rdma()"* which would call "dev_rw_infiniband()"* and add the CAP_IPC_LOCK permission.

Quoted 1 line

It would be good to hear Chris' take on this.

Okay, so I guess you addressed your comments more towards refpolicy maintainer/contributors than to me as the submitter/testsuite maintainer and I didn't have to react so defensively...

Quoted 5 lines

I agree that having better semantic interfaces for RDMA users in refpolicy and Fedora policy would be nice, but I also wouldn't block having a working testsuite on that. I'll be happy to switch any new appropriate interfaces (and replicate them in Fedora policy) once they are available.

Yes, the test suite needs to be functional even if the reference policy is missing important permissions, I was hoping to see some comment from Chris or perhaps some of the other policy folks about this but it looks like that isn't going to happen in a timely fashion.

Signature · 1 line
paul-moore.com
#8 lore raw

PATCH 2/3 policy: allow test_ibpkey_access_t to use RDMA netlink sockets

In reply to Ondrej Mosnacek

ibv_get_device_list(3) first tries to get the device list via netlink and 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 | 1 +
 1 file changed, 1 insertion(+)
policy/test_ibpkey.te +1 -0
index 97f0c3c..6835897 100644
@@ -11,6 +11,7 @@ testsuite_domain_type(test_ibpkey_access_t)
 typeattribute test_ibpkey_access_t ibpkeydomain;
 
 allow test_ibpkey_access_t self:capability ipc_lock;
+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
maintainer
#9 lore raw

Re: [PATCH testsuite 2/3] policy: allow test_ibpkey_access_t to use RDMA netlink sockets

Quoted 11 lines · Ondrej Mosnacek

ibv_get_device_list(3) first tries to get the device list via netlink and 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 | 1 +
 1 file changed, 1 insertion(+)

Similar to the other policy issue, it seems like this is a general problem and not specifically a selinux-testsuite issue, right? If that is the case should we fix this in refpol? I think it's okay to put a temporary fix in the test suite, but we should also push to fix this in refpol.

Quoted 14 lines
policy/test_ibpkey.te +1 -1
index 97f0c3c..6835897 100644
@@ -11,6 +11,7 @@ testsuite_domain_type(test_ibpkey_access_t)
 typeattribute test_ibpkey_access_t ibpkeydomain;
 
 allow test_ibpkey_access_t self:capability ipc_lock;
+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)
--

2.39.2

Signature · 1 line
paul-moore.com
#10 lore raw

Re: [PATCH testsuite 2/3] policy: allow test_ibpkey_access_t to use RDMA netlink sockets

Quoted 13 lines · Paul Moore
Quoted 11 lines · Ondrej Mosnacek

ibv_get_device_list(3) first tries to get the device list via netlink and 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 | 1 +
 1 file changed, 1 insertion(+)
Quoted 5 lines

Similar to the other policy issue, it seems like this is a general problem and not specifically a selinux-testsuite issue, right? If that is the case should we fix this in refpol? I think it's okay to put a temporary fix in the test suite, but we should also push to fix this in refpol.

Basically the same as I said in the first paragraph of my reply under patch 1 applies here, just in this case we are talking about users of ibv_get_device_list(3) instead of ibv_create_cq(3).

Signature · 3 lines
Ondrej Mosnacek
Senior Software Engineer, Linux Security - SELinux kernel
Red Hat, Inc.
maintainer
#11 lore raw

Re: [PATCH testsuite 2/3] policy: allow test_ibpkey_access_t to use RDMA netlink sockets

Quoted 20 lines · Ondrej Mosnacek
Quoted 13 lines · Paul Moore
Quoted 11 lines · Ondrej Mosnacek

ibv_get_device_list(3) first tries to get the device list via netlink and 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 | 1 +
 1 file changed, 1 insertion(+)
Quoted 5 lines

Similar to the other policy issue, it seems like this is a general problem and not specifically a selinux-testsuite issue, right? If that is the case should we fix this in refpol? I think it's okay to put a temporary fix in the test suite, but we should also push to fix this in refpol.

Quoted 3 lines

Basically the same as I said in the first paragraph of my reply under patch 1 applies here, just in this case we are talking about users of ibv_get_device_list(3) instead of ibv_create_cq(3).

Yeah, let's just tackle this in the other thread, at this point it's a bit silly to duplicate the discussion.

Signature · 1 line
paul-moore.com
#12 lore raw

PATCH 3/3 tests/infiniband*: simplify test activation

In reply to Ondrej Mosnacek

Use 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
index 6f7675f..682b805 100644
@@ -89,6 +89,7 @@ EOF
       e2fsprogs \
       jfsutils \
       dosfstools \
+      rdma-core-devel \
       #{kernel_pkgs}
 
     #{extra_commands}
tests/Makefile +2 -9
index 5998a9f..74df247 100644
@@ -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
index f071fbc..c55ce84 100755
@@ -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