Skip to contentSkip to conversation

tests/io_uring: check io_uring_disabled before probing

PATCH In review Brian Grech 2 participants 3 messages Oct 5 – Oct 8 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/io_uring: check io_uring_disabled before probing

With kernel.io_uring_disabled == 2, the unconfined probe also fails (io_uring_setup() -> EPERM), so the probe's generic skip_all fires before the sysctl-specific elsif is ever reached, giving a less specific skip message than possible.

Check the sysctl first so the more specific message is used when it applies.

Fixes c3911c7 ("tests: skip io_uring when unsupported or disabled")
---
 tests/io_uring/test | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)
tests/io_uring/test +15 -11
index fb6528e..217ac0a 100755
@@ -6,27 +6,31 @@ BEGIN {
     $basedir = $0;
     $basedir =~ s|(.*)/[^/]*|$1|;
 
-    # Probe unconfined so a failure here means io_uring isn't built into
-    # the kernel at all, not that it was denied by policy.
-    my $io_uring_supported =
-      system("$basedir/iouring probe >/dev/null 2>&1") == 0 ? 1 : 0;
-
     # kernel.io_uring_disabled was only added in v6.6, well after the
     # io_uring support being tested here (v5.16), so its absence does not
     # mean io_uring is unsupported - only a value of 2 means io_uring is
-    # administratively disabled, even for privileged processes.
+    # administratively disabled, even for privileged processes. Check
+    # this first: when it applies, the unconfined probe below would also
+    # fail (io_uring_setup() -> EPERM), giving a less specific message.
     chomp( my $io_uring_disabled =
           `sysctl -n kernel.io_uring_disabled 2>/dev/null` );
 
-    if ( !$io_uring_supported ) {
-        plan skip_all => "io_uring not supported by this kernel";
-    }
-    elsif ( $io_uring_disabled eq "2" ) {
+    if ( $io_uring_disabled eq "2" ) {
         plan skip_all =>
           "io_uring is disabled via the kernel.io_uring_disabled sysctl";
     }
     else {
-        plan tests => 11;
+        # Probe unconfined so a failure here means io_uring isn't built
+        # into the kernel at all, not that it was denied by policy.
+        my $io_uring_supported =
+          system("$basedir/iouring probe >/dev/null 2>&1") == 0 ? 1 : 0;
+
+        if ( !$io_uring_supported ) {
+            plan skip_all => "io_uring not supported by this kernel";
+        }
+        else {
+            plan tests => 11;
+        }
     }
 }
 
Signature · 1 line
2.55.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Brian Grech

With kernel.io_uring_disabled == 2, the unconfined probe also fails (io_uring_setup() -> EPERM), so the probe's generic skip_all fires before the sysctl-specific elsif is ever reached, giving a less specific skip message than possible.

Check the sysctl first so the more specific message is used when it applies.

Fixes c3911c7 ("tests: skip io_uring when unsupported or disabled")

Nit: We conventionally use 12-char commit hashes like the Linux kernel, but I can fix that on merge.

maintainer
#2 lore raw
Quoted 11 lines · Stephen Smalley
Quoted 9 lines · Brian Grech

With kernel.io_uring_disabled == 2, the unconfined probe also fails (io_uring_setup() -> EPERM), so the probe's generic skip_all fires before the sysctl-specific elsif is ever reached, giving a less specific skip message than possible.

Check the sysctl first so the more specific message is used when it applies.

Quoted 6 lines
Quoted 2 lines
Fixes c3911c7 ("tests: skip io_uring when unsupported or disabled")

Nit: We conventionally use 12-char commit hashes like the Linux kernel, but I can fix that on merge.

Thanks, merged