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

Richard Palethorpe rpalethorpe@suse.de
Thu Jan 12 12:03:39 CET 2023


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


-- 
Thank you,
Richard.


More information about the ltp mailing list