Linux Test Project
 help / color / mirror / Atom feed
From: Andrea Cervesato <andrea.cervesato@suse.de>
To: Linux Test Project <ltp@lists.linux.it>
Subject: [LTP] [PATCH v2 01/33] lapi/keyctl.h: Add fallback definitions for extended ops
Date: Fri, 04 Sep 2026 14:08:50 +0200	[thread overview]
Message-ID: <20260904-keyctl_coverage-v2-1-43b78b15ef9f@suse.com> (raw)
In-Reply-To: <20260904-keyctl_coverage-v2-0-43b78b15ef9f@suse.com>

From: Andrea Cervesato <andrea.cervesato@suse.com>

Add fallback definitions for KEYCTL_LINK, KEYCTL_RESTRICT_KEYRING,
KEYCTL_MOVE, and KEYCTL_MOVE_EXCL, as well as fallback definitions
for struct keyctl_dh_params and struct keyctl_kdf_params when built
without keyutils.h or linux/keyctl.h.

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
 include/lapi/keyctl.h | 36 +++++++++++++++++++++++++++++++++++-
 m4/ltp-keyutils.m4    | 13 +++++++++++++
 2 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/include/lapi/keyctl.h b/include/lapi/keyctl.h
index 83fa09303..1c6627f55 100644
--- a/include/lapi/keyctl.h
+++ b/include/lapi/keyctl.h
@@ -8,6 +8,8 @@
 
 #include "config.h"
 
+#include <stdint.h>
+
 #if defined(HAVE_KEYUTILS_H) && defined(HAVE_LIBKEYUTILS)
 # include <keyutils.h>
 #else
@@ -16,7 +18,6 @@
 # endif /* HAVE_LINUX_KEYCTL_H */
 
 # include <stdarg.h>
-# include <stdint.h>
 # include "lapi/syscalls.h"
 typedef int32_t key_serial_t;
 
@@ -60,6 +61,23 @@ static inline key_serial_t keyctl_join_session_keyring(const char *name) {
 
 #endif /* defined(HAVE_KEYUTILS_H) && defined(HAVE_LIBKEYUTILS) */
 
+#ifndef HAVE_STRUCT_KEYCTL_DH_PARAMS
+struct keyctl_dh_params {
+	int32_t priv;
+	int32_t prime;
+	int32_t base;
+};
+#endif
+
+#ifndef HAVE_STRUCT_KEYCTL_KDF_PARAMS
+struct keyctl_kdf_params {
+	char *hashname;
+	char *otherinfo;
+	uint32_t otherinfolen;
+	uint32_t __spare[8];
+};
+#endif
+
 /* special process keyring shortcut IDs */
 #ifndef KEY_SPEC_THREAD_KEYRING
 # define KEY_SPEC_THREAD_KEYRING -1
@@ -124,6 +142,10 @@ static inline key_serial_t keyctl_join_session_keyring(const char *name) {
 # define KEYCTL_CLEAR 7
 #endif
 
+#ifndef KEYCTL_LINK
+# define KEYCTL_LINK 8
+#endif
+
 #ifndef KEYCTL_UNLINK
 # define KEYCTL_UNLINK 9
 #endif
@@ -168,6 +190,18 @@ static inline key_serial_t keyctl_join_session_keyring(const char *name) {
 # define KEYCTL_WATCH_KEY 32
 #endif
 
+#ifndef KEYCTL_RESTRICT_KEYRING
+# define KEYCTL_RESTRICT_KEYRING 29
+#endif
+
+#ifndef KEYCTL_MOVE
+# define KEYCTL_MOVE 30
+#endif
+
+#ifndef KEYCTL_MOVE_EXCL
+# define KEYCTL_MOVE_EXCL 0x00000001 /* do not displace from the to-keyring */
+#endif
+
 /* key permissions */
 #ifndef KEY_POS_VIEW
 # define KEY_POS_VIEW    0x01000000
diff --git a/m4/ltp-keyutils.m4 b/m4/ltp-keyutils.m4
index 451c549f3..82303bef7 100644
--- a/m4/ltp-keyutils.m4
+++ b/m4/ltp-keyutils.m4
@@ -7,4 +7,17 @@ AC_DEFUN([LTP_CHECK_KEYUTILS_SUPPORT], [
 	AC_CHECK_LIB([keyutils], [add_key],
 	[AC_DEFINE(HAVE_LIBKEYUTILS, 1, [Define to 1 if you have libkeyutils installed.])
 	      AC_SUBST(KEYUTILS_LIBS, "-lkeyutils")])
+
+	LTP_KEYCTL_HEADERS=""
+
+	if test "x$ac_cv_header_keyutils_h" = "xyes" && \
+	   test "x$ac_cv_lib_keyutils_add_key" = "xyes"; then
+		LTP_KEYCTL_HEADERS="#include <keyutils.h>"
+	elif test "x$ac_cv_header_linux_keyctl_h" = "xyes"; then
+		LTP_KEYCTL_HEADERS="#include <linux/keyctl.h>"
+	fi
+
+	AC_CHECK_TYPES([struct keyctl_dh_params, struct keyctl_kdf_params,
+			struct keyctl_pkey_query, struct keyctl_pkey_params],,,
+			[$LTP_KEYCTL_HEADERS])
 ])

-- 
2.51.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2026-09-04 12:09 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04 12:08 [LTP] [PATCH v2 00/33] Improve coverage for keyctl() syscall Andrea Cervesato
2026-09-04 12:08 ` Andrea Cervesato [this message]
2026-09-04 15:18   ` [LTP] lapi/keyctl.h: Add fallback definitions for extended ops linuxtestproject.agent
2026-09-11  7:31   ` [LTP] [PATCH v2 01/33] " Cyril Hrubis
2026-09-11  8:58     ` Petr Vorel
2026-09-04 12:08 ` [LTP] [PATCH v2 02/33] keyctl10: Test KEYCTL_DESCRIBE format parsing Andrea Cervesato
2026-09-11  7:54   ` Cyril Hrubis
2026-09-04 12:08 ` [LTP] [PATCH v2 03/33] keyctl11: Test KEYCTL_DESCRIBE with exact buffer size Andrea Cervesato
2026-09-11  8:01   ` Cyril Hrubis
2026-09-04 12:08 ` [LTP] [PATCH v2 04/33] keyctl12: Test KEYCTL_DESCRIBE with too small buffer Andrea Cervesato
2026-09-11  8:09   ` Cyril Hrubis
2026-09-04 12:08 ` [LTP] [PATCH v2 05/33] keyctl13: Test KEYCTL_DESCRIBE size query Andrea Cervesato
2026-09-04 12:08 ` [LTP] [PATCH v2 06/33] keyctl14: Negative tests for KEYCTL_DESCRIBE Andrea Cervesato
2026-09-11  8:17   ` Cyril Hrubis
2026-09-04 12:08 ` [LTP] [PATCH v2 07/33] keyctl15: Test KEYCTL_GET_SECURITY label retrieval Andrea Cervesato
2026-09-11  8:20   ` Cyril Hrubis
2026-09-11  9:11     ` Petr Vorel
2026-09-11 15:34       ` Cyril Hrubis
2026-09-11 19:24         ` Petr Vorel
2026-09-04 12:08 ` [LTP] [PATCH v2 08/33] keyctl16: Test KEYCTL_GET_SECURITY truncated copy Andrea Cervesato
2026-09-11  8:30   ` Cyril Hrubis
2026-09-04 12:08 ` [LTP] [PATCH v2 09/33] keyctl17: Negative tests for KEYCTL_GET_SECURITY Andrea Cervesato
2026-09-11  8:40   ` Cyril Hrubis
2026-09-04 12:08 ` [LTP] [PATCH v2 10/33] keyctl18: Test basic KEYCTL_MOVE Andrea Cervesato
2026-09-11 11:48   ` Cyril Hrubis
2026-09-04 12:09 ` [LTP] [PATCH v2 11/33] keyctl19: Test KEYCTL_MOVE with same source and destination Andrea Cervesato
2026-09-11 11:52   ` Cyril Hrubis
2026-09-04 12:09 ` [LTP] [PATCH v2 12/33] keyctl20: Test KEYCTL_MOVE displacement Andrea Cervesato
2026-09-11 12:00   ` Cyril Hrubis
2026-09-04 12:09 ` [LTP] [PATCH v2 13/33] keyctl21: Negative and boundary tests for KEYCTL_MOVE Andrea Cervesato
2026-09-11 12:11   ` Cyril Hrubis
2026-09-04 12:09 ` [LTP] [PATCH v2 14/33] keyctl22: Test KEYCTL_RESTRICT_KEYRING reject-all Andrea Cervesato
2026-09-11 12:13   ` Cyril Hrubis
2026-09-04 12:09 ` [LTP] [PATCH v2 15/33] keyctl23: Test KEYCTL_RESTRICT_KEYRING builtin_trusted Andrea Cervesato
2026-09-11 12:34   ` Cyril Hrubis
2026-09-04 12:09 ` [LTP] [PATCH v2 16/33] keyctl24: Negative tests for KEYCTL_RESTRICT_KEYRING Andrea Cervesato
2026-09-11 14:36   ` Cyril Hrubis
2026-09-04 12:09 ` [LTP] [PATCH v2 17/33] keyctl25: Test KEYCTL_DH_COMPUTE shared secret computation Andrea Cervesato
2026-09-11 14:53   ` Cyril Hrubis
2026-09-04 12:09 ` [LTP] [PATCH v2 18/33] keyctl26: Test KEYCTL_DH_COMPUTE size query Andrea Cervesato
2026-09-11 14:54   ` Cyril Hrubis
2026-09-04 12:09 ` [LTP] [PATCH v2 19/33] keyctl27: Test KEYCTL_DH_COMPUTE KDF key derivation Andrea Cervesato
2026-09-11 15:05   ` Cyril Hrubis
2026-09-04 12:09 ` [LTP] [PATCH v2 20/33] keyctl28: Negative and boundary tests for KEYCTL_DH_COMPUTE Andrea Cervesato
2026-09-11 15:17   ` Cyril Hrubis
2026-09-04 12:09 ` [LTP] [PATCH v2 21/33] lapi/keyctl.h: Add fallback definitions for public key ops Andrea Cervesato
2026-09-04 12:09 ` [LTP] [PATCH v2 22/33] keyctl29: Test KEYCTL_PKEY_QUERY on public key Andrea Cervesato
2026-09-11 15:35   ` Cyril Hrubis
2026-09-04 12:09 ` [LTP] [PATCH v2 23/33] keyctl30: Test KEYCTL_PKEY_QUERY on private key Andrea Cervesato
2026-09-11 15:37   ` Cyril Hrubis
2026-09-04 12:09 ` [LTP] [PATCH v2 24/33] keyctl31: Test KEYCTL_PKEY_ENCRYPT and KEYCTL_PKEY_DECRYPT Andrea Cervesato
2026-09-04 12:09 ` [LTP] [PATCH v2 25/33] keyctl32: Test KEYCTL_PKEY_SIGN and VERIFY Andrea Cervesato
2026-09-04 12:09 ` [LTP] [PATCH v2 26/33] keyctl33: Negative tests for KEYCTL_PKEY_* Andrea Cervesato
2026-09-04 12:09 ` [LTP] [PATCH v2 27/33] lapi/keyctl.h: Add capability fallback defines Andrea Cervesato
2026-09-04 12:09 ` [LTP] [PATCH v2 28/33] keyctl34: Test KEYCTL_CAPABILITIES flag retrieval Andrea Cervesato
2026-09-04 12:09 ` [LTP] [PATCH v2 29/33] keyctl35: Test KEYCTL_CAPABILITIES size query Andrea Cervesato
2026-09-04 12:09 ` [LTP] [PATCH v2 30/33] keyctl36: Test KEYCTL_CAPABILITIES buffer sizing Andrea Cervesato
2026-09-04 12:09 ` [LTP] [PATCH v2 31/33] keyctl37: Negative tests for KEYCTL_CAPABILITIES Andrea Cervesato
2026-09-04 12:09 ` [LTP] [PATCH v2 32/33] keyctl38: Test KEYCTL_WATCH_KEY add and remove Andrea Cervesato
2026-09-04 12:09 ` [LTP] [PATCH v2 33/33] keyctl39: Negative tests for KEYCTL_WATCH_KEY Andrea Cervesato

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=20260904-keyctl_coverage-v2-1-43b78b15ef9f@suse.com \
    --to=andrea.cervesato@suse.de \
    --cc=ltp@lists.linux.it \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox