summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended
diff options
context:
space:
mode:
authorFathi Boudra <fathi.boudra@linaro.org>2017-07-03 14:45:34 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-07-06 14:38:15 +0100
commitb18a0f56edbb61e78d6c71722233aaa50970a9bd (patch)
treee0ff74c03ec8d030f39677d04b14b1f9e2344629 /meta/recipes-extended
parent966b113113b22eaae47dcd4bb7e0abef23b23c3b (diff)
downloadpoky-b18a0f56edbb61e78d6c71722233aaa50970a9bd.tar.gz
ltp: syscalls/add_key02: fix for nonempty NULL payload
Add upstream patch to fix syscalls/add_key02 test for nonempty NULL payload: https://github.com/linux-test-project/ltp/commit/25045624e941ee76a13febd36187e23c6c435507 (From OE-Core rev: c7c72b73a841c6eadf88428db643e77deb0c0e65) Signed-off-by: Milosz Wasilewski <milosz.wasilewski@linaro.org> Signed-off-by: Fathi Boudra <fathi.boudra@linaro.org> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-extended')
-rw-r--r--meta/recipes-extended/ltp/ltp/0038-syscalls-add_key02-update-to-test-fix-for-nonempty-N.patch136
-rw-r--r--meta/recipes-extended/ltp/ltp_20170516.bb1
2 files changed, 137 insertions, 0 deletions
diff --git a/meta/recipes-extended/ltp/ltp/0038-syscalls-add_key02-update-to-test-fix-for-nonempty-N.patch b/meta/recipes-extended/ltp/ltp/0038-syscalls-add_key02-update-to-test-fix-for-nonempty-N.patch
new file mode 100644
index 0000000000..3759e1fa9f
--- /dev/null
+++ b/meta/recipes-extended/ltp/ltp/0038-syscalls-add_key02-update-to-test-fix-for-nonempty-N.patch
@@ -0,0 +1,136 @@
1From 25045624e941ee76a13febd36187e23c6c435507 Mon Sep 17 00:00:00 2001
2From: Eric Biggers <ebiggers@google.com>
3Date: Mon, 12 Jun 2017 11:55:21 -0700
4Subject: [PATCH 01/39] syscalls/add_key02: update to test fix for nonempty
5 NULL payload
6
7add_key02 was supposed to be a "Basic test for the add_key() syscall",
8but it actually happened to test the obscure case of passing a NULL
9payload with nonzero length. This case was mishandled by the kernel,
10which either returned EINVAL or crashed with a NULL pointer dereference,
11depending on the key type. (The former applied to the test, as it used
12the "user" key type.) The expected behavior in this case is that the
13syscall fail with EFAULT.
14
15Update the test to expect the fixed behavior from v4.12-rc5, and make
16the test more thorough by testing additional key types, including ones
17that caused a NULL pointer dereference in unfixed kernels.
18
19Signed-off-by: Eric Biggers <ebiggers@google.com>
20Upstream-Status: Accepted [https://github.com/linux-test-project/ltp/commit/25045624e941ee76a13febd36187e23c6c435507]
21---
22 testcases/kernel/syscalls/add_key/add_key02.c | 69 ++++++++++++++++++++-------
23 1 file changed, 51 insertions(+), 18 deletions(-)
24
25diff --git a/testcases/kernel/syscalls/add_key/add_key02.c b/testcases/kernel/syscalls/add_key/add_key02.c
26index 866800d6f..2e3308dcd 100644
27--- a/testcases/kernel/syscalls/add_key/add_key02.c
28+++ b/testcases/kernel/syscalls/add_key/add_key02.c
29@@ -1,5 +1,6 @@
30 /******************************************************************************
31 * Copyright (c) Crackerjack Project., 2007 *
32+ * Copyright (c) 2017 Google, Inc. *
33 * *
34 * This program is free software; you can redistribute it and/or modify *
35 * it under the terms of the GNU General Public License as published by *
36@@ -18,10 +19,17 @@
37 ******************************************************************************/
38
39 /*
40- * Basic test for the add_key() syscall.
41+ * Test that the add_key() syscall correctly handles a NULL payload with nonzero
42+ * length. Specifically, it should fail with EFAULT rather than oopsing the
43+ * kernel with a NULL pointer dereference or failing with EINVAL, as it did
44+ * before (depending on the key type). This is a regression test for commit
45+ * 5649645d725c ("KEYS: fix dereferencing NULL payload with nonzero length").
46 *
47- * History: Porting from Crackerjack to LTP is done by
48- * Manas Kumar Nayak maknayak@in.ibm.com>
49+ * Note that none of the key types that exhibited the NULL pointer dereference
50+ * are guaranteed to be built into the kernel, so we just test as many as we
51+ * can, in the hope of catching one. We also test with the "user" key type for
52+ * good measure, although it was one of the types that failed with EINVAL rather
53+ * than dereferencing NULL.
54 */
55
56 #include "config.h"
57@@ -33,36 +41,61 @@
58
59 #ifdef HAVE_LINUX_KEYCTL_H
60 struct tcase {
61- char *type;
62- char *desc;
63- void *payload;
64- int plen;
65- int exp_errno;
66+ const char *type;
67+ size_t plen;
68 } tcases[] = {
69- {"user", "firstkey", NULL, 1, EINVAL}
70+ /*
71+ * The payload length we test for each key type needs to pass initial
72+ * validation but is otherwise arbitrary. Note: the "rxrpc_s" key type
73+ * requires a payload of exactly 8 bytes.
74+ */
75+ { "asymmetric", 64 },
76+ { "cifs.idmap", 64 },
77+ { "cifs.spnego", 64 },
78+ { "pkcs7_test", 64 },
79+ { "rxrpc", 64 },
80+ { "rxrpc_s", 8 },
81+ { "user", 64 },
82 };
83 #endif /* HAVE_LINUX_KEYCTL_H */
84
85 static void verify_add_key(unsigned int i)
86 {
87 #ifdef HAVE_LINUX_KEYCTL_H
88- TEST(tst_syscall(__NR_add_key, tcases[i].type, tcases[i].desc,
89- tcases[i].payload, tcases[i].plen,
90- KEY_SPEC_USER_KEYRING));
91+ TEST(tst_syscall(__NR_add_key, tcases[i].type, "abc:def",
92+ NULL, tcases[i].plen, KEY_SPEC_PROCESS_KEYRING));
93
94 if (TEST_RETURN != -1) {
95- tst_res(TFAIL, "add_key() passed unexpectedly");
96+ tst_res(TFAIL,
97+ "add_key() with key type '%s' unexpectedly succeeded",
98+ tcases[i].type);
99 return;
100 }
101
102- if (TEST_ERRNO == tcases[i].exp_errno) {
103- tst_res(TPASS | TTERRNO, "add_key() failed expectedly");
104+ if (TEST_ERRNO == EFAULT) {
105+ tst_res(TPASS, "received expected EFAULT with key type '%s'",
106+ tcases[i].type);
107 return;
108 }
109
110- tst_res(TFAIL | TTERRNO,
111- "add_key() failed unexpectedly, expected %s",
112- tst_strerrno(tcases[i].exp_errno));
113+ if (TEST_ERRNO == ENODEV) {
114+ tst_res(TCONF, "kernel doesn't support key type '%s'",
115+ tcases[i].type);
116+ return;
117+ }
118+
119+ /*
120+ * It's possible for the "asymmetric" key type to be supported, but with
121+ * no asymmetric key parsers registered. In that case, attempting to
122+ * add a key of type asymmetric will fail with EBADMSG.
123+ */
124+ if (TEST_ERRNO == EBADMSG && !strcmp(tcases[i].type, "asymmetric")) {
125+ tst_res(TCONF, "no asymmetric key parsers are registered");
126+ return;
127+ }
128+
129+ tst_res(TFAIL | TTERRNO, "unexpected error with key type '%s'",
130+ tcases[i].type);
131 #else
132 tst_brk(TCONF, "linux/keyctl.h was missing upon compilation.");
133 #endif /* HAVE_LINUX_KEYCTL_H */
134--
1352.13.0
136
diff --git a/meta/recipes-extended/ltp/ltp_20170516.bb b/meta/recipes-extended/ltp/ltp_20170516.bb
index f537d60c15..ac66b09569 100644
--- a/meta/recipes-extended/ltp/ltp_20170516.bb
+++ b/meta/recipes-extended/ltp/ltp_20170516.bb
@@ -51,6 +51,7 @@ SRC_URI = "git://github.com/linux-test-project/ltp.git \
51 file://0036-testcases-network-nfsv4-acl-acl1.c-Security-fix-on-s.patch \ 51 file://0036-testcases-network-nfsv4-acl-acl1.c-Security-fix-on-s.patch \
52 file://0001-dirtyc0w-Include-stdint.h.patch \ 52 file://0001-dirtyc0w-Include-stdint.h.patch \
53 file://0037-faccessat-and-fchmodat-Fix-build-warnings.patch \ 53 file://0037-faccessat-and-fchmodat-Fix-build-warnings.patch \
54 file://0038-syscalls-add_key02-update-to-test-fix-for-nonempty-N.patch \
54 " 55 "
55 56
56S = "${WORKDIR}/git" 57S = "${WORKDIR}/git"