From patchwork Mon Jul 3 11:45:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fathi Boudra X-Patchwork-Id: 106895 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp5669938qge; Mon, 3 Jul 2017 04:45:57 -0700 (PDT) X-Received: by 10.84.217.30 with SMTP id o30mr10333894pli.184.1499082357123; Mon, 03 Jul 2017 04:45:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499082357; cv=none; d=google.com; s=arc-20160816; b=TpU2zz6U/GMDOkMIGxILaD3W37vql181IVOQDiPfBvBhdmnVpzw1Iz4jeH2FXm7icR JEp7cpArYnAC2iLVOBRu3XdkArMEmBSG//r2AkzNyCIABbxTZlgtdjYjshh5krdoRH6N DZj3cp61YLPFeTJAtAstBmOvGbkqXWvfSlF9pL9PZMLGODD+ZCM11AVZoo8NRCdmFRE1 I5ftOghMeccfe3XQh9IgfHHURbfT0McyYShsASn9h4PksRQp4WtIXIS+D/ODuMN58EAu qEgqSSs8aMCz4jdY5MsxFpLQhd+tBNlf7NTfMNoarIIQCBw0jHaCm257rNaoO0fsS6KJ mvWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:message-id:date:to:from :dkim-signature:delivered-to:arc-authentication-results; bh=oUoAEuc0m6CarSP32sBmu3nhzMIZZf0uTtWM9LnxCJ4=; b=KXtwhG8e2FzBXahTPmIhGiPiIU9+G8Nzvrjf4QdPFxvlQm/TZAmb3ExiPaF85qoisr Xu/pWj3eZMXSbsBDRJBBT5eQ6/LCVkA0hBp3/mtCBNuGEecHEdPkvAfgohxXuXn/sibL +Y6njEaZ2QPav6Q4NavmYKrRrwvltUNj/RikwFN6FIQqpIbE6SVNKmvcE31Ke/dCGv+5 yk0Fi7JIWr5XvlDVAu3eJlaAMoGG4BjtHs+gLAwF5YPG5ir9D/whtkADdU12MQSnlKwP VE0t3Q39lVXDHFRvfSv2g2DWTILVp1SW9n1M+2cenj05Z9dDCRp5I4NaNuvVOZOt09A4 dRkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=C8DYC6eT; spf=pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) smtp.mailfrom=openembedded-core-bounces@lists.openembedded.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail.openembedded.org (mail.openembedded.org. [140.211.169.62]) by mx.google.com with ESMTP id r14si99616pgs.480.2017.07.03.04.45.56; Mon, 03 Jul 2017 04:45:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) client-ip=140.211.169.62; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=C8DYC6eT; spf=pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) smtp.mailfrom=openembedded-core-bounces@lists.openembedded.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from review.yoctoproject.org (localhost [127.0.0.1]) by mail.openembedded.org (Postfix) with ESMTP id 4B245780B2; Mon, 3 Jul 2017 11:45:54 +0000 (UTC) X-Original-To: openembedded-core@lists.openembedded.org Delivered-To: openembedded-core@lists.openembedded.org Received: from mail-lf0-f46.google.com (mail-lf0-f46.google.com [209.85.215.46]) by mail.openembedded.org (Postfix) with ESMTP id 2A47A780BD for ; Mon, 3 Jul 2017 11:45:37 +0000 (UTC) Received: by mail-lf0-f46.google.com with SMTP id l13so101187566lfl.1 for ; Mon, 03 Jul 2017 04:45:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=MXqqhJXEXHgOd0wicb4Dv7BrWYKpsinpAZH5f5Q+B8k=; b=C8DYC6eTpQPSYScQdKx8EeZkFtaV8mzrIuaDd1RjhbeNHDG82f6o4PMrAhZZpsEObT YrZfxiNA9YTWh/pQ0tiObw3M/pZGOojKEHPpJXVCghdj0CG2+IdqLx3YofO+ll9MPQ8h iQyD77lDi30IBkUPegTNDCp1fVqQfdmIj/ESU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=MXqqhJXEXHgOd0wicb4Dv7BrWYKpsinpAZH5f5Q+B8k=; b=b2wYgWBZyv9Xr+kv1o5ucvnw7Zv3lxs4nSI+UCKU7kXwNWztqitpoTDW/k4Tiq4hYT mRBYHWZBxQSXQaSwEZsxc7oF8YAOLX2yXyfBnGyDGb6MDLRjxCdJjoG78jOUpjkutQug WhbNR8AAPtso0RVwuXMS6S8QyyxBi6Y75inBXXb2N9lvuhyCPU5w29ik4QPYkVseDWP5 9hVrqOH0/DuOyRz8jzOMgYn1U+APA8O+9DIYX+/KalVvLtgQ+40LqjGlsu5hPJNl4JSE yvzZqyDGk9A1mi0B90MLA3ffn9tipfnnIck/3359TVT64ba4Zk+0IZWLpG8tjDsHbpm/ unHg== X-Gm-Message-State: AIVw111DE4K6zxhLMVVjqAA+M4isfUtmT8eYcvqSDX1nQPoV8D2k/sWY T3jj4+vvxVTM4I7HBtTCPg== X-Received: by 10.46.15.25 with SMTP id 25mr895432ljp.90.1499082338092; Mon, 03 Jul 2017 04:45:38 -0700 (PDT) Received: from localhost.localdomain (a91-156-68-101.elisa-laajakaista.fi. [91.156.68.101]) by smtp.gmail.com with ESMTPSA id 8sm3191545ljw.61.2017.07.03.04.45.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Jul 2017 04:45:36 -0700 (PDT) From: Fathi Boudra To: openembedded-core@lists.openembedded.org Date: Mon, 3 Jul 2017 14:45:34 +0300 Message-Id: <20170703114534.27853-1-fathi.boudra@linaro.org> X-Mailer: git-send-email 2.13.0 Cc: Milosz Wasilewski Subject: [OE-core] [PATCH] ltp: syscalls/add_key02: fix for nonempty NULL payload X-BeenThere: openembedded-core@lists.openembedded.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Patches and discussions about the oe-core layer List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: openembedded-core-bounces@lists.openembedded.org Errors-To: openembedded-core-bounces@lists.openembedded.org Add upstream patch to fix syscalls/add_key02 test for nonempty NULL payload: https://github.com/linux-test-project/ltp/commit/25045624e941ee76a13febd36187e23c6c435507 Signed-off-by: Milosz Wasilewski Signed-off-by: Fathi Boudra --- ...d_key02-update-to-test-fix-for-nonempty-N.patch | 136 +++++++++++++++++++++ meta/recipes-extended/ltp/ltp_20170516.bb | 1 + 2 files changed, 137 insertions(+) create mode 100644 meta/recipes-extended/ltp/ltp/0038-syscalls-add_key02-update-to-test-fix-for-nonempty-N.patch -- 2.13.0 -- _______________________________________________ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core 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 @@ +From 25045624e941ee76a13febd36187e23c6c435507 Mon Sep 17 00:00:00 2001 +From: Eric Biggers +Date: Mon, 12 Jun 2017 11:55:21 -0700 +Subject: [PATCH 01/39] syscalls/add_key02: update to test fix for nonempty + NULL payload + +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 in this case is that the +syscall fail with EFAULT. + +Update the test to expect the fixed behavior from v4.12-rc5, and make +the test more thorough by testing additional key types, including ones +that caused a NULL pointer dereference in unfixed kernels. + +Signed-off-by: Eric Biggers +Upstream-Status: Accepted [https://github.com/linux-test-project/ltp/commit/25045624e941ee76a13febd36187e23c6c435507] +--- + testcases/kernel/syscalls/add_key/add_key02.c | 69 ++++++++++++++++++++------- + 1 file changed, 51 insertions(+), 18 deletions(-) + +diff --git a/testcases/kernel/syscalls/add_key/add_key02.c b/testcases/kernel/syscalls/add_key/add_key02.c +index 866800d6f..2e3308dcd 100644 +--- a/testcases/kernel/syscalls/add_key/add_key02.c ++++ b/testcases/kernel/syscalls/add_key/add_key02.c +@@ -1,5 +1,6 @@ + /****************************************************************************** + * Copyright (c) Crackerjack Project., 2007 * ++ * Copyright (c) 2017 Google, Inc. * + * * + * 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 * +@@ -18,10 +19,17 @@ + ******************************************************************************/ + + /* +- * Basic test for the add_key() syscall. ++ * Test that the add_key() syscall correctly handles a NULL payload with nonzero ++ * length. Specifically, it should fail with EFAULT rather than oopsing the ++ * kernel with a NULL pointer dereference or failing with EINVAL, as it did ++ * before (depending on the key type). This is a regression test for commit ++ * 5649645d725c ("KEYS: fix dereferencing NULL payload with nonzero length"). + * +- * History: Porting from Crackerjack to LTP is done by +- * Manas Kumar Nayak maknayak@in.ibm.com> ++ * Note that none of the key types that exhibited the NULL pointer dereference ++ * are guaranteed to be built into the kernel, so we just test as many as we ++ * can, in the hope of catching one. We also test with the "user" key type for ++ * good measure, although it was one of the types that failed with EINVAL rather ++ * than dereferencing NULL. + */ + + #include "config.h" +@@ -33,36 +41,61 @@ + + #ifdef HAVE_LINUX_KEYCTL_H + struct tcase { +- char *type; +- char *desc; +- void *payload; +- int plen; +- int exp_errno; ++ const char *type; ++ size_t plen; + } tcases[] = { +- {"user", "firstkey", NULL, 1, EINVAL} ++ /* ++ * The payload length we test for each key type needs to pass initial ++ * validation but is otherwise arbitrary. Note: the "rxrpc_s" key type ++ * requires a payload of exactly 8 bytes. ++ */ ++ { "asymmetric", 64 }, ++ { "cifs.idmap", 64 }, ++ { "cifs.spnego", 64 }, ++ { "pkcs7_test", 64 }, ++ { "rxrpc", 64 }, ++ { "rxrpc_s", 8 }, ++ { "user", 64 }, + }; + #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)); ++ TEST(tst_syscall(__NR_add_key, tcases[i].type, "abc:def", ++ NULL, tcases[i].plen, KEY_SPEC_PROCESS_KEYRING)); + + if (TEST_RETURN != -1) { +- tst_res(TFAIL, "add_key() passed unexpectedly"); ++ tst_res(TFAIL, ++ "add_key() with key type '%s' unexpectedly succeeded", ++ tcases[i].type); + return; + } + +- if (TEST_ERRNO == tcases[i].exp_errno) { +- tst_res(TPASS | TTERRNO, "add_key() failed expectedly"); ++ if (TEST_ERRNO == EFAULT) { ++ tst_res(TPASS, "received expected EFAULT with key type '%s'", ++ tcases[i].type); + return; + } + +- tst_res(TFAIL | TTERRNO, +- "add_key() failed unexpectedly, expected %s", +- tst_strerrno(tcases[i].exp_errno)); ++ if (TEST_ERRNO == ENODEV) { ++ tst_res(TCONF, "kernel doesn't support key type '%s'", ++ tcases[i].type); ++ return; ++ } ++ ++ /* ++ * It's possible for the "asymmetric" key type to be supported, but with ++ * no asymmetric key parsers registered. In that case, attempting to ++ * add a key of type asymmetric will fail with EBADMSG. ++ */ ++ if (TEST_ERRNO == EBADMSG && !strcmp(tcases[i].type, "asymmetric")) { ++ tst_res(TCONF, "no asymmetric key parsers are registered"); ++ return; ++ } ++ ++ tst_res(TFAIL | TTERRNO, "unexpected error with key type '%s'", ++ tcases[i].type); + #else + tst_brk(TCONF, "linux/keyctl.h was missing upon compilation."); + #endif /* HAVE_LINUX_KEYCTL_H */ +-- +2.13.0 + 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 \ file://0036-testcases-network-nfsv4-acl-acl1.c-Security-fix-on-s.patch \ file://0001-dirtyc0w-Include-stdint.h.patch \ file://0037-faccessat-and-fchmodat-Fix-build-warnings.patch \ + file://0038-syscalls-add_key02-update-to-test-fix-for-nonempty-N.patch \ " S = "${WORKDIR}/git"