Improve coverage for keyctl() syscall
cover Improve coverage for keyctl() syscall
Improve the keyctl() syscall coverage by adding more tests for the following features, which are not currently tested in LTP:
- KEYCTL_DESCRIBE
- KEYCTL_GET_SECURITY
- KEYCTL_MOVE
- KEYCTL_RESTRICT_KEYRING
- KEYCTL_DH_COMPUTE
- KEYCTL_PKEY_*
- KEYCTL_CAPABILITIES
- KEYCTL_WATCH_KEY
The testing suite has been assisted by GLM 5.3 for coverage analysis and Gemini Flash 3.7 for the tests skeleton.
Validation: https://openqa.opensuse.org/tests/6199954#
---
Andrea Cervesato (33):
lapi/keyctl.h: Add fallback definitions for extended ops
keyctl10: Test KEYCTL_DESCRIBE format parsing
keyctl11: Test KEYCTL_DESCRIBE with exact buffer size
keyctl12: Test KEYCTL_DESCRIBE with too small buffer
keyctl13: Test KEYCTL_DESCRIBE size query
keyctl14: Negative tests for KEYCTL_DESCRIBE
keyctl15: Test KEYCTL_GET_SECURITY label retrieval
keyctl16: Test KEYCTL_GET_SECURITY truncated copy
keyctl17: Negative tests for KEYCTL_GET_SECURITY
keyctl18: Test basic KEYCTL_MOVE
keyctl19: Test KEYCTL_MOVE with same source and destination
keyctl20: Test KEYCTL_MOVE displacement
keyctl21: Negative and boundary tests for KEYCTL_MOVE
keyctl22: Test KEYCTL_RESTRICT_KEYRING reject-all
keyctl23: Test KEYCTL_RESTRICT_KEYRING builtin_trusted
keyctl24: Negative tests for KEYCTL_RESTRICT_KEYRING
keyctl25: Test KEYCTL_DH_COMPUTE shared secret computation
keyctl26: Test KEYCTL_DH_COMPUTE size query
keyctl27: Test KEYCTL_DH_COMPUTE KDF key derivation
keyctl28: Negative and boundary tests for KEYCTL_DH_COMPUTE lapi/keyctl.h: Add fallback definitions for public key ops
keyctl29: Test KEYCTL_PKEY_QUERY on public key
keyctl30: Test KEYCTL_PKEY_QUERY on private key
keyctl31: Test KEYCTL_PKEY_ENCRYPT and KEYCTL_PKEY_DECRYPT
keyctl32: Test KEYCTL_PKEY_SIGN and VERIFY
keyctl33: Negative tests for KEYCTL_PKEY_* lapi/keyctl.h: Add capability fallback defines
keyctl34: Test KEYCTL_CAPABILITIES flag retrieval
keyctl35: Test KEYCTL_CAPABILITIES size query
keyctl36: Test KEYCTL_CAPABILITIES buffer sizing
keyctl37: Negative tests for KEYCTL_CAPABILITIES
keyctl38: Test KEYCTL_WATCH_KEY add and remove
keyctl39: Negative tests for KEYCTL_WATCH_KEY
include/lapi/keyctl.h | 102 +++++++++ runtest/syscalls | 30 +++ testcases/kernel/syscalls/keyctl/.gitignore | 30 +++ testcases/kernel/syscalls/keyctl/keyctl10.c | 99 +++++++++ testcases/kernel/syscalls/keyctl/keyctl11.c | 62 ++++++ testcases/kernel/syscalls/keyctl/keyctl12.c | 62 ++++++ testcases/kernel/syscalls/keyctl/keyctl13.c | 46 ++++ testcases/kernel/syscalls/keyctl/keyctl14.c | 54 +++++ testcases/kernel/syscalls/keyctl/keyctl15.c | 66 ++++++ testcases/kernel/syscalls/keyctl/keyctl16.c | 74 ++++++ testcases/kernel/syscalls/keyctl/keyctl17.c | 55 +++++ testcases/kernel/syscalls/keyctl/keyctl18.c | 60 +++++ testcases/kernel/syscalls/keyctl/keyctl19.c | 43 ++++ testcases/kernel/syscalls/keyctl/keyctl20.c | 62 ++++++ testcases/kernel/syscalls/keyctl/keyctl21.c | 111 +++++++++ testcases/kernel/syscalls/keyctl/keyctl22.c | 54 +++++ testcases/kernel/syscalls/keyctl/keyctl23.c | 142 ++++++++++++ testcases/kernel/syscalls/keyctl/keyctl24.c | 173 +++++++++++++++ testcases/kernel/syscalls/keyctl/keyctl25.c | 66 ++++++ testcases/kernel/syscalls/keyctl/keyctl26.c | 53 +++++ testcases/kernel/syscalls/keyctl/keyctl27.c | 78 +++++++ testcases/kernel/syscalls/keyctl/keyctl28.c | 140 ++++++++++++ testcases/kernel/syscalls/keyctl/keyctl29.c | 90 ++++++++ testcases/kernel/syscalls/keyctl/keyctl30.c | 86 +++++++ testcases/kernel/syscalls/keyctl/keyctl31.c | 110 +++++++++ testcases/kernel/syscalls/keyctl/keyctl32.c | 121 ++++++++++ testcases/kernel/syscalls/keyctl/keyctl33.c | 247 +++++++++++++++++++++ testcases/kernel/syscalls/keyctl/keyctl34.c | 62 ++++++ testcases/kernel/syscalls/keyctl/keyctl35.c | 49 ++++ testcases/kernel/syscalls/keyctl/keyctl36.c | 88 ++++++++ testcases/kernel/syscalls/keyctl/keyctl37.c | 63 ++++++ testcases/kernel/syscalls/keyctl/keyctl38.c | 91 ++++++++ testcases/kernel/syscalls/keyctl/keyctl39.c | 149 +++++++++++++ testcases/kernel/syscalls/keyctl/keyctl_common.h | 73 ++++++ testcases/kernel/syscalls/keyctl/keyctl_dh_data.h | 79 +++++++ .../kernel/syscalls/keyctl/keyctl_pkey_data.h | 152 +++++++++++++ 36 files changed, 3122 insertions(+)
---
base-commit: 12724413534a6d4160ff9694ba6f09daa4ccb6bd
change-id: 20260831-keyctl_coverage-345a4c4d7992
Best regards,
Signature · 5 lines
Andrea Cervesato <[email protected]> -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 1/33 lapi/keyctl.h: Add fallback definitions for extended ops
From: Andrea Cervesato <[email protected]>
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.
--- include/lapi/keyctl.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
include/lapi/keyctl.h +31 -0
@@ -20,6 +20,21 @@# include "lapi/syscalls.h" typedef int32_t key_serial_t ; +#if !defined(HAVE_KEYUTILS_H ) && !defined(HAVE_LINUX_KEYCTL_H ) +struct keyctl_dh_params { +int32_t priv; +int32_t prime; +int32_t base; +}; + +struct keyctl_kdf_params { +char *hashname; +char *otherinfo; +uint32_t otherinfolen; +uint32_t __spare[8 ]; +}; +#endif + static inline key_serial_t add_key(const char *type, const char *description, const void *payload,
@@ -124,6 +139,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 +187,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
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 2/33 keyctl10: Test KEYCTL_DESCRIBE format parsing
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Test the format parsing of KEYCTL_DESCRIBE: verify that describing a valid key returns a string formatted as "type;uid;gid;perm;description" and that all five fields match the key's attributes.
Also add keyctl_common.h helper header for shared test definitions.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/keyctl/.gitignore | 1 + testcases/kernel/syscalls/keyctl/keyctl10.c | 99 ++++++++++++++++++++++++ testcases/kernel/syscalls/keyctl/keyctl_common.h | 53 +++++++++++++ 4 files changed, 154 insertions(+)
runtest/syscalls +1 -0
@@ -727,6 +727,7 @@ keyctl06 keyctl06 keyctl07 keyctl07 keyctl08 keyctl08 keyctl09 keyctl09 +keyctl10 keyctl10 kcmp01 kcmp01 kcmp02 kcmp02
testcases/kernel/syscalls/keyctl/.gitignore +1 -0
@@ -7,3 +7,4 @@ /keyctl07 /keyctl08 /keyctl09 +/keyctl10
testcases/kernel/syscalls/keyctl/keyctl10.c new file +99 -0
99 lines not on this page · raw message
testcases/kernel/syscalls/keyctl/keyctl_common.h new file +53 -0
53 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] lapi/keyctl.h: Add fallback definitions for extended ops
Hi Andrea,
Quoted 1 line · Andrea Cervesato
lapi/keyctl.h: Add fallback definitions for extended ops
--- [PATCH 1/33] ---
Review
Quoted 2 lines
(quoted diff) +2
-0+#if !defined(HAVE_KEYUTILS_H) && !defined(HAVE_LINUX_KEYCTL_H) +struct keyctl_dh_params {
This block sits in the #else branch of "defined(HAVE_KEYUTILS_H) && defined(HAVE_LIBKEYUTILS)", so <keyutils.h> is never included on this path and only <linux/keyctl.h> can declare the structs. With keyutils.h present (HAVE_KEYUTILS_H, configure.ac:59) but libkeyutils not linkable (m4/ltp-keyutils.m4) and linux/keyctl.h absent, the guard is false and nothing declares keyctl_dh_params / keyctl_kdf_params, breaking keyctl25..keyctl28. Use
"#ifndef HAVE_LINUX_KEYCTL_H". The same guard is reused for keyctl_pkey_query / keyctl_pkey_params in patch 21/33.
Review
Quoted 3 lines
(quoted diff) +3
-0+#ifndef KEYCTL_RESTRICT_KEYRING +# define KEYCTL_RESTRICT_KEYRING 29 +#endif
Commands 29 and 30 are appended after KEYCTL_WATCH_KEY (32), and patches 21/33 and 27/33 then insert 24..28 and 31 after those. The rest of the list is in ascending command order.
--- [PATCH 2/33] ---
testcases/kernel/syscalls/keyctl/keyctl10.c line 44
Quoted 5 lines
testcases/kernel/syscalls/keyctl/keyctl10.c new file +5
-0+TEST (keyctl (KEYCTL_DESCRIBE , key, (unsigned long )NULL ,0 ,0 )); +if (TST_RET <0 ) +tst_brk (TBROK |TTERRNO ,"KEYCTL_DESCRIBE failed" ); + + desc_len =TST_RET ;
safe_keyctl() already treats a negative KEYCTL_DESCRIBE return as a failure, and the previous line in the same function uses SAFE_KEYCTL(). This is a setup precondition, not the tested call, so the "subject syscall" exception does not apply:
desc_len = SAFE_KEYCTL(KEYCTL_DESCRIBE, key, 0, 0, 0);
Same in keyctl11, keyctl12, keyctl16, keyctl34, keyctl35 and keyctl36.
testcases/kernel/syscalls/keyctl/keyctl10.c line 73
Quoted 4 lines
testcases/kernel/syscalls/keyctl/keyctl10.c new file +4
-0+if (strcmp (type,"user" )) { +tst_res (TFAIL ,"wrong key type '%s', expected 'user'" , type); +return ; + }
Use TST_EXP_EQ_STR(type, "user") instead of strcmp() + tst_res(). Same for the strcmp() against KEY_DESC below.
--- [PATCH 3/33] ---
testcases/kernel/syscalls/keyctl/keyctl10.c
Quoted 8 lines
testcases/kernel/syscalls/keyctl/keyctl10.c new file +8
-0+memset (buf,0 , desc_len); +TST_EXP_EQ_LI_SILENT (keyctl (KEYCTL_DESCRIBE , key, (unsigned long )buf, + desc_len,0 ), desc_len); +if (!TST_PASS ) +return ; + +if (buf[desc_len -1 ] !='\0' ) { +tst_res (TFAIL ,"description is not NUL terminated" );
buf is zeroed immediately before the call, so buf[desc_len - 1] is already '\0' and this check cannot fail even if the kernel copied nothing. Nothing verifies the content either. Poison the buffer (memset(buf, 'x', desc_len)) and assert
strlen(buf) + 1 == (size_t)desc_len, as keyctl12 already does with 0xAA.
Review
Quoted 2 lines
(quoted diff) +2
-0+ TST_EXP_EQ_LI_SILENT(keyctl(KEYCTL_DESCRIBE, key, (unsigned long)buf, + desc_len, 0), desc_len);
TST_EXP_EQ_*() compare two plain values and do not go through TEST(), so errno is lost on failure. For syscall return values use TST_EXP_VAL()/TST_EXP_VAL_SILENT(), or TST_EXP_PASS()/ TST_EXP_PASS_SILENT() when 0 is expected. Recurs in keyctl12, keyctl16, keyctl18, keyctl19, keyctl20, keyctl25, keyctl27 and keyctl29..keyctl36.
--- [PATCH 7/33] ---
Quoted 3 lines
testcases/kernel/syscalls/keyctl/keyctl10.c new file +3
-0+memset (buf,0 ,sizeof (buf)); + +TEST (keyctl (KEYCTL_GET_SECURITY , key, (unsigned long )buf,sizeof (buf),0 ));
...
Quoted 3 lines
(quoted diff) +3
-0+ if (TST_RET == 1) { + if (buf[0] != '\0') { + tst_res(TFAIL, "empty label is not NUL terminated");
...
Review
Quoted 1 line
(quoted diff) +1
-0+ tst_res(TPASS, "security label returned, full length %ld", TST_RET);
Same tautology as keyctl11: buf is zeroed first, so buf[0] == '\0' always holds. The TST_RET > 1 branch reports TPASS without inspecting buf at all. Poison buf and assert strlen(buf) + 1 == (size_t)TST_RET whenever TST_RET <= sizeof(buf); that covers both branches.
--- [PATCH 14/33] ---
Review
Quoted 5 lines
(quoted diff) +5
-0+ TEST(keyctl(KEYCTL_RESTRICT_KEYRING, ring_reject, 0, 0, 0)); + if (TST_RET == 0) + tst_res(TPASS, "KEYCTL_RESTRICT_KEYRING with NULL type and restriction passed"); + else if (TST_RET == -1 && TST_ERR == EEXIST) + tst_res(TPASS, "KEYCTL_RESTRICT_KEYRING reject-all already active");
Restricting a keyring is one-shot (keyring_restrict() returns -EEXIST once restrict_link is set), so this branch only exists to survive -i N, but it also accepts EEXIST on the first iteration where the keyring has never been restricted. Move the restriction into setup(), which the framework calls once, and keep run() to the EPERM assertions. Same pattern in keyctl23.
--- [PATCH 15/33] ---
Review
Quoted 6 lines
(quoted diff) +6
-0+ TST_EXP_FAIL(keyctl(KEYCTL_LINK, user_key, ring_builtin, 0, 0), + EOPNOTSUPP, + "KEYCTL_LINK of non-asymmetric key on builtin_trusted restricted keyring"); + + TST_EXP_FAIL2(add_key("asymmetric", "cert", untrusted_cert, + sizeof(untrusted_cert), ring_builtin), ENOKEY,
EOPNOTSUPP and ENOKEY come from restrict_link_by_signature(), which is only reachable with CONFIG_SYSTEM_TRUSTED_KEYRING=y. Without it, include/keys/system_keyring.h does
"#define restrict_link_by_builtin_trusted restrict_link_reject", both calls return EPERM and the test reports two TFAILs instead of skipping. The restriction still installs in that configuration, so the existing EOPNOTSUPP TCONF branch never fires. Add:
.needs_kconfigs = (const char *[]) {
"CONFIG_SYSTEM_TRUSTED_KEYRING=y",
NULL
},Note certs/Kconfig makes SYSTEM_TRUSTED_KEYRING depend on X509_CERTIFICATE_PARSER=y, so whenever modprobe actually loads x509_key_parser as a module the option is off and the test always fails.
Review
Quoted 3 lines
(quoted diff) +3
-0+ TEST(keyctl(KEYCTL_RESTRICT_KEYRING, ring_builtin, + (unsigned long)"asymmetric", (unsigned long)"bogus", 0)); + asym_supported = (TST_RET != -1 || TST_ERR != ENODEV);
KEYCTL_RESTRICT_KEYRING resolves the type through keyring_restrict() -> key_type_lookup(), which returns ENOKEY for an unregistered type; ENODEV is what add_key() returns (security/keys/key.c:830), as add_asymmetric_key_or_tconf() correctly assumes in patch 22/33. With a registered type the probe gets EINVAL from "bogus", so asym_supported is always 1 and the TCONF branch is dead code. Compare against ENOKEY.
--- [PATCH 16/33] ---
Review
Quoted 1 line
(quoted diff) +1
-0+ asym_supported = (TST_RET != -1 || TST_ERR != ENODEV);
Same wrong errno as keyctl23. Here the dead TCONF branch also turns two tcases into spurious TFAILs on a kernel without CONFIG_ASYMMETRIC_KEY_TYPE:
"asymmetric with invalid restriction string" expects EINVAL and "self-referencing key_or_keyring chain" expects EDEADLK, but both receive ENOKEY.
Review
Quoted 1 line
(quoted diff) +1
-0+ keyctl(KEYCTL_UNLINK, probe_ring, KEY_SPEC_PROCESS_KEYRING, 0, 0);
These housekeeping unlinks are not the tested call and must succeed. Use SAFE_KEYCTL(); as written a failure is silently discarded. Same for the fresh_ring unlink in verify_negative().
--- [PATCH 17/33] ---
Review
Quoted 3 lines
(quoted diff) +3
-0+/* RFC 7919 2048-bit FFDHE Group parameters (ffdhe2048) */ +static const unsigned char dh_prime[] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc9, 0x0f, 0xda, 0xa2, 0x21, 0x68, 0xc2, 0x34,
This prime is the RFC 3526 2048-bit MODP group (Group 14 / modp2048), not RFC 7919 ffdhe2048 - ffdhe2048 continues 0xad 0xf8 0x54 0x58 after the leading 0xff bytes. The commit message repeats the claim. The vector itself is correct: pow(dh_base, dh_priv, dh_prime) reproduces dh_expected_secret byte for byte. The header is reused by keyctl26..keyctl28, so fix the comment and the commit message.
--- [PATCH 28/33] ---
Review
Quoted 3 lines
(quoted diff) +3
-0+ TEST(keyctl(KEYCTL_CAPABILITIES, (unsigned long)caps, sizeof(caps), 0, 0)); + if (TST_RET < 0) + tst_brk(TBROK | TTERRNO, "KEYCTL_CAPABILITIES failed");
Patch 27/33 adds "case KEYCTL_CAPABILITIES" to safe_keyctl(), and patch 21/33 adds the five KEYCTL_PKEY_* cases, but no test in the series ever calls SAFE_KEYCTL() with any of them. Either use SAFE_KEYCTL() here and in keyctl35/keyctl36, or drop the unused cases.
--- [PATCH 32/33] ---
Review
Quoted 4 lines
(quoted diff) +4
-0+ .ulimit = (const struct tst_ulimit_val []) { + {RLIMIT_NOFILE, 524288}, + {} + },
set_ulimit_() (lib/tst_test.c:1330) raises rlim_max when rlim_cur exceeds it, which needs CAP_SYS_RESOURCE, and safe_setrlimit() aborts with TBROK | TERRNO on failure. The test does not set .needs_root, so on any host whose hard RLIMIT_NOFILE is below 524288 an unprivileged run ends in TBROK before a single assertion runs - reproduced here with a hard limit of 65536, where the same getrlimit/setrlimit sequence returns EPERM. The test holds one watch at a time, so the default soft limit already suffices; keyctl39 exercises the same code with no .ulimit at all.
Review
Quoted 2 lines
(quoted diff) +2
-0+ TST_EXP_PASS(keyctl(KEYCTL_WATCH_KEY, key, pipefd[0], 1), + "KEYCTL_WATCH_KEY add watch on key");
The keyctl() helper in lapi/keyctl.h unconditionally reads four variadic arguments (arg2..arg5); only three are passed here, which is undefined behaviour. Append an explicit 0, as every other call site in this series does. Same in keyctl39.
Review
Quoted 4 lines
(quoted diff) +4
-0+ TEST(pipe2(pipefd, O_NOTIFICATION_PIPE)); + if (TST_RET < 0) { + if (TST_ERR == ENOPKG) + tst_brk(TCONF | TTERRNO, "CONFIG_WATCH_QUEUE is not set");
This block plus the IOC_WATCH_QUEUE_SET_SIZE call duplicates wqueue_watch() in testcases/kernel/watchqueue/common.h:100-116.
Verdict - Needs revision
Pre-existing issues:
include/lapi/keyctl.h already fails checkpatch on master with one ERROR ("open brace '{' following function definitions go on the next line", keyctl_join_session_keyring()) and two CHECKs (multiple blank lines, missing blank line after a declaration).
---
Note:
The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 3/33 keyctl11: Test KEYCTL_DESCRIBE with exact buffer size
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Test KEYCTL_DESCRIBE when called with a buffer sized exactly to the full description length: verify the string is copied completely including the terminating NUL byte.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/keyctl/.gitignore | 1 + testcases/kernel/syscalls/keyctl/keyctl11.c | 62 +++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+)
runtest/syscalls +1 -0
@@ -728,6 +728,7 @@ keyctl07 keyctl07 keyctl08 keyctl08 keyctl09 keyctl09 keyctl10 keyctl10 +keyctl11 keyctl11 kcmp01 kcmp01 kcmp02 kcmp02
testcases/kernel/syscalls/keyctl/.gitignore +1 -0
@@ -8,3 +8,4 @@ /keyctl08 /keyctl09 /keyctl10 +/keyctl11
testcases/kernel/syscalls/keyctl/keyctl11.c new file +62 -0
62 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 4/33 keyctl12: Test KEYCTL_DESCRIBE with too small buffer
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Test KEYCTL_DESCRIBE when called with a buffer smaller than the full description length: verify the buffer is left untouched and the return value still reports the full length.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/keyctl/.gitignore | 1 + testcases/kernel/syscalls/keyctl/keyctl12.c | 62 +++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+)
runtest/syscalls +1 -0
@@ -729,6 +729,7 @@ keyctl08 keyctl08 keyctl09 keyctl09 keyctl10 keyctl10 keyctl11 keyctl11 +keyctl12 keyctl12 kcmp01 kcmp01 kcmp02 kcmp02
testcases/kernel/syscalls/keyctl/.gitignore +1 -0
@@ -9,3 +9,4 @@ /keyctl09 /keyctl10 /keyctl11 +/keyctl12
testcases/kernel/syscalls/keyctl/keyctl12.c new file +62 -0
62 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 5/33 keyctl13: Test KEYCTL_DESCRIBE size query
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Test KEYCTL_DESCRIBE when called with a NULL buffer and buflen 0:
verify the call succeeds and returns the full description length without writing to userspace memory.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/keyctl/.gitignore | 1 + testcases/kernel/syscalls/keyctl/keyctl13.c | 46 +++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+)
runtest/syscalls +1 -0
@@ -730,6 +730,7 @@ keyctl09 keyctl09 keyctl10 keyctl10 keyctl11 keyctl11 keyctl12 keyctl12 +keyctl13 keyctl13 kcmp01 kcmp01 kcmp02 kcmp02
testcases/kernel/syscalls/keyctl/.gitignore +1 -0
@@ -10,3 +10,4 @@ /keyctl10 /keyctl11 /keyctl12 +/keyctl13
testcases/kernel/syscalls/keyctl/keyctl13.c new file +46 -0
46 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 6/33 keyctl14: Negative tests for KEYCTL_DESCRIBE
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Test error conditions of KEYCTL_DESCRIBE using a parameterized tcase table: verify ENOKEY on a bogus key id and EACCES when View permission is missing.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/keyctl/.gitignore | 1 + testcases/kernel/syscalls/keyctl/keyctl14.c | 54 +++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+)
runtest/syscalls +1 -0
@@ -731,6 +731,7 @@ keyctl10 keyctl10 keyctl11 keyctl11 keyctl12 keyctl12 keyctl13 keyctl13 +keyctl14 keyctl14 kcmp01 kcmp01 kcmp02 kcmp02
testcases/kernel/syscalls/keyctl/.gitignore +1 -0
@@ -11,3 +11,4 @@ /keyctl11 /keyctl12 /keyctl13 +/keyctl14
testcases/kernel/syscalls/keyctl/keyctl14.c new file +54 -0
54 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 7/33 keyctl15: Test KEYCTL_GET_SECURITY label retrieval
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Test KEYCTL_GET_SECURITY label retrieval: verify reading the security label of a valid key into a large buffer returns a positive length and an empty string when no LSM label is set.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/keyctl/.gitignore | 1 + testcases/kernel/syscalls/keyctl/keyctl15.c | 66 +++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+)
runtest/syscalls +1 -0
@@ -732,6 +732,7 @@ keyctl11 keyctl11 keyctl12 keyctl12 keyctl13 keyctl13 keyctl14 keyctl14 +keyctl15 keyctl15 kcmp01 kcmp01 kcmp02 kcmp02
testcases/kernel/syscalls/keyctl/.gitignore +1 -0
@@ -12,3 +12,4 @@ /keyctl12 /keyctl13 /keyctl14 +/keyctl15
testcases/kernel/syscalls/keyctl/keyctl15.c new file +66 -0
66 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 8/33 keyctl16: Test KEYCTL_GET_SECURITY truncated copy
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Test KEYCTL_GET_SECURITY truncated copy behavior: verify that calling with a 1-byte buffer receives exactly one byte while the return value still reports the full label length.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/keyctl/.gitignore | 1 + testcases/kernel/syscalls/keyctl/keyctl16.c | 74 +++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+)
runtest/syscalls +1 -0
@@ -733,6 +733,7 @@ keyctl12 keyctl12 keyctl13 keyctl13 keyctl14 keyctl14 keyctl15 keyctl15 +keyctl16 keyctl16 kcmp01 kcmp01 kcmp02 kcmp02
testcases/kernel/syscalls/keyctl/.gitignore +1 -0
@@ -13,3 +13,4 @@ /keyctl13 /keyctl14 /keyctl15 +/keyctl16
testcases/kernel/syscalls/keyctl/keyctl16.c new file +74 -0
74 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 9/33 keyctl17: Negative tests for KEYCTL_GET_SECURITY
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Test error conditions of KEYCTL_GET_SECURITY using a parameterized tcase table: verify ENOKEY on a bogus key id and ENOKEY when View permission is missing (due to the kernel request-key auth token fallback path).
--- runtest/syscalls | 1 + testcases/kernel/syscalls/keyctl/.gitignore | 1 + testcases/kernel/syscalls/keyctl/keyctl17.c | 55 +++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+)
runtest/syscalls +1 -0
@@ -734,6 +734,7 @@ keyctl13 keyctl13 keyctl14 keyctl14 keyctl15 keyctl15 keyctl16 keyctl16 +keyctl17 keyctl17 kcmp01 kcmp01 kcmp02 kcmp02
testcases/kernel/syscalls/keyctl/.gitignore +1 -0
@@ -14,3 +14,4 @@ /keyctl14 /keyctl15 /keyctl16 +/keyctl17
testcases/kernel/syscalls/keyctl/keyctl17.c new file +55 -0
55 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 10/33 keyctl18: Test basic KEYCTL_MOVE
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Test basic moving of a key between two keyrings with KEYCTL_MOVE:
verify the key is moved to the destination and no longer found in the source keyring.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/keyctl/.gitignore | 1 + testcases/kernel/syscalls/keyctl/keyctl18.c | 60 +++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+)
runtest/syscalls +1 -0
@@ -735,6 +735,7 @@ keyctl14 keyctl14 keyctl15 keyctl15 keyctl16 keyctl16 keyctl17 keyctl17 +keyctl18 keyctl18 kcmp01 kcmp01 kcmp02 kcmp02
testcases/kernel/syscalls/keyctl/.gitignore +1 -0
@@ -15,3 +15,4 @@ /keyctl15 /keyctl16 /keyctl17 +/keyctl18
testcases/kernel/syscalls/keyctl/keyctl18.c new file +60 -0
60 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 11/33 keyctl19: Test KEYCTL_MOVE with same source and destination
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Test KEYCTL_MOVE when the source keyring equals the destination
keyring: verify the operation succeeds as a no-op and the key remains linked in the keyring.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/keyctl/.gitignore | 1 + testcases/kernel/syscalls/keyctl/keyctl19.c | 43 +++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+)
runtest/syscalls +1 -0
@@ -736,6 +736,7 @@ keyctl15 keyctl15 keyctl16 keyctl16 keyctl17 keyctl17 keyctl18 keyctl18 +keyctl19 keyctl19 kcmp01 kcmp01 kcmp02 kcmp02
testcases/kernel/syscalls/keyctl/.gitignore +1 -0
@@ -16,3 +16,4 @@ /keyctl16 /keyctl17 /keyctl18 +/keyctl19
testcases/kernel/syscalls/keyctl/keyctl19.c new file +43 -0
43 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 12/33 keyctl20: Test KEYCTL_MOVE displacement
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Test KEYCTL_MOVE displacement behavior: verify moving a key without KEYCTL_MOVE_EXCL into a destination holding a matching key displaces the existing key.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/keyctl/.gitignore | 1 + testcases/kernel/syscalls/keyctl/keyctl20.c | 62 +++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+)
runtest/syscalls +1 -0
@@ -737,6 +737,7 @@ keyctl16 keyctl16 keyctl17 keyctl17 keyctl18 keyctl18 keyctl19 keyctl19 +keyctl20 keyctl20 kcmp01 kcmp01 kcmp02 kcmp02
testcases/kernel/syscalls/keyctl/.gitignore +1 -0
@@ -17,3 +17,4 @@ /keyctl17 /keyctl18 /keyctl19 +/keyctl20
testcases/kernel/syscalls/keyctl/keyctl20.c new file +62 -0
62 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 13/33 keyctl21: Negative and boundary tests for KEYCTL_MOVE
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Test error and boundary conditions of KEYCTL_MOVE using a parameterized tcase table: KEYCTL_MOVE_EXCL (EEXIST), unknown flag bits (EINVAL), bogus IDs (ENOKEY), non-keyrings (ENOTDIR), unlinked key (ENOENT), keyring cycle (EDEADLK), and destination without Write permission (EACCES).
--- runtest/syscalls | 1 + testcases/kernel/syscalls/keyctl/.gitignore | 1 + testcases/kernel/syscalls/keyctl/keyctl21.c | 111 ++++++++++++++++++++++++++++ 3 files changed, 113 insertions(+)
runtest/syscalls +1 -0
@@ -738,6 +738,7 @@ keyctl17 keyctl17 keyctl18 keyctl18 keyctl19 keyctl19 keyctl20 keyctl20 +keyctl21 keyctl21 kcmp01 kcmp01 kcmp02 kcmp02
testcases/kernel/syscalls/keyctl/.gitignore +1 -0
@@ -18,3 +18,4 @@ /keyctl18 /keyctl19 /keyctl20 +/keyctl21
testcases/kernel/syscalls/keyctl/keyctl21.c new file +111 -0
111 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 14/33 keyctl22: Test KEYCTL_RESTRICT_KEYRING reject-all
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Test KEYCTL_RESTRICT_KEYRING reject-all restriction: verify that restricting a keyring with NULL type and NULL restriction succeeds, and subsequent link and add_key attempts fail with EPERM.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/keyctl/.gitignore | 1 + testcases/kernel/syscalls/keyctl/keyctl22.c | 54 +++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+)
runtest/syscalls +1 -0
@@ -739,6 +739,7 @@ keyctl18 keyctl18 keyctl19 keyctl19 keyctl20 keyctl20 keyctl21 keyctl21 +keyctl22 keyctl22 kcmp01 kcmp01 kcmp02 kcmp02
testcases/kernel/syscalls/keyctl/.gitignore +1 -0
@@ -19,3 +19,4 @@ /keyctl19 /keyctl20 /keyctl21 +/keyctl22
testcases/kernel/syscalls/keyctl/keyctl22.c new file +54 -0
54 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 15/33 keyctl23: Test KEYCTL_RESTRICT_KEYRING builtin_trusted
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Test KEYCTL_RESTRICT_KEYRING builtin_trusted restriction: verify that restricting a keyring with asymmetric builtin_trusted allows only trusted asymmetric keys, rejecting user keys with EOPNOTSUPP and untrusted certs with ENOKEY.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/keyctl/.gitignore | 1 + testcases/kernel/syscalls/keyctl/keyctl23.c | 142 ++++++++++++++++++++++++++++ 3 files changed, 144 insertions(+)
runtest/syscalls +1 -0
@@ -740,6 +740,7 @@ keyctl19 keyctl19 keyctl20 keyctl20 keyctl21 keyctl21 keyctl22 keyctl22 +keyctl23 keyctl23 kcmp01 kcmp01 kcmp02 kcmp02
testcases/kernel/syscalls/keyctl/.gitignore +1 -0
@@ -20,3 +20,4 @@ /keyctl20 /keyctl21 /keyctl22 +/keyctl23
testcases/kernel/syscalls/keyctl/keyctl23.c new file +142 -0
142 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 16/33 keyctl24: Negative tests for KEYCTL_RESTRICT_KEYRING
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Test error conditions of KEYCTL_RESTRICT_KEYRING using a parameterized tcase table: invalid type/restriction combinations (EINVAL), non-keyrings (ENOTDIR), unknown key type (ENOKEY), key type without lookup (ENOENT), invalid restriction string (EINVAL), bogus key serial (ENOKEY), already restricted (EEXIST), self-chain cycle (EDEADLK), and missing Setattr (EACCES).
--- runtest/syscalls | 1 + testcases/kernel/syscalls/keyctl/.gitignore | 1 + testcases/kernel/syscalls/keyctl/keyctl24.c | 173 ++++++++++++++++++++++++++++ 3 files changed, 175 insertions(+)
runtest/syscalls +1 -0
@@ -741,6 +741,7 @@ keyctl20 keyctl20 keyctl21 keyctl21 keyctl22 keyctl22 keyctl23 keyctl23 +keyctl24 keyctl24 kcmp01 kcmp01 kcmp02 kcmp02
testcases/kernel/syscalls/keyctl/.gitignore +1 -0
@@ -21,3 +21,4 @@ /keyctl21 /keyctl22 /keyctl23 +/keyctl24
testcases/kernel/syscalls/keyctl/keyctl24.c new file +173 -0
173 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 17/33 keyctl25: Test KEYCTL_DH_COMPUTE shared secret computation
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Test KEYCTL_DH_COMPUTE shared secret computation: verify that computing a 256-byte DH shared secret with RFC 7919 FFDHE-2048 parameters matches the precomputed mathematical value.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/keyctl/.gitignore | 1 + testcases/kernel/syscalls/keyctl/keyctl25.c | 66 ++++++++++++++++++++ testcases/kernel/syscalls/keyctl/keyctl_dh_data.h | 74 +++++++++++++++++++++++ 4 files changed, 142 insertions(+)
runtest/syscalls +1 -0
@@ -742,6 +742,7 @@ keyctl21 keyctl21 keyctl22 keyctl22 keyctl23 keyctl23 keyctl24 keyctl24 +keyctl25 keyctl25 kcmp01 kcmp01 kcmp02 kcmp02
testcases/kernel/syscalls/keyctl/.gitignore +1 -0
@@ -22,3 +22,4 @@ /keyctl22 /keyctl23 /keyctl24 +/keyctl25
testcases/kernel/syscalls/keyctl/keyctl25.c new file +66 -0
66 lines not on this page · raw message
testcases/kernel/syscalls/keyctl/keyctl_dh_data.h new file +74 -0
74 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 18/33 keyctl26: Test KEYCTL_DH_COMPUTE size query
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Test KEYCTL_DH_COMPUTE buffer size query: verify that calling with buflen 0 returns the required output buffer size (256) without writing to userspace.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/keyctl/.gitignore | 1 + testcases/kernel/syscalls/keyctl/keyctl26.c | 53 +++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+)
runtest/syscalls +1 -0
@@ -743,6 +743,7 @@ keyctl22 keyctl22 keyctl23 keyctl23 keyctl24 keyctl24 keyctl25 keyctl25 +keyctl26 keyctl26 kcmp01 kcmp01 kcmp02 kcmp02
testcases/kernel/syscalls/keyctl/.gitignore +1 -0
@@ -23,3 +23,4 @@ /keyctl23 /keyctl24 /keyctl25 +/keyctl26
testcases/kernel/syscalls/keyctl/keyctl26.c new file +53 -0
53 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 19/33 keyctl27: Test KEYCTL_DH_COMPUTE KDF key derivation
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Test KEYCTL_DH_COMPUTE SP800-56A KDF key derivation: verify that deriving a key using SHA-256 and otherinfo matches the precomputed mathematical test vector.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/keyctl/.gitignore | 1 + testcases/kernel/syscalls/keyctl/keyctl27.c | 78 +++++++++++++++++++++++ testcases/kernel/syscalls/keyctl/keyctl_dh_data.h | 5 ++ 4 files changed, 85 insertions(+)
runtest/syscalls +1 -0
@@ -744,6 +744,7 @@ keyctl23 keyctl23 keyctl24 keyctl24 keyctl25 keyctl25 keyctl26 keyctl26 +keyctl27 keyctl27 kcmp01 kcmp01 kcmp02 kcmp02
testcases/kernel/syscalls/keyctl/.gitignore +1 -0
@@ -24,3 +24,4 @@ /keyctl24 /keyctl25 /keyctl26 +/keyctl27
testcases/kernel/syscalls/keyctl/keyctl27.c new file +78 -0
78 lines not on this page · raw message
testcases/kernel/syscalls/keyctl/keyctl_dh_data.h +5 -0
@@ -71,4 +71,9 @@ static const unsigned char dh_expected_secret[] = { 0xfb, 0xeb, 0xdd, 0x18, 0x54, 0x0d, 0x4c, 0xa7, 0x65, 0xc1, 0x0c, 0x11, 0xad, 0xea, 0x83, 0x9f, }; +static const unsigned char dh_kdf_expected[] = { +0x66 ,0x39 ,0xec ,0x41 ,0x31 ,0x33 ,0xe6 ,0xc0 ,0x61 ,0x67 ,0x28 ,0x51 ,0x61 ,0xf7 ,0x8c ,0xd7 , +0xc0 ,0x55 ,0xc9 ,0xcc ,0x83 ,0x46 ,0xf3 ,0xaa ,0x62 ,0xed ,0xca ,0x90 ,0x99 ,0x2d ,0xc4 ,0x07 , +}; +#endif /* KEYCTL_DH_DATA_H__ */
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 20/33 keyctl28: Negative and boundary tests for KEYCTL_DH_COMPUTE
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Test error and boundary conditions of KEYCTL_DH_COMPUTE using a parameterized tcase table: buffer smaller than secret (EOVERFLOW), bogus prime key (ENOKEY), non-user key (EOPNOTSUPP), NULL buffer (EINVAL), non-zero __spare (EINVAL), buflen > 1024 (EMSGSIZE), otherinfolen > 64 (EMSGSIZE), and unknown KDF hash name (ENOENT).
--- runtest/syscalls | 1 + testcases/kernel/syscalls/keyctl/.gitignore | 1 + testcases/kernel/syscalls/keyctl/keyctl28.c | 140 ++++++++++++++++++++++++++++ 3 files changed, 142 insertions(+)
runtest/syscalls +1 -0
@@ -745,6 +745,7 @@ keyctl24 keyctl24 keyctl25 keyctl25 keyctl26 keyctl26 keyctl27 keyctl27 +keyctl28 keyctl28 kcmp01 kcmp01 kcmp02 kcmp02
testcases/kernel/syscalls/keyctl/.gitignore +1 -0
@@ -25,3 +25,4 @@ /keyctl25 /keyctl26 /keyctl27 +/keyctl28
testcases/kernel/syscalls/keyctl/keyctl28.c new file +140 -0
140 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 21/33 lapi/keyctl.h: Add fallback definitions for public key ops
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Add fallback definitions for KEYCTL_PKEY_QUERY, KEYCTL_PKEY_ENCRYPT, KEYCTL_PKEY_DECRYPT, KEYCTL_PKEY_SIGN, KEYCTL_PKEY_VERIFY, and KEYCTL_SUPPORTS_*, as well as fallback structs keyctl_pkey_query and keyctl_pkey_params when built without keyutils.h or linux/keyctl.h.
--- include/lapi/keyctl.h | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)
include/lapi/keyctl.h +52 -0
@@ -33,6 +33,26 @@ struct keyctl_kdf_params {uint32_t otherinfolen;uint32_t __spare[8 ]; }; + +struct keyctl_pkey_query { +uint32_t supported_ops; +uint32_t key_size; +uint16_t max_data_size; +uint16_t max_sig_size; +uint16_t max_enc_size; +uint16_t max_dec_size; +uint32_t __spare[10 ]; +}; + +struct keyctl_pkey_params { +int32_t key_id; +uint32_t in_len; +union { +uint32_t out_len; +uint32_t in2_len; + }; +uint32_t __spare[7 ]; +};#endif static inline key_serial_t add_key(const char *type,
@@ -199,6 +219,33 @@ static inline key_serial_t keyctl_join_session_keyring(const char *name) {# define KEYCTL_MOVE_EXCL 0x00000001/* do not displace from the to-keyring */ #endif +#ifndef KEYCTL_PKEY_QUERY +# define KEYCTL_PKEY_QUERY 24 +#endif + +#ifndef KEYCTL_PKEY_ENCRYPT +# define KEYCTL_PKEY_ENCRYPT 25 +#endif + +#ifndef KEYCTL_PKEY_DECRYPT +# define KEYCTL_PKEY_DECRYPT 26 +#endif + +#ifndef KEYCTL_PKEY_SIGN +# define KEYCTL_PKEY_SIGN 27 +#endif + +#ifndef KEYCTL_PKEY_VERIFY +# define KEYCTL_PKEY_VERIFY 28 +#endif + +#ifndef KEYCTL_SUPPORTS_ENCRYPT +# define KEYCTL_SUPPORTS_ENCRYPT 0x01 +# define KEYCTL_SUPPORTS_DECRYPT 0x02 +# define KEYCTL_SUPPORTS_SIGN 0x04 +# define KEYCTL_SUPPORTS_VERIFY 0x08 +#endif +/* key permissions */ #ifndef KEY_POS_VIEW # define KEY_POS_VIEW 0x01000000
@@ -259,6 +306,11 @@ static inline long safe_keyctl(const char *file, const int lineno,case KEYCTL_GET_SECURITY :case KEYCTL_GET_PERSISTENT :case KEYCTL_DH_COMPUTE : +case KEYCTL_PKEY_QUERY : +case KEYCTL_PKEY_ENCRYPT : +case KEYCTL_PKEY_DECRYPT : +case KEYCTL_PKEY_SIGN : +case KEYCTL_PKEY_VERIFY :if (rval <0 ) failure =1 ;break ;
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 22/33 keyctl29: Test KEYCTL_PKEY_QUERY on public key
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Test KEYCTL_PKEY_QUERY operation on an RSA-2048 X.509 public key
certificate: verify key_size is 2048, supported_ops contains ENCRYPT and VERIFY, and max_enc_size/max_sig_size are 256.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/keyctl/.gitignore | 1 + testcases/kernel/syscalls/keyctl/keyctl29.c | 90 ++++++++++++++++++++++ testcases/kernel/syscalls/keyctl/keyctl_common.h | 20 +++++ .../kernel/syscalls/keyctl/keyctl_pkey_data.h | 68 ++++++++++++++++ 5 files changed, 180 insertions(+)
runtest/syscalls +1 -0
@@ -746,6 +746,7 @@ keyctl25 keyctl25 keyctl26 keyctl26 keyctl27 keyctl27 keyctl28 keyctl28 +keyctl29 keyctl29 kcmp01 kcmp01 kcmp02 kcmp02
testcases/kernel/syscalls/keyctl/.gitignore +1 -0
@@ -26,3 +26,4 @@ /keyctl26 /keyctl27 /keyctl28 +/keyctl29
testcases/kernel/syscalls/keyctl/keyctl29.c new file +90 -0
90 lines not on this page · raw message
testcases/kernel/syscalls/keyctl/keyctl_common.h +20 -0
@@ -50,4 +50,24 @@ static inline key_serial_t search_ring(key_serial_t ring, const char *type, (unsigned long)desc, 0); } +static inline key_serial_t add_asymmetric_key_or_tconf (const char *desc, +const void *payload, +size_t plen, +const char *parser_kconfig) +{ +TEST (add_key ("asymmetric" , desc, payload, plen,KEY_SPEC_PROCESS_KEYRING )); +if (TST_RET >=0 ) +return TST_RET ; + +if (TST_ERR ==ENODEV ) +tst_brk (TCONF ,"kernel does not support asymmetric keys" ); +if (TST_ERR ==EBADMSG ) +tst_brk (TCONF ,"missing asymmetric parser (%s)" , parser_kconfig); +if (TST_ERR ==ENOENT ) +tst_brk (TCONF ,"missing crypto RSA / SHA256 algorithms" ); + +tst_brk (TBROK |TTERRNO ,"failed to add asymmetric key '%s'" , desc); +return -1 ; +} +#endif /* KEYCTL_COMMON_H__ */
testcases/kernel/syscalls/keyctl/keyctl_pkey_data.h new file +68 -0
68 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 23/33 keyctl30: Test KEYCTL_PKEY_QUERY on private key
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Test KEYCTL_PKEY_QUERY operation on an RSA-2048 PKCS#8 private key:
verify key_size is 2048, supported_ops contains DECRYPT and SIGN, and max_dec_size/max_sig_size are 256.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/keyctl/.gitignore | 1 + testcases/kernel/syscalls/keyctl/keyctl30.c | 86 ++++++++++++++++++++++ .../kernel/syscalls/keyctl/keyctl_pkey_data.h | 84 +++++++++++++++++++++ 4 files changed, 172 insertions(+)
runtest/syscalls +1 -0
@@ -747,6 +747,7 @@ keyctl26 keyctl26 keyctl27 keyctl27 keyctl28 keyctl28 keyctl29 keyctl29 +keyctl30 keyctl30 kcmp01 kcmp01 kcmp02 kcmp02
testcases/kernel/syscalls/keyctl/.gitignore +1 -0
@@ -27,3 +27,4 @@ /keyctl27 /keyctl28 /keyctl29 +/keyctl30
testcases/kernel/syscalls/keyctl/keyctl30.c new file +86 -0
86 lines not on this page · raw message
testcases/kernel/syscalls/keyctl/keyctl_pkey_data.h +84 -0
88 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 24/33 keyctl31: Test KEYCTL_PKEY_ENCRYPT and KEYCTL_PKEY_DECRYPT
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Test public key encryption and private key decryption with KEYCTL_PKEY_ENCRYPT and KEYCTL_PKEY_DECRYPT: encrypt a 32-byte plaintext using an RSA-2048 X.509 public key with enc=pkcs1, decrypt with the matching PKCS#8 private key, and verify the decrypted output matches the original plaintext.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/keyctl/.gitignore | 1 + testcases/kernel/syscalls/keyctl/keyctl31.c | 110 ++++++++++++++++++++++++++++ 3 files changed, 112 insertions(+)
runtest/syscalls +1 -0
@@ -748,6 +748,7 @@ keyctl27 keyctl27 keyctl28 keyctl28 keyctl29 keyctl29 keyctl30 keyctl30 +keyctl31 keyctl31 kcmp01 kcmp01 kcmp02 kcmp02
testcases/kernel/syscalls/keyctl/.gitignore +1 -0
@@ -28,3 +28,4 @@ /keyctl28 /keyctl29 /keyctl30 +/keyctl31
testcases/kernel/syscalls/keyctl/keyctl31.c new file +110 -0
110 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 25/33 keyctl32: Test KEYCTL_PKEY_SIGN and VERIFY
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Test public key signature creation and verification with KEYCTL_PKEY_SIGN and KEYCTL_PKEY_VERIFY: sign a 32-byte digest using an RSA-2048 PKCS#8 private key with enc=pkcs1, verify the 256-byte signature with the matching X.509 public key, and verify that a mismatched digest fails with EKEYREJECTED.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/keyctl/.gitignore | 1 + testcases/kernel/syscalls/keyctl/keyctl32.c | 121 ++++++++++++++++++++++++++++ 3 files changed, 123 insertions(+)
runtest/syscalls +1 -0
@@ -749,6 +749,7 @@ keyctl28 keyctl28 keyctl29 keyctl29 keyctl30 keyctl30 keyctl31 keyctl31 +keyctl32 keyctl32 kcmp01 kcmp01 kcmp02 kcmp02
testcases/kernel/syscalls/keyctl/.gitignore +1 -0
@@ -29,3 +29,4 @@ /keyctl29 /keyctl30 /keyctl31 +/keyctl32
testcases/kernel/syscalls/keyctl/keyctl32.c new file +121 -0
121 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 26/33 keyctl33: Negative tests for KEYCTL_PKEY_*
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Add negative and boundary test cases for KEYCTL_PKEY_* operations (QUERY, ENCRYPT, DECRYPT, SIGN, VERIFY), testing invalid key serials, unsupported key types, invalid info strings, and buffer size limits.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/keyctl/.gitignore | 1 + testcases/kernel/syscalls/keyctl/keyctl33.c | 247 ++++++++++++++++++++++++++++ 3 files changed, 249 insertions(+)
runtest/syscalls +1 -0
@@ -750,6 +750,7 @@ keyctl29 keyctl29 keyctl30 keyctl30 keyctl31 keyctl31 keyctl32 keyctl32 +keyctl33 keyctl33 kcmp01 kcmp01 kcmp02 kcmp02
testcases/kernel/syscalls/keyctl/.gitignore +1 -0
@@ -30,3 +30,4 @@ /keyctl30 /keyctl31 /keyctl32 +/keyctl33
testcases/kernel/syscalls/keyctl/keyctl33.c new file +247 -0
247 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 27/33 lapi/keyctl.h: Add capability fallback defines
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Add fallback definitions for KEYCTL_CAPABILITIES, KEYCTL_CAPS0_*, and KEYCTL_CAPS1_* constants, and update safe_keyctl to handle KEYCTL_CAPABILITIES.
--- include/lapi/keyctl.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
include/lapi/keyctl.h +19 -0
@@ -219,6 +219,10 @@ static inline key_serial_t keyctl_join_session_keyring(const char *name) {# define KEYCTL_MOVE_EXCL 0x00000001/* do not displace from the to-keyring */ #endif +#ifndef KEYCTL_CAPABILITIES +# define KEYCTL_CAPABILITIES 31 +#endif +#ifndef KEYCTL_PKEY_QUERY # define KEYCTL_PKEY_QUERY 24#endif
@@ -246,6 +250,20 @@ static inline key_serial_t keyctl_join_session_keyring(const char *name) {# define KEYCTL_SUPPORTS_VERIFY 0x08#endif +#ifndef KEYCTL_CAPS0_CAPABILITIES +# define KEYCTL_CAPS0_CAPABILITIES 0x01 +# define KEYCTL_CAPS0_PERSISTENT_KEYRINGS 0x02 +# define KEYCTL_CAPS0_DIFFIE_HELLMAN 0x04 +# define KEYCTL_CAPS0_PUBLIC_KEY 0x08 +# define KEYCTL_CAPS0_BIG_KEY 0x10 +# define KEYCTL_CAPS0_INVALIDATE 0x20 +# define KEYCTL_CAPS0_RESTRICT_KEYRING 0x40 +# define KEYCTL_CAPS0_MOVE 0x80 +# define KEYCTL_CAPS1_NS_KEYRING_NAME 0x01 +# define KEYCTL_CAPS1_NS_KEY_TAG 0x02 +# define KEYCTL_CAPS1_NOTIFICATIONS 0x04 +#endif +/* key permissions */ #ifndef KEY_POS_VIEW # define KEY_POS_VIEW 0x01000000
@@ -311,6 +329,7 @@ static inline long safe_keyctl(const char *file, const int lineno,case KEYCTL_PKEY_DECRYPT :case KEYCTL_PKEY_SIGN :case KEYCTL_PKEY_VERIFY : +case KEYCTL_CAPABILITIES :if (rval <0 ) failure =1 ;break ;
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 28/33 keyctl34: Test KEYCTL_CAPABILITIES flag retrieval
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Test keyrings subsystem capabilities retrieval with KEYCTL_CAPABILITIES and verify standard capability bits (CAPABILITIES, INVALIDATE, RESTRICT_KEYRING, MOVE, NS_KEYRING_NAME, NS_KEY_TAG).
--- runtest/syscalls | 1 + testcases/kernel/syscalls/keyctl/.gitignore | 1 + testcases/kernel/syscalls/keyctl/keyctl34.c | 62 +++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+)
runtest/syscalls +1 -0
@@ -751,6 +751,7 @@ keyctl30 keyctl30 keyctl31 keyctl31 keyctl32 keyctl32 keyctl33 keyctl33 +keyctl34 keyctl34 kcmp01 kcmp01 kcmp02 kcmp02
testcases/kernel/syscalls/keyctl/.gitignore +1 -0
@@ -31,3 +31,4 @@ /keyctl31 /keyctl32 /keyctl33 +/keyctl34
testcases/kernel/syscalls/keyctl/keyctl34.c new file +62 -0
62 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 29/33 keyctl35: Test KEYCTL_CAPABILITIES size query
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Test that calling KEYCTL_CAPABILITIES with a NULL buffer and buflen of 0 returns the total size in bytes of the keyrings subsystem capability array without faulting.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/keyctl/.gitignore | 1 + testcases/kernel/syscalls/keyctl/keyctl35.c | 49 +++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+)
runtest/syscalls +1 -0
@@ -752,6 +752,7 @@ keyctl31 keyctl31 keyctl32 keyctl32 keyctl33 keyctl33 keyctl34 keyctl34 +keyctl35 keyctl35 kcmp01 kcmp01 kcmp02 kcmp02
testcases/kernel/syscalls/keyctl/.gitignore +1 -0
@@ -32,3 +32,4 @@ /keyctl32 /keyctl33 /keyctl34 +/keyctl35
testcases/kernel/syscalls/keyctl/keyctl35.c new file +49 -0
49 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 30/33 keyctl36: Test KEYCTL_CAPABILITIES buffer sizing
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Test KEYCTL_CAPABILITIES with short buffer (verifying partial copy without overrun) and oversized buffer (verifying trailing space is zero-filled while returning the full capability length).
--- runtest/syscalls | 1 + testcases/kernel/syscalls/keyctl/.gitignore | 1 + testcases/kernel/syscalls/keyctl/keyctl36.c | 88 +++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+)
runtest/syscalls +1 -0
@@ -753,6 +753,7 @@ keyctl32 keyctl32 keyctl33 keyctl33 keyctl34 keyctl34 keyctl35 keyctl35 +keyctl36 keyctl36 kcmp01 kcmp01 kcmp02 kcmp02
testcases/kernel/syscalls/keyctl/.gitignore +1 -0
@@ -33,3 +33,4 @@ /keyctl33 /keyctl34 /keyctl35 +/keyctl36
testcases/kernel/syscalls/keyctl/keyctl36.c new file +88 -0
88 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 31/33 keyctl37: Negative tests for KEYCTL_CAPABILITIES
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Add negative test cases for KEYCTL_CAPABILITIES verifying that passing a NULL buffer with a non-zero length or an invalid buffer pointer fails with EFAULT.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/keyctl/.gitignore | 1 + testcases/kernel/syscalls/keyctl/keyctl37.c | 63 +++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+)
runtest/syscalls +1 -0
@@ -754,6 +754,7 @@ keyctl33 keyctl33 keyctl34 keyctl34 keyctl35 keyctl35 keyctl36 keyctl36 +keyctl37 keyctl37 kcmp01 kcmp01 kcmp02 kcmp02
testcases/kernel/syscalls/keyctl/.gitignore +1 -0
@@ -34,3 +34,4 @@ /keyctl34 /keyctl35 /keyctl36 +/keyctl37
testcases/kernel/syscalls/keyctl/keyctl37.c new file +63 -0
63 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 32/33 keyctl38: Test KEYCTL_WATCH_KEY add and remove
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Test KEYCTL_WATCH_KEY by opening a watch queue notification pipe and adding then removing watches on both a user key and the session keyring.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/keyctl/.gitignore | 1 + testcases/kernel/syscalls/keyctl/keyctl38.c | 91 +++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+)
runtest/syscalls +1 -0
@@ -755,6 +755,7 @@ keyctl34 keyctl34 keyctl35 keyctl35 keyctl36 keyctl36 keyctl37 keyctl37 +keyctl38 keyctl38 kcmp01 kcmp01 kcmp02 kcmp02
testcases/kernel/syscalls/keyctl/.gitignore +1 -0
@@ -35,3 +35,4 @@ /keyctl35 /keyctl36 /keyctl37 +/keyctl38
testcases/kernel/syscalls/keyctl/keyctl38.c new file +91 -0
91 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 33/33 keyctl39: Negative tests for KEYCTL_WATCH_KEY
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
Add negative test cases for KEYCTL_WATCH_KEY verifying invalid watch_id values, bogus key ids, missing View permission, invalid file descriptors, non-watch-queue pipes, and removal of watches on unwatched keys.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/keyctl/.gitignore | 1 + testcases/kernel/syscalls/keyctl/keyctl39.c | 149 ++++++++++++++++++++++++++++ 3 files changed, 151 insertions(+)
runtest/syscalls +1 -0
@@ -756,6 +756,7 @@ keyctl35 keyctl35 keyctl36 keyctl36 keyctl37 keyctl37 keyctl38 keyctl38 +keyctl39 keyctl39 kcmp01 kcmp01 kcmp02 kcmp02
testcases/kernel/syscalls/keyctl/.gitignore +1 -0
@@ -36,3 +36,4 @@ /keyctl36 /keyctl37 /keyctl38 +/keyctl39
testcases/kernel/syscalls/keyctl/keyctl39.c new file +149 -0
149 lines not on this page · raw message
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp