From: Eric Biggers <ebiggers@kernel.org>
To: ltp@lists.linux.it
Cc: linux-crypto@vger.kernel.org
Subject: [PATCH 5/6] crypto/af_alg04: new regression test for vmac race conditions
Date: Wed, 20 Feb 2019 21:30:25 -0800 [thread overview]
Message-ID: <20190221053026.18489-6-ebiggers@kernel.org> (raw)
In-Reply-To: <20190221053026.18489-1-ebiggers@kernel.org>
From: Eric Biggers <ebiggers@google.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
testcases/kernel/crypto/.gitignore | 1 +
testcases/kernel/crypto/af_alg04.c | 56 ++++++++++++++++++++++++++++++
2 files changed, 57 insertions(+)
create mode 100644 testcases/kernel/crypto/af_alg04.c
diff --git a/testcases/kernel/crypto/.gitignore b/testcases/kernel/crypto/.gitignore
index 3e7936fc94..df6b7e73cb 100644
--- a/testcases/kernel/crypto/.gitignore
+++ b/testcases/kernel/crypto/.gitignore
@@ -1,5 +1,6 @@
af_alg01
af_alg02
af_alg03
+af_alg04
pcrypt_aead01
crypto_user01
diff --git a/testcases/kernel/crypto/af_alg04.c b/testcases/kernel/crypto/af_alg04.c
new file mode 100644
index 0000000000..b8e494b870
--- /dev/null
+++ b/testcases/kernel/crypto/af_alg04.c
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright 2019 Google LLC
+ */
+
+/*
+ * Regression test for commit bb2964810233 ("crypto: vmac - separate tfm and
+ * request context"). This test verifies that a VMAC transform can be used by
+ * multiple concurrent hash requests without crashing the kernel. Based on the
+ * reproducer from the commit message.
+ */
+
+#include <sys/wait.h>
+
+#include "tst_test.h"
+#include "tst_af_alg.h"
+
+static void run(void)
+{
+ int algfd, reqfd;
+ char buf[256] = { 0 };
+ pid_t pid;
+ int status;
+ int i;
+
+ if (tst_have_alg("hash", "vmac64(aes)"))
+ algfd = tst_alg_setup("hash", "vmac64(aes)", NULL, 16);
+ else
+ algfd = tst_alg_setup("hash", "vmac(aes)", NULL, 16);
+
+ pid = SAFE_FORK();
+
+ reqfd = tst_alg_accept(algfd);
+
+ for (i = 0; i < 500000; i++)
+ SAFE_WRITE(1, reqfd, buf, sizeof(buf));
+
+ close(reqfd);
+
+ if (pid != 0) {
+ SAFE_WAIT(&status);
+ if (WIFEXITED(status) && WEXITSTATUS(status) == 0)
+ tst_res(TPASS, "didn't crash");
+ else if (WIFSIGNALED(status) && WTERMSIG(status) == SIGKILL)
+ tst_res(TFAIL, "crashed");
+ else
+ tst_brk(TBROK, "child %s", tst_strstatus(status));
+
+ close(algfd);
+ }
+}
+
+static struct tst_test test = {
+ .test_all = run,
+ .forks_child = 1,
+};
--
2.20.1
WARNING: multiple messages have this Message-ID (diff)
From: Eric Biggers <ebiggers@kernel.org>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 5/6] crypto/af_alg04: new regression test for vmac race conditions
Date: Wed, 20 Feb 2019 21:30:25 -0800 [thread overview]
Message-ID: <20190221053026.18489-6-ebiggers@kernel.org> (raw)
In-Reply-To: <20190221053026.18489-1-ebiggers@kernel.org>
From: Eric Biggers <ebiggers@google.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
testcases/kernel/crypto/.gitignore | 1 +
testcases/kernel/crypto/af_alg04.c | 56 ++++++++++++++++++++++++++++++
2 files changed, 57 insertions(+)
create mode 100644 testcases/kernel/crypto/af_alg04.c
diff --git a/testcases/kernel/crypto/.gitignore b/testcases/kernel/crypto/.gitignore
index 3e7936fc94..df6b7e73cb 100644
--- a/testcases/kernel/crypto/.gitignore
+++ b/testcases/kernel/crypto/.gitignore
@@ -1,5 +1,6 @@
af_alg01
af_alg02
af_alg03
+af_alg04
pcrypt_aead01
crypto_user01
diff --git a/testcases/kernel/crypto/af_alg04.c b/testcases/kernel/crypto/af_alg04.c
new file mode 100644
index 0000000000..b8e494b870
--- /dev/null
+++ b/testcases/kernel/crypto/af_alg04.c
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright 2019 Google LLC
+ */
+
+/*
+ * Regression test for commit bb2964810233 ("crypto: vmac - separate tfm and
+ * request context"). This test verifies that a VMAC transform can be used by
+ * multiple concurrent hash requests without crashing the kernel. Based on the
+ * reproducer from the commit message.
+ */
+
+#include <sys/wait.h>
+
+#include "tst_test.h"
+#include "tst_af_alg.h"
+
+static void run(void)
+{
+ int algfd, reqfd;
+ char buf[256] = { 0 };
+ pid_t pid;
+ int status;
+ int i;
+
+ if (tst_have_alg("hash", "vmac64(aes)"))
+ algfd = tst_alg_setup("hash", "vmac64(aes)", NULL, 16);
+ else
+ algfd = tst_alg_setup("hash", "vmac(aes)", NULL, 16);
+
+ pid = SAFE_FORK();
+
+ reqfd = tst_alg_accept(algfd);
+
+ for (i = 0; i < 500000; i++)
+ SAFE_WRITE(1, reqfd, buf, sizeof(buf));
+
+ close(reqfd);
+
+ if (pid != 0) {
+ SAFE_WAIT(&status);
+ if (WIFEXITED(status) && WEXITSTATUS(status) == 0)
+ tst_res(TPASS, "didn't crash");
+ else if (WIFSIGNALED(status) && WTERMSIG(status) == SIGKILL)
+ tst_res(TFAIL, "crashed");
+ else
+ tst_brk(TBROK, "child %s", tst_strstatus(status));
+
+ close(algfd);
+ }
+}
+
+static struct tst_test test = {
+ .test_all = run,
+ .forks_child = 1,
+};
--
2.20.1
next prev parent reply other threads:[~2019-02-21 5:31 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-21 5:30 [PATCH 0/6] ltp: AF_ALG test helpers and a few regression tests Eric Biggers
2019-02-21 5:30 ` [LTP] " Eric Biggers
2019-02-21 5:30 ` [PATCH 1/6] lib: add tst_af_alg lib Eric Biggers
2019-02-21 5:30 ` [LTP] " Eric Biggers
2019-03-15 9:38 ` Petr Vorel
2019-03-15 9:38 ` Petr Vorel
2019-02-21 5:30 ` [PATCH 2/6] crypto/af_alg01: new regression test for hmac nesting bug Eric Biggers
2019-02-21 5:30 ` [LTP] " Eric Biggers
2019-03-15 9:43 ` Petr Vorel
2019-03-15 9:43 ` Petr Vorel
2019-02-21 5:30 ` [PATCH 3/6] crypto/af_alg02: new regression test for salsa20 empty message bug Eric Biggers
2019-02-21 5:30 ` [LTP] " Eric Biggers
2019-02-21 5:30 ` [PATCH 4/6] crypto/af_alg03: new regression test for rfc7539 hash alg validation Eric Biggers
2019-02-21 5:30 ` [LTP] " Eric Biggers
2019-03-15 9:29 ` Petr Vorel
2019-03-15 9:29 ` Petr Vorel
2019-03-15 16:13 ` Eric Biggers
2019-03-15 16:13 ` Eric Biggers
2019-03-15 18:40 ` Petr Vorel
2019-03-15 18:40 ` Petr Vorel
2019-03-15 19:49 ` Eric Biggers
2019-03-15 19:49 ` Eric Biggers
2019-02-21 5:30 ` Eric Biggers [this message]
2019-02-21 5:30 ` [LTP] [PATCH 5/6] crypto/af_alg04: new regression test for vmac race conditions Eric Biggers
2019-02-21 5:30 ` [PATCH 6/6] crypto/af_alg05: new regression test for skcipher_walk error bug Eric Biggers
2019-02-21 5:30 ` [LTP] " Eric Biggers
2019-03-15 0:11 ` [PATCH 0/6] ltp: AF_ALG test helpers and a few regression tests Eric Biggers
2019-03-15 0:11 ` [LTP] " Eric Biggers
2019-03-15 9:45 ` Petr Vorel
2019-03-15 9:45 ` Petr Vorel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190221053026.18489-6-ebiggers@kernel.org \
--to=ebiggers@kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.