diff mbox series

[v2] syscalls/keyctl/keyctl09.c: fix test encrypted key

Message ID 20230111142316.A0DBECA25@mail.steuer-voss.de
State Accepted
Headers show
Series [v2] syscalls/keyctl/keyctl09.c: fix test encrypted key | expand

Commit Message

Nikolaus Voss Jan. 11, 2023, 2:23 p.m. UTC
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.")
Link: https://lore.kernel.org/ltp/20221006081709.92303897@mail.steuer-voss.de/
Signed-off-by: Nikolaus Voss <nikolaus.voss@haag-streit.com>
---
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(-)

Comments

Petr Vorel Jan. 12, 2023, 12:39 a.m. UTC | #1
Hi Nikolaus,

thank you for this update.


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

> Link: https://lore.kernel.org/ltp/20221006081709.92303897@mail.steuer-voss.de/

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/d2d2afa4-b031-3455-38dd-c099715319e4@vosn.de/


Kind regards,
Petr
Nikolaus Voss Jan. 12, 2023, 9:01 a.m. UTC | #2
Hi Petr,

On Thu, 12 Jan 2023, Petr Vorel wrote:
> Hi Nikolaus,
>
> thank you for this update.
>
>
> I pushed your patch through mailing list, because you posted unsubscribed.

thanks!

>
>> Link: https://lore.kernel.org/ltp/20221006081709.92303897@mail.steuer-voss.de/
>
> 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.

> 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/d2d2afa4-b031-3455-38dd-c099715319e4@vosn.de/

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

Niko
Richard Palethorpe Jan. 12, 2023, 11:03 a.m. UTC | #3
Hello,

Merged, Thanks!

Nikolaus Voss <nikolaus.voss@haag-streit.com> writes:

> 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.")
> Link: https://lore.kernel.org/ltp/20221006081709.92303897@mail.steuer-voss.de/
> Signed-off-by: Nikolaus Voss <nikolaus.voss@haag-streit.com>
> ---
> 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(-)
>
> diff --git a/testcases/kernel/syscalls/keyctl/keyctl09.c b/testcases/kernel/syscalls/keyctl/keyctl09.c
> index c88c481b9..cfd5f7e5f 100644
> --- a/testcases/kernel/syscalls/keyctl/keyctl09.c
> +++ b/testcases/kernel/syscalls/keyctl/keyctl09.c
> @@ -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"},
> +		{}
>  	}
>  };
> -- 
> 2.34.1
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/keyctl/keyctl09.c b/testcases/kernel/syscalls/keyctl/keyctl09.c
index c88c481b9..cfd5f7e5f 100644
--- a/testcases/kernel/syscalls/keyctl/keyctl09.c
+++ b/testcases/kernel/syscalls/keyctl/keyctl09.c
@@ -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"},
+		{}
 	}
 };