Skip to contentSkip to conversation

syscalls/keyctl/keyctl09.c: fix test encrypted key

PATCH Applied Nikolaus Voss 4 participants 4 messages Jan 12, 2023

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 syscalls/keyctl/keyctl09.c: fix test encrypted key

This commit fixes the test for adding encrypted keys with unencrypted data. Unencryted data must be provided hex-ascii encoding. Due to a kernel bug, the unencypted data was not decoded to binary thus the length of the key was only half the specified key size. This patch doubles the key size.

Fixes 342e7a0dd ("syscalls/keyctl09: test encrypted keys with provided decrypted data.")

---
v2: add linux-git tag for kernel fix, only correct test input data

 testcases/kernel/syscalls/keyctl/keyctl09.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
testcases/kernel/syscalls/keyctl/keyctl09.c +10 -4
index c88c481b9..cfd5f7e5f 100644
@@ -13,8 +13,8 @@
 #include "tst_test.h"
 #include "lapi/keyctl.h"
 
-#define ENCRYPTED_KEY_VALID_PAYLOAD	"new enc32 user:masterkey 32 abcdefABCDEF1234567890aaaaaaaaaa"
-#define ENCRYPTED_KEY_INVALID_PAYLOAD	"new enc32 user:masterkey 32 plaintext123@123!123@123!123@123"
+#define ENCRYPTED_KEY_VALID_PAYLOAD	"new enc32 user:masterkey 32 abcdefABCDEF1234567890aaaaaaaaaaabcdefABCDEF1234567890aaaaaaaaaa"
+#define ENCRYPTED_KEY_INVALID_PAYLOAD	"new enc32 user:masterkey 32 plaintext123@123!123@123!123@123plaintext123@123!123@123!123@123"
 
 static void do_test(void)
 {
@@ -28,7 +28,8 @@ static void do_test(void)
 
 	TST_EXP_POSITIVE(add_key("encrypted", "ltptestkey1",
 			    ENCRYPTED_KEY_VALID_PAYLOAD,
-			    60, KEY_SPEC_PROCESS_KEYRING));
+			    strlen(ENCRYPTED_KEY_VALID_PAYLOAD),
+			    KEY_SPEC_PROCESS_KEYRING));
 
 	if (!TST_PASS)
 		return;
@@ -39,7 +40,8 @@ static void do_test(void)
 		return;
 
 	TST_EXP_FAIL2(add_key("encrypted", "ltptestkey2",
-			    ENCRYPTED_KEY_INVALID_PAYLOAD, 60,
+			    ENCRYPTED_KEY_INVALID_PAYLOAD,
+			    strlen(ENCRYPTED_KEY_INVALID_PAYLOAD),
 			    KEY_SPEC_PROCESS_KEYRING), EINVAL);
 
 	keyctl(KEYCTL_CLEAR, KEY_SPEC_PROCESS_KEYRING);
@@ -50,5 +52,9 @@ static struct tst_test test = {
 	.needs_kconfigs = (const char *[]) {
 		"CONFIG_USER_DECRYPTED_DATA=y",
 		NULL
+	},
+	.tags = (const struct tst_tag[]) {
+		{ "linux-git", "5adedd42245af"},
+		{}
 	}
 };
Signature · 5 lines
2.34.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi Nikolaus,

thank you for this update.

I pushed your patch through mailing list, because you posted unsubscribed.

Quoted 1 line

From a link above you were able to send patch to kernel mailing list, thus you managed to subscribed. Why do you expect LTP would work for unsubscribed mails addresses?

I also dared to enable this mail for posting to LTP mailing list, but better would be if you subscribed before sending patches.

v1 is not in patchwork, but it's in lore:
https://lore.kernel.org/ltp/[email protected]/

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

Hi Petr,

Quoted 6 lines · Petr Vorel

Hi Nikolaus,

thank you for this update.

I pushed your patch through mailing list, because you posted unsubscribed.

thanks!

Quoted 6 lines
Quoted 2 lines

From a link above you were able to send patch to kernel mailing list, thus you managed to subscribed. Why do you expect LTP would work for unsubscribed mails addresses?

I don't remember, maybe I subscribed, posted and then unsubscribed for v1 and didn't remember I have to be subscribed before posting v2. As an irregular contributor I'm not subscribed to any list and use the archives instead. The majority of lists don't require subscription.

As an additional complication I use two mail-addresses, as I'm forced to use Outlook on the job, which doesn't work well with posting patches.

Quoted 5 lines

I also dared to enable this mail for posting to LTP mailing list, but better would be if you subscribed before sending patches.

v1 is not in patchwork, but it's in lore:
https://lore.kernel.org/ltp/[email protected]/

The above link (in the patch) _is_ a lore link, isn't it?

Niko

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw
In reply to Nikolaus Voss

Hello,

Merged, Thanks!

Quoted 62 lines · Nikolaus Voss

This commit fixes the test for adding encrypted keys with unencrypted data. Unencryted data must be provided hex-ascii encoding. Due to a kernel bug, the unencypted data was not decoded to binary thus the length of the key was only half the specified key size. This patch doubles the key size.

Fixes 342e7a0dd ("syscalls/keyctl09: test encrypted keys with provided decrypted data.")

---
v2: add linux-git tag for kernel fix, only correct test input data

 testcases/kernel/syscalls/keyctl/keyctl09.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
testcases/kernel/syscalls/keyctl/keyctl09.c +10 -4
index c88c481b9..cfd5f7e5f 100644
@@ -13,8 +13,8 @@
 #include "tst_test.h"
 #include "lapi/keyctl.h"
 
-#define ENCRYPTED_KEY_VALID_PAYLOAD	"new enc32 user:masterkey 32 abcdefABCDEF1234567890aaaaaaaaaa"
-#define ENCRYPTED_KEY_INVALID_PAYLOAD	"new enc32 user:masterkey 32 plaintext123@123!123@123!123@123"
+#define ENCRYPTED_KEY_VALID_PAYLOAD	"new enc32 user:masterkey 32 abcdefABCDEF1234567890aaaaaaaaaaabcdefABCDEF1234567890aaaaaaaaaa"
+#define ENCRYPTED_KEY_INVALID_PAYLOAD	"new enc32 user:masterkey 32 plaintext123@123!123@123!123@123plaintext123@123!123@123!123@123"
 
 static void do_test(void)
 {
@@ -28,7 +28,8 @@ static void do_test(void)
 
 	TST_EXP_POSITIVE(add_key("encrypted", "ltptestkey1",
 			    ENCRYPTED_KEY_VALID_PAYLOAD,
-			    60, KEY_SPEC_PROCESS_KEYRING));
+			    strlen(ENCRYPTED_KEY_VALID_PAYLOAD),
+			    KEY_SPEC_PROCESS_KEYRING));
 
 	if (!TST_PASS)
 		return;
@@ -39,7 +40,8 @@ static void do_test(void)
 		return;
 
 	TST_EXP_FAIL2(add_key("encrypted", "ltptestkey2",
-			    ENCRYPTED_KEY_INVALID_PAYLOAD, 60,
+			    ENCRYPTED_KEY_INVALID_PAYLOAD,
+			    strlen(ENCRYPTED_KEY_INVALID_PAYLOAD),
 			    KEY_SPEC_PROCESS_KEYRING), EINVAL);
 
 	keyctl(KEYCTL_CLEAR, KEY_SPEC_PROCESS_KEYRING);
@@ -50,5 +52,9 @@ static struct tst_test test = {
 	.needs_kconfigs = (const char *[]) {
 		"CONFIG_USER_DECRYPTED_DATA=y",
 		NULL
+	},
+	.tags = (const struct tst_tag[]) {
+		{ "linux-git", "5adedd42245af"},
+		{}
 	}
 };
Signature · 1 line
2.34.1
Signature · 5 lines
Thank you,
Richard.

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