<div dir="ltr"><div class="gmail_default" style="font-size:small"></div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, May 8, 2019 at 3:16 PM Christian Amann <<a href="mailto:camann@suse.com" target="_blank">camann@suse.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On kernels < 4.14 (missing commit 2d97591ef43d) reading from<br>
the request socket does not return and the testcase does not<br>
finish.<br>
<br>
This fix moves the logic to a child thread in order for the<br>
parent to handle the timeout and report a message to the user.<br>
<br>
Signed-off-by: Christian Amann <<a href="mailto:camann@suse.com" target="_blank">camann@suse.com</a>><br></blockquote><div>Reviewed-by: Li Wang <<a href="mailto:liwang@redhat.com" target="_blank">liwang@redhat.com</a>><br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
---<br>
<br>
Notes:<br>
Hi Li,<br>
<br>
> We could set LTP_ATTRIBUTE_UNUSED at the behind of unused parameter to get<br>
> rid of compiling warning<br>
<br>
Thats very useful but I couldn't find it anywhere in the documentation.<br>
IMHO it should be put in there, because I stumbled upon this problem<br>
a couple of times.<br></blockquote><div><br></div><div><div class="gmail_default">This is just a definition for variable attribute which supports by GNU compiler, I'm not sure if we should add it to LTP documents.</div><br></div><div><div class="gmail_default" style="font-size:small">$ grep LTP_ATTRIBUTE_UNUSED . -r</div></div><div><div class="gmail_default">tst_common.h:25:#define LTP_ATTRIBUTE_UNUSED<span style="white-space:pre-wrap"> </span>__attribute__((unused))<br></div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Anyway, I implemented your suggestions. I hope it's an alright patch now.<br>
Thanks for your feedback!<br>
<br>
Regards,<br>
Christian<br>
<br>
testcases/kernel/crypto/Makefile | 2 ++<br>
testcases/kernel/crypto/af_alg02.c | 37 +++++++++++++++++++++++++++++++++++--<br>
2 files changed, 37 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/testcases/kernel/crypto/Makefile b/testcases/kernel/crypto/Makefile<br>
index 76f9308c2..6547e1cb6 100644<br>
--- a/testcases/kernel/crypto/Makefile<br>
+++ b/testcases/kernel/crypto/Makefile<br>
@@ -20,3 +20,5 @@ include $(top_srcdir)/include/mk/<a href="http://testcases.mk" rel="noreferrer" target="_blank">testcases.mk</a><br>
CFLAGS += -D_GNU_SOURCE<br>
<br>
include $(top_srcdir)/include/mk/<a href="http://generic_leaf_target.mk" rel="noreferrer" target="_blank">generic_leaf_target.mk</a><br>
+<br>
+af_alg02: CFLAGS += -pthread<br>
diff --git a/testcases/kernel/crypto/af_alg02.c b/testcases/kernel/crypto/af_alg02.c<br>
index a9e820423..1c725212a 100644<br>
--- a/testcases/kernel/crypto/af_alg02.c<br>
+++ b/testcases/kernel/crypto/af_alg02.c<br>
@@ -7,23 +7,56 @@<br>
* Regression test for commit ecaaab564978 ("crypto: salsa20 - fix<br>
* blkcipher_walk API usage"), or CVE-2017-17805. This test verifies that an<br>
* empty message can be encrypted with Salsa20 without crashing the kernel.<br>
+ *<br>
+ * Fix for kernels < 4.14:<br>
+ * With kernels missing commit 2d97591ef43d ("crypto: af_alg - consolidation<br>
+ * of duplicate code") read() does not return in this situation. The call is<br>
+ * now moved to a child thread in order to cancel it in case read() takes an<br>
+ * unusual long amount of time.<br>
*/<br>
<br>
#include "tst_test.h"<br>
#include "tst_af_alg.h"<br>
+#include "tst_safe_pthread.h"<br>
+#include <pthread.h><br>
+#include <errno.h><br>
<br>
-static void run(void)<br>
+void *verify_encrypt(void *arg LTP_ATTRIBUTE_UNUSED)<br>
{<br>
char buf[16];<br>
int reqfd = tst_alg_setup_reqfd("skcipher", "salsa20", NULL, 16);<br>
<br>
+ TST_CHECKPOINT_WAKE(0);<br>
+<br>
/* With the bug the kernel crashed here */<br>
if (read(reqfd, buf, 16) == 0)<br>
tst_res(TPASS, "Successfully \"encrypted\" an empty message");<br>
else<br>
- tst_res(TBROK, "read() didn't return 0");<br>
+ tst_res(TFAIL, "read() didn't return 0");<br>
+ return arg;<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Since arg has been marked as unused, so here better to return NULL.</div></div><div><br></div><div><div class="gmail_default" style="font-size:small">Anyway, patch V3 looks good to me.</div></div><div> </div></div>-- <br><div dir="ltr" class="m_6104703560222033971gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div></div></div></div></div></div>