From: Pablo Alessandro Santos Hugen <phugen@redhat.com>
To: selinux@vger.kernel.org
Cc: stephen.smalley.work@gmail.com, omosnacek@gmail.com
Subject: [PATCH v2] tests/keys: skip KEYCTL_DH_COMPUTE when unavailable
Date: Tue, 20 Oct 2026 15:06:37 -0300 [thread overview]
Message-ID: <20261020180701.2710971-1-phugen@redhat.com> (raw)
In-Reply-To: <20261018012855.1795025-1-phugen@redhat.com>
Since 32f07cc40c9b ("crypto: dh - disallow plain "dh" usage in
FIPS mode") landed in linux 5.18, plain "dh" is disallowed in
FIPS mode per SP800-56Arev3. keyctl(KEYCTL_DH_COMPUTE) returns
ENOENT in FIPS mode.
Treat ENOENT and EOPNOTSUPP as non-fatal in keyctl.c and
request_keys.c (the operation is unavailable, not denied by
policy). SELinux denials (EACCES) still exit 9/8.
Fixes: 2d7aad8a1f8c ("selinux-testsuite: Add keys tests")
Signed-off-by: Pablo Alessandro Santos Hugen <phugen@redhat.com>
---
Changes in v2 (Stephen Smalley):
- Replace ENOSYS with EOPNOTSUPP — KEYCTL_DH_COMPUTE never
returns ENOSYS; the !CONFIG_KEY_DH_OPERATIONS stub returns
EOPNOTSUPP
- Drop SKIP blocks in Perl test — SELinux denial fires before
DH computation (EACCES -> ENOKEY), so no_read_t tests still
pass under FIPS
tests/keys/keyctl.c | 15 ++++++++++-----
tests/keys/request_keys.c | 15 ++++++++++-----
2 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/tests/keys/keyctl.c b/tests/keys/keyctl.c
index e13c655..5e98f11 100644
--- a/tests/keys/keyctl.c
+++ b/tests/keys/keyctl.c
@@ -142,12 +142,17 @@ int main(int argc, char *argv[])
/* Requires key { create read write } */
compute = keyctl(KEYCTL_DH_COMPUTE, ¶ms, NULL, 0, 0);
if (compute < 0) {
- fprintf(stderr, "Failed KEYCTL_DH_COMPUTE: %s\n",
- strerror(errno));
- exit(9);
- }
- if (verbose)
+ if (errno == ENOENT || errno == EOPNOTSUPP) {
+ if (verbose)
+ printf("KEYCTL_DH_COMPUTE not available, skipping\n");
+ } else {
+ fprintf(stderr, "Failed KEYCTL_DH_COMPUTE: %s\n",
+ strerror(errno));
+ exit(9);
+ }
+ } else if (verbose) {
printf("KEYCTL_DH_COMPUTE key ID size: %d\n", compute);
+ }
/* Requires key { write link } */
link = keyctl(KEYCTL_LINK, base, KEY_SPEC_PROCESS_KEYRING);
diff --git a/tests/keys/request_keys.c b/tests/keys/request_keys.c
index 43b20d9..291a522 100644
--- a/tests/keys/request_keys.c
+++ b/tests/keys/request_keys.c
@@ -127,12 +127,17 @@ int main(int argc, char **argv)
/* Requires key { read write } */
compute = keyctl(KEYCTL_DH_COMPUTE, ¶ms, NULL, 0, 0);
if (compute < 0) {
- fprintf(stderr, "Failed KEYCTL_DH_COMPUTE: %s\n",
- strerror(errno));
- exit(8);
- }
- if (verbose)
+ if (errno == ENOENT || errno == EOPNOTSUPP) {
+ if (verbose)
+ printf("\tKEYCTL_DH_COMPUTE not available, skipping\n");
+ } else {
+ fprintf(stderr, "Failed KEYCTL_DH_COMPUTE: %s\n",
+ strerror(errno));
+ exit(8);
+ }
+ } else if (verbose) {
printf("\tKEYCTL_DH_COMPUTE key ID size: %d\n", compute);
+ }
exit(0);
}
--
2.56.0
next prev parent reply other threads:[~2026-10-20 18:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-18 1:28 [PATCH] tests/keys: skip KEYCTL_DH_COMPUTE when unavailable Pablo Alessandro Santos Hugen
2026-10-19 17:11 ` Stephen Smalley
2026-10-20 18:03 ` Pablo Hugen
2026-10-20 18:06 ` Pablo Alessandro Santos Hugen [this message]
2026-10-21 12:57 ` [PATCH v2] " Stephen Smalley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261020180701.2710971-1-phugen@redhat.com \
--to=phugen@redhat.com \
--cc=omosnacek@gmail.com \
--cc=selinux@vger.kernel.org \
--cc=stephen.smalley.work@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.