Skip to contentSkip to conversation

key: Fix Valgrind warnings

PATCH Applied Mat Martineau 2 participants 2 messages Oct 12, 2016 – Oct 13, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 key: Fix Valgrind warnings

Valgrind doesn't understand all of the keyctl syscalls and how they set memory, so clear the encrypt/decrypt/sign output buffer to prevent false positives.

TEST: key crypto
==5884== Conditional jump or move depends on uninitialised value(s)

==5884==    at 0x40555F: unpad (key.c:479)
==5884==    by 0x4057DF: l_key_decrypt (key.c:556)
==5884==    by 0x4021EB: test_key_crypto (test-key.c:535)
==5884==    by 0x4039BB: l_test_run (test.c:83)
==5884==    by 0x4026F3: main (test-key.c:606)
==5884==
==5884== Conditional jump or move depends on uninitialised value(s)
==5884==    at 0x40556F: unpad (key.c:479)
==5884==    by 0x4057DF: l_key_decrypt (key.c:556)
==5884==    by 0x4021EB: test_key_crypto (test-key.c:535)
==5884==    by 0x4039BB: l_test_run (test.c:83)
==5884==    by 0x4026F3: main (test-key.c:606)
==5884==
==5884== Conditional jump or move depends on uninitialised value(s)
==5884==    at 0x4055AC: unpad (key.c:483)
==5884==    by 0x4057DF: l_key_decrypt (key.c:556)
==5884==    by 0x4021EB: test_key_crypto (test-key.c:535)
==5884==    by 0x4039BB: l_test_run (test.c:83)
==5884==    by 0x4026F3: main (test-key.c:606)
==5884==
==5884== Conditional jump or move depends on uninitialised value(s)
==5884==    at 0x4C2FC4C: strcmp (vg_replace_strmem.c:842)
==5884==    by 0x40223A: test_key_crypto (test-key.c:538)
==5884==    by 0x4039BB: l_test_run (test.c:83)
==5884==    by 0x4026F3: main (test-key.c:606)
==5884==
==5884== Conditional jump or move depends on uninitialised value(s)
==5884==    at 0x4C2FC50: strcmp (vg_replace_strmem.c:842)
==5884==    by 0x40223A: test_key_crypto (test-key.c:538)
==5884==    by 0x4039BB: l_test_run (test.c:83)
==5884==    by 0x4026F3: main (test-key.c:606)
==5884==
==5884== Conditional jump or move depends on uninitialised value(s)
==5884==    at 0x4C2FC6C: strcmp (vg_replace_strmem.c:842)
==5884==    by 0x40223A: test_key_crypto (test-key.c:538)
==5884==    by 0x4039BB: l_test_run (test.c:83)
==5884==    by 0x4026F3: main (test-key.c:606)
---
 ell/key.c | 2 ++
 1 file changed, 2 insertions(+)
ell/key.c +2 -0
index 0222b39..fc20d29 100644
@@ -218,6 +218,8 @@ static long kernel_key_eds(int op, int32_t serial, const char *encoding,
 					     .out_len = len_out };
 	char *info = format_key_info(encoding, hash);
 
+	memset(out, 0, len_out);
+
 	result = syscall(__NR_keyctl, op, &params, info ?: "", in, out);
 	l_free(info);
 
Signature · 1 line
2.10.1
#1 lore raw

Hi Mat,

Quoted 8 lines · Mat Martineau

Valgrind doesn't understand all of the keyctl syscalls and how they set memory, so clear the encrypt/decrypt/sign output buffer to prevent false positives.

---
  ell/key.c | 2 ++
  1 file changed, 2 insertions(+)

Applied, thanks.

Regards,
-Denis