From patchwork Tue Mar 13 15:24:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Palethorpe X-Patchwork-Id: 885173 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.com Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 400zF02sJtz9sSp for ; Wed, 14 Mar 2018 02:25:08 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id D67303E7832 for ; Tue, 13 Mar 2018 16:25:05 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [217.194.8.7]) by picard.linux.it (Postfix) with ESMTP id 6F1BB3E6FC2 for ; Tue, 13 Mar 2018 16:25:01 +0100 (CET) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-7.smtp.seeweb.it (Postfix) with ESMTPS id 41ACC200061 for ; Tue, 13 Mar 2018 16:24:59 +0100 (CET) Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 916FFABE0; Tue, 13 Mar 2018 15:24:59 +0000 (UTC) From: Richard Palethorpe To: ltp@lists.linux.it Date: Tue, 13 Mar 2018 16:24:47 +0100 Message-Id: <20180313152448.7480-1-rpalethorpe@suse.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180313105541.GB14611@rei> References: <20180313105541.GB14611@rei> X-Virus-Scanned: clamav-milter 0.99.2 at in-7.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=-0.0 required=7.0 tests=SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-7.smtp.seeweb.it Cc: Richard Palethorpe Subject: [LTP] [PATCH v2 1/2] lib: Add TRERRNO to tst_res and remove sign when present X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Some system calls and libraries pass the error code back to the user in the return value. Sometimes it is inverted, sometimes not. This allows TRERRNO to be passed to tst_res which then causes it to print the error code in TEST_RETURN. Signed-off-by: Richard Palethorpe --- I think we have to branch on TEST_RETURN < 0 because of two's complement integer representation, but I could be missing a trick here. lib/tst_res.c | 4 ++-- lib/tst_test.c | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/tst_res.c b/lib/tst_res.c index b56f37db0..b4bc09179 100644 --- a/lib/tst_res.c +++ b/lib/tst_res.c @@ -346,10 +346,10 @@ static void tst_print(const char *tcid, int tnum, int ttype, const char *tmesg) } if (ttype & TRERRNO) { + err = TEST_RETURN < 0 ? -(int)TEST_RETURN : (int)TEST_RETURN; size += snprintf(message + size, sizeof(message) - size, ": TEST_RETURN=%s(%i): %s", - tst_strerrno(TEST_RETURN), (int)TEST_RETURN, - strerror(TEST_RETURN)); + tst_strerrno(err), err, strerror(err)); } if (size + 1 >= sizeof(message)) { diff --git a/lib/tst_test.c b/lib/tst_test.c index 2cf35ed66..00b8ccb69 100644 --- a/lib/tst_test.c +++ b/lib/tst_test.c @@ -215,6 +215,11 @@ static void print_result(const char *file, const int lineno, int ttype, if (ttype & TTERRNO) str_errno = tst_strerrno(TEST_ERRNO); + if (ttype & TRERRNO) { + ret = TEST_RETURN < 0 ? -(int)TEST_RETURN : (int)TEST_RETURN; + str_errno = tst_strerrno(ret); + } + ret = snprintf(str, size, "%s:%i: ", file, lineno); str += ret; size -= ret; From patchwork Tue Mar 13 15:24:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Palethorpe X-Patchwork-Id: 885174 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.com Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 400zDx5TjKz9s9l for ; Wed, 14 Mar 2018 02:25:05 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 2A3583E773B for ; Tue, 13 Mar 2018 16:25:03 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [217.194.8.3]) by picard.linux.it (Postfix) with ESMTP id 694B03E6B32 for ; Tue, 13 Mar 2018 16:25:01 +0100 (CET) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id 5874C1A008B9 for ; Tue, 13 Mar 2018 16:25:00 +0100 (CET) Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id CA183AC92; Tue, 13 Mar 2018 15:24:59 +0000 (UTC) From: Richard Palethorpe To: ltp@lists.linux.it Date: Tue, 13 Mar 2018 16:24:48 +0100 Message-Id: <20180313152448.7480-2-rpalethorpe@suse.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180313105541.GB14611@rei> References: <20180313105541.GB14611@rei> X-Virus-Scanned: clamav-milter 0.99.2 at in-3.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=-0.0 required=7.0 tests=SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-3.smtp.seeweb.it Cc: Richard Palethorpe Subject: [LTP] [PATCH v2 2/2] cve-2015-3290: Handle 16-bit segments being disabled X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" If modify_ldt fails with EINVAL then we can only assume the kernel has 16-bit data segments disabled. Signed-off-by: Richard Palethorpe --- testcases/cve/cve-2015-3290.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/testcases/cve/cve-2015-3290.c b/testcases/cve/cve-2015-3290.c index 87c9c956c..631702e2e 100644 --- a/testcases/cve/cve-2015-3290.c +++ b/testcases/cve/cve-2015-3290.c @@ -215,8 +215,13 @@ static void set_ldt(void) .useable = 0 }; - if (tst_syscall(__NR_modify_ldt, 1, &data_desc, sizeof(data_desc)) != 0) - tst_brk(TBROK | TERRNO, "modify_ldt"); + TEST(tst_syscall(__NR_modify_ldt, 1, &data_desc, sizeof(data_desc))); + if (TEST_RETURN == -EINVAL) { + tst_brk(TCONF | TRERRNO, + "modify_ldt: 16-bit data segments are probably disabled"); + } else if (TEST_RETURN != 0) { + tst_brk(TBROK | TRERRNO, "modify_ldt"); + } } static void try_corrupt_stack(unsigned short orig_ss) @@ -474,6 +479,8 @@ static void run(void) SAFE_WAITPID(pid, &status, 0); if (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV) tst_res(TFAIL, "corrupted NMI stack"); + else if (WIFEXITED(status) && WEXITSTATUS(status) != 0) + tst_res(WEXITSTATUS(status), "Propogate child status"); } static struct tst_test test = {