From patchwork Mon Jul 20 19:49:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erico Nunes X-Patchwork-Id: 1332618 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=jGyt22Ry; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B9XPl72Qwz9sRR for ; Tue, 21 Jul 2020 05:50:02 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id DD5CF3C4E1F for ; Mon, 20 Jul 2020 21:49:58 +0200 (CEST) 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 [IPv6:2001:4b78:1:20::7]) by picard.linux.it (Postfix) with ESMTP id 4252E3C072E for ; Mon, 20 Jul 2020 21:49:55 +0200 (CEST) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by in-7.smtp.seeweb.it (Postfix) with ESMTP id D53432009F4 for ; Mon, 20 Jul 2020 21:49:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595274593; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=KWG8Fp3veKAV2YINLQMro/M7ocrQnzY5wjCnPmyyO7E=; b=jGyt22RytcwNnsy7afprvJy0eu0HdWCRSHHvxyYS70ltPx+FUmHalBcYl+Pg/pQnFmfuZA IFKvtxd32jDWWMRAneaWJqqm55S+gQViLXKwcaudscjse80XDq7V3a9oWQ6EgSXS/L/sSI ASukr188uAHJcWgt7OT2bi7sxdp1TPE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-188-w8nV9yTvNuiKwKYzSBLTQw-1; Mon, 20 Jul 2020 15:49:48 -0400 X-MC-Unique: w8nV9yTvNuiKwKYzSBLTQw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ADC35100AA30 for ; Mon, 20 Jul 2020 19:49:47 +0000 (UTC) Received: from centennial.enunes.eu.com (unknown [10.40.192.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED8B510021B3; Mon, 20 Jul 2020 19:49:46 +0000 (UTC) From: Erico Nunes To: ltp@lists.linux.it Date: Mon, 20 Jul 2020 21:49:18 +0200 Message-Id: <20200720194920.22784-1-ernunes@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Virus-Scanned: clamav-milter 0.99.2 at in-7.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,SPF_HELO_NONE,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 Subject: [LTP] [PATCH 1/3] lib: add function to check for kernel lockdown X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Some syscalls are not available if the kernel is booted using the 'lockdown' feature. That can cause some tests to report fail, showing a message like: Lockdown: iopl01: iopl is restricted; see man kernel_lockdown.7 This patch adds a function that can be used by tests to check for this case, so tests can be skipped rather than reporting a test failure. Signed-off-by: Erico Nunes --- include/tst_lockdown.h | 8 ++++++++ include/tst_test.h | 1 + lib/tst_lockdown.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 include/tst_lockdown.h create mode 100644 lib/tst_lockdown.c diff --git a/include/tst_lockdown.h b/include/tst_lockdown.h new file mode 100644 index 000000000..8db26d943 --- /dev/null +++ b/include/tst_lockdown.h @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#ifndef TST_LOCKDOWN_H +#define TST_LOCKDOWN_H + +void tst_lockdown_skip(void); + +#endif /* TST_LOCKDOWN_H */ diff --git a/include/tst_test.h b/include/tst_test.h index b84f7b9dd..b02de4597 100644 --- a/include/tst_test.h +++ b/include/tst_test.h @@ -40,6 +40,7 @@ #include "tst_hugepage.h" #include "tst_assert.h" #include "tst_cgroup.h" +#include "tst_lockdown.h" /* * Reports testcase result. diff --git a/lib/tst_lockdown.c b/lib/tst_lockdown.c new file mode 100644 index 000000000..d57a6bdf3 --- /dev/null +++ b/lib/tst_lockdown.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#define TST_NO_DEFAULT_MAIN + +#include +#include +#include + +#include "tst_test.h" +#include "tst_safe_macros.h" +#include "tst_safe_stdio.h" +#include "tst_lockdown.h" + +void tst_lockdown_skip(void) +{ + char line[BUFSIZ]; + FILE *file; + + if (access("/sys/kernel/security/lockdown", F_OK) != 0) + return; + + file = SAFE_FOPEN("/sys/kernel/security/lockdown", "r"); + fgets(line, sizeof(line), file); + SAFE_FCLOSE(file); + + if (strstr(line, "[none]") == NULL) + tst_brk(TCONF, "Kernel is locked down, skip this test."); +} From patchwork Mon Jul 20 19:49:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erico Nunes X-Patchwork-Id: 1332620 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=gVzbOtZS; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B9XQ621wmz9sRR for ; Tue, 21 Jul 2020 05:50:22 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id EF4E93C4E21 for ; Mon, 20 Jul 2020 21:50:18 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [IPv6:2001:4b78:1:20::5]) by picard.linux.it (Postfix) with ESMTP id 5CD063C4E25 for ; Mon, 20 Jul 2020 21:49:58 +0200 (CEST) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by in-5.smtp.seeweb.it (Postfix) with ESMTP id A840D600484 for ; Mon, 20 Jul 2020 21:48:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595274595; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bBSAw9dAcQt5+BTgXGU6x/rZUmiV3cEVfmSu1H22Aq8=; b=gVzbOtZSD06UaoUZateaD6vDwhDx697HwCZpteX+j+1cX8e6bPjrhzP4kF3puRlFRgrH+6 a27EF3TPApLJE716iFfN7VKXwzeKfOlEolHKB6cyxIWMT2YFKH4kzghywGU4QNP4tGYH+P i8KAHmEZ6O0VKDxrxdQI//izbqBDItU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-411-utRZWuELNoqK2OGQFW3gmw-1; Mon, 20 Jul 2020 15:49:53 -0400 X-MC-Unique: utRZWuELNoqK2OGQFW3gmw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6CCBF100AA23 for ; Mon, 20 Jul 2020 19:49:51 +0000 (UTC) Received: from centennial.enunes.eu.com (unknown [10.40.192.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id ACDF210027AC; Mon, 20 Jul 2020 19:49:50 +0000 (UTC) From: Erico Nunes To: ltp@lists.linux.it Date: Mon, 20 Jul 2020 21:49:19 +0200 Message-Id: <20200720194920.22784-2-ernunes@redhat.com> In-Reply-To: <20200720194920.22784-1-ernunes@redhat.com> References: <20200720194920.22784-1-ernunes@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Virus-Scanned: clamav-milter 0.99.2 at in-5.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-5.smtp.seeweb.it Subject: [LTP] [PATCH 2/3] ioperm01: skip test if kernel is locked down X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" ioperm is restricted under kernel lockdown. Signed-off-by: Erico Nunes --- testcases/kernel/syscalls/ioperm/ioperm01.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/testcases/kernel/syscalls/ioperm/ioperm01.c b/testcases/kernel/syscalls/ioperm/ioperm01.c index 4c5c0e6ea..d1d633b20 100644 --- a/testcases/kernel/syscalls/ioperm/ioperm01.c +++ b/testcases/kernel/syscalls/ioperm/ioperm01.c @@ -42,6 +42,9 @@ static void verify_ioperm(void) static void setup(void) { + /* ioperm is restricted under kernel lockdown. */ + tst_lockdown_skip(); + /* * The value of IO_BITMAP_BITS (include/asm-i386/processor.h) changed * from kernel 2.6.8 to permit 16-bits ioperm From patchwork Mon Jul 20 19:49:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erico Nunes X-Patchwork-Id: 1332619 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=MbF+IaOm; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B9XPw4WZ3z9sRR for ; Tue, 21 Jul 2020 05:50:12 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id E20503C4E1C for ; Mon, 20 Jul 2020 21:50:09 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [217.194.8.5]) by picard.linux.it (Postfix) with ESMTP id 928503C4E2B for ; Mon, 20 Jul 2020 21:49:59 +0200 (CEST) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by in-5.smtp.seeweb.it (Postfix) with ESMTP id 4B8126005D1 for ; Mon, 20 Jul 2020 21:48:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595274597; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=31nFcdvYz7h2yr/bdNj+wc/7U2Ozj9yKic77J9pL7c8=; b=MbF+IaOmxNTSoYIKioVzKooxDgnxjgW58uRfleN7wiRTv8ZhIjIZsNgG3C/9wu5DwSvKaY j3DXyXJQb0sjCQ3vFHeXRpx2TOyz8LpFGEi4oZWEzMIKJaCDmY8j89m+03PANeFRoW+KOK fWCr6IQDG1DzsMa/xk8lz9+Vrz28Wz4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-364-gNTEX3nZO-O1c_gLGq0IKQ-1; Mon, 20 Jul 2020 15:49:56 -0400 X-MC-Unique: gNTEX3nZO-O1c_gLGq0IKQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 57E3910BF for ; Mon, 20 Jul 2020 19:49:55 +0000 (UTC) Received: from centennial.enunes.eu.com (unknown [10.40.192.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id 97A1710021B3; Mon, 20 Jul 2020 19:49:54 +0000 (UTC) From: Erico Nunes To: ltp@lists.linux.it Date: Mon, 20 Jul 2020 21:49:20 +0200 Message-Id: <20200720194920.22784-3-ernunes@redhat.com> In-Reply-To: <20200720194920.22784-1-ernunes@redhat.com> References: <20200720194920.22784-1-ernunes@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Virus-Scanned: clamav-milter 0.99.2 at in-5.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-5.smtp.seeweb.it Subject: [LTP] [PATCH 3/3] iopl01: skip test if kernel is locked down X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" iopl is restricted under kernel lockdown. Signed-off-by: Erico Nunes --- testcases/kernel/syscalls/iopl/iopl01.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/testcases/kernel/syscalls/iopl/iopl01.c b/testcases/kernel/syscalls/iopl/iopl01.c index edf586cd1..4237d3f10 100644 --- a/testcases/kernel/syscalls/iopl/iopl01.c +++ b/testcases/kernel/syscalls/iopl/iopl01.c @@ -42,6 +42,12 @@ static void verify_iopl(void) } } +static void setup(void) +{ + /* iopl is restricted under kernel lockdown. */ + tst_lockdown_skip(); +} + static void cleanup(void) { /* @@ -54,6 +60,7 @@ static void cleanup(void) static struct tst_test test = { .test_all = verify_iopl, .needs_root = 1, + .setup = setup, .cleanup = cleanup, };