From: Eric Biggers <ebiggers3@gmail.com> To: keyrings@vger.kernel.org Subject: [PATCH 1/2] syscalls/add_key02: remove test Date: Mon, 05 Jun 2017 17:48:10 +0000 [thread overview] Message-ID: <20170605174811.95267-2-ebiggers3@gmail.com> (raw) From: Eric Biggers <ebiggers@google.com> add_key02 was supposed to be a "Basic test for the add_key() syscall", but it actually happened to test the obscure case of passing a NULL payload with nonzero length. This case was mishandled by the kernel, which either returned EINVAL or crashed with a NULL pointer dereference, depending on the key type. (The former applied to the test, as it used the "user" key type.) The expected behavior is that the syscall fail with EFAULT. As this is being fixed by the kernel patch "KEYS: fix dereferencing NULL payload with nonzero length", the test needed to be updated. To avoid making it appear as a regression, just remove the test; the next patch will add a replacement test as add_key03. The new test will also be more thorough as it will test other key types besides "user", including ones that cause a NULL pointer dereference in unfixed kernels. Signed-off-by: Eric Biggers <ebiggers@google.com> --- runtest/syscalls | 1 - testcases/kernel/syscalls/.gitignore | 1 - testcases/kernel/syscalls/add_key/add_key02.c | 74 --------------------------- 3 files changed, 76 deletions(-) delete mode 100644 testcases/kernel/syscalls/add_key/add_key02.c diff --git a/runtest/syscalls b/runtest/syscalls index fe5227290..0c3c46e57 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -12,7 +12,6 @@ access04 access04 acct01 acct01 add_key01 add_key01 -add_key02 add_key02 adjtimex01 adjtimex01 adjtimex02 adjtimex02 diff --git a/testcases/kernel/syscalls/.gitignore b/testcases/kernel/syscalls/.gitignore index c14c4e66b..5b8df06f5 100644 --- a/testcases/kernel/syscalls/.gitignore +++ b/testcases/kernel/syscalls/.gitignore @@ -7,7 +7,6 @@ /access/access04 /acct/acct01 /add_key/add_key01 -/add_key/add_key02 /adjtimex/adjtimex01 /adjtimex/adjtimex02 /alarm/alarm01 diff --git a/testcases/kernel/syscalls/add_key/add_key02.c b/testcases/kernel/syscalls/add_key/add_key02.c deleted file mode 100644 index 866800d6f..000000000 --- a/testcases/kernel/syscalls/add_key/add_key02.c +++ /dev/null @@ -1,74 +0,0 @@ -/****************************************************************************** - * Copyright (c) Crackerjack Project., 2007 * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See * - * the GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the Free Software Foundation, * - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * * - ******************************************************************************/ - -/* - * Basic test for the add_key() syscall. - * - * History: Porting from Crackerjack to LTP is done by - * Manas Kumar Nayak maknayak@in.ibm.com> - */ - -#include "config.h" -#ifdef HAVE_LINUX_KEYCTL_H -# include <linux/keyctl.h> -#endif -#include "tst_test.h" -#include "linux_syscall_numbers.h" - -#ifdef HAVE_LINUX_KEYCTL_H -struct tcase { - char *type; - char *desc; - void *payload; - int plen; - int exp_errno; -} tcases[] = { - {"user", "firstkey", NULL, 1, EINVAL} -}; -#endif /* HAVE_LINUX_KEYCTL_H */ - -static void verify_add_key(unsigned int i) -{ -#ifdef HAVE_LINUX_KEYCTL_H - TEST(tst_syscall(__NR_add_key, tcases[i].type, tcases[i].desc, - tcases[i].payload, tcases[i].plen, - KEY_SPEC_USER_KEYRING)); - - if (TEST_RETURN != -1) { - tst_res(TFAIL, "add_key() passed unexpectedly"); - return; - } - - if (TEST_ERRNO = tcases[i].exp_errno) { - tst_res(TPASS | TTERRNO, "add_key() failed expectedly"); - return; - } - - tst_res(TFAIL | TTERRNO, - "add_key() failed unexpectedly, expected %s", - tst_strerrno(tcases[i].exp_errno)); -#else - tst_brk(TCONF, "linux/keyctl.h was missing upon compilation."); -#endif /* HAVE_LINUX_KEYCTL_H */ -} - -static struct tst_test test = { - .tcnt = ARRAY_SIZE(tcases), - .test = verify_add_key, -}; -- 2.13.0.506.g27d5fe0cd-goog
WARNING: multiple messages have this Message-ID (diff)
From: Eric Biggers <ebiggers3@gmail.com> To: ltp@lists.linux.it Subject: [LTP] [PATCH 1/2] syscalls/add_key02: remove test Date: Mon, 5 Jun 2017 10:48:10 -0700 [thread overview] Message-ID: <20170605174811.95267-2-ebiggers3@gmail.com> (raw) In-Reply-To: <20170605174811.95267-1-ebiggers3@gmail.com> From: Eric Biggers <ebiggers@google.com> add_key02 was supposed to be a "Basic test for the add_key() syscall", but it actually happened to test the obscure case of passing a NULL payload with nonzero length. This case was mishandled by the kernel, which either returned EINVAL or crashed with a NULL pointer dereference, depending on the key type. (The former applied to the test, as it used the "user" key type.) The expected behavior is that the syscall fail with EFAULT. As this is being fixed by the kernel patch "KEYS: fix dereferencing NULL payload with nonzero length", the test needed to be updated. To avoid making it appear as a regression, just remove the test; the next patch will add a replacement test as add_key03. The new test will also be more thorough as it will test other key types besides "user", including ones that cause a NULL pointer dereference in unfixed kernels. Signed-off-by: Eric Biggers <ebiggers@google.com> --- runtest/syscalls | 1 - testcases/kernel/syscalls/.gitignore | 1 - testcases/kernel/syscalls/add_key/add_key02.c | 74 --------------------------- 3 files changed, 76 deletions(-) delete mode 100644 testcases/kernel/syscalls/add_key/add_key02.c diff --git a/runtest/syscalls b/runtest/syscalls index fe5227290..0c3c46e57 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -12,7 +12,6 @@ access04 access04 acct01 acct01 add_key01 add_key01 -add_key02 add_key02 adjtimex01 adjtimex01 adjtimex02 adjtimex02 diff --git a/testcases/kernel/syscalls/.gitignore b/testcases/kernel/syscalls/.gitignore index c14c4e66b..5b8df06f5 100644 --- a/testcases/kernel/syscalls/.gitignore +++ b/testcases/kernel/syscalls/.gitignore @@ -7,7 +7,6 @@ /access/access04 /acct/acct01 /add_key/add_key01 -/add_key/add_key02 /adjtimex/adjtimex01 /adjtimex/adjtimex02 /alarm/alarm01 diff --git a/testcases/kernel/syscalls/add_key/add_key02.c b/testcases/kernel/syscalls/add_key/add_key02.c deleted file mode 100644 index 866800d6f..000000000 --- a/testcases/kernel/syscalls/add_key/add_key02.c +++ /dev/null @@ -1,74 +0,0 @@ -/****************************************************************************** - * Copyright (c) Crackerjack Project., 2007 * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See * - * the GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the Free Software Foundation, * - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * * - ******************************************************************************/ - -/* - * Basic test for the add_key() syscall. - * - * History: Porting from Crackerjack to LTP is done by - * Manas Kumar Nayak maknayak@in.ibm.com> - */ - -#include "config.h" -#ifdef HAVE_LINUX_KEYCTL_H -# include <linux/keyctl.h> -#endif -#include "tst_test.h" -#include "linux_syscall_numbers.h" - -#ifdef HAVE_LINUX_KEYCTL_H -struct tcase { - char *type; - char *desc; - void *payload; - int plen; - int exp_errno; -} tcases[] = { - {"user", "firstkey", NULL, 1, EINVAL} -}; -#endif /* HAVE_LINUX_KEYCTL_H */ - -static void verify_add_key(unsigned int i) -{ -#ifdef HAVE_LINUX_KEYCTL_H - TEST(tst_syscall(__NR_add_key, tcases[i].type, tcases[i].desc, - tcases[i].payload, tcases[i].plen, - KEY_SPEC_USER_KEYRING)); - - if (TEST_RETURN != -1) { - tst_res(TFAIL, "add_key() passed unexpectedly"); - return; - } - - if (TEST_ERRNO == tcases[i].exp_errno) { - tst_res(TPASS | TTERRNO, "add_key() failed expectedly"); - return; - } - - tst_res(TFAIL | TTERRNO, - "add_key() failed unexpectedly, expected %s", - tst_strerrno(tcases[i].exp_errno)); -#else - tst_brk(TCONF, "linux/keyctl.h was missing upon compilation."); -#endif /* HAVE_LINUX_KEYCTL_H */ -} - -static struct tst_test test = { - .tcnt = ARRAY_SIZE(tcases), - .test = verify_add_key, -}; -- 2.13.0.506.g27d5fe0cd-goog
next reply other threads:[~2017-06-05 17:48 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-06-05 17:48 Eric Biggers [this message] 2017-06-05 17:48 ` [LTP] [PATCH 1/2] syscalls/add_key02: remove test Eric Biggers -- strict thread matches above, loose matches on Subject: below -- 2017-06-06 12:06 [LTP] [PATCH 2/2] syscalls/add_key03: add test for NULL payload with nonzero length Cyril Hrubis 2017-06-06 12:06 ` Cyril Hrubis 2017-06-06 17:06 ` Eric Biggers 2017-06-06 17:06 ` Eric Biggers 2017-06-06 11:55 [LTP] [PATCH 0/2] ltp: update add_key tests for nonempty NULL payload fix Cyril Hrubis 2017-06-06 11:55 ` Cyril Hrubis 2017-06-06 17:04 ` Eric Biggers 2017-06-06 17:04 ` Eric Biggers 2017-06-07 13:51 ` Cyril Hrubis 2017-06-07 13:51 ` Cyril Hrubis 2017-06-05 17:48 [PATCH 2/2] syscalls/add_key03: add test for NULL payload with nonzero length Eric Biggers 2017-06-05 17:48 ` [LTP] " Eric Biggers 2017-06-05 17:48 [PATCH 0/2] ltp: update add_key tests for nonempty NULL payload fix Eric Biggers 2017-06-05 17:48 ` [LTP] " Eric Biggers
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=20170605174811.95267-2-ebiggers3@gmail.com \ --to=ebiggers3@gmail.com \ --cc=keyrings@vger.kernel.org \ /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: linkBe 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.