From patchwork Thu Jan 17 00:35:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10767341 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BC7F66C2 for ; Thu, 17 Jan 2019 00:35:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC6D22EA19 for ; Thu, 17 Jan 2019 00:35:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A0A262EB04; Thu, 17 Jan 2019 00:35:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 420FD2EA19 for ; Thu, 17 Jan 2019 00:35:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726818AbfAQAfa (ORCPT ); Wed, 16 Jan 2019 19:35:30 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:46187 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729886AbfAQAf3 (ORCPT ); Wed, 16 Jan 2019 19:35:29 -0500 Received: by mail-pf1-f196.google.com with SMTP id c73so3874762pfe.13 for ; Wed, 16 Jan 2019 16:35:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=VTHWtlVbQul7bfM9w9IYIYA38lGAXNVOLlUfKXeMV5M=; b=QevgCGzKkh4e/Ugp3ZMY4dLllbuXr29HZxgccxdZkw0n3IntXYND3n+DMtUijNA6qD WkWRvoo2fPgWWNIj40dTuRrlHU36mNQjQ6FjBI+5Nnj81zCJ5RqkupYJSIwsuUqx8w1j 5i7V2wC2CIuVMGwHzVkMkXrVcMZfBvflEm4OI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=VTHWtlVbQul7bfM9w9IYIYA38lGAXNVOLlUfKXeMV5M=; b=mJenpqUyUxwRkH9bUA+RyzLlbDHXojsanB56WWNCecKCAiKg/+4SAQ0h4JkLK1xNny ETMf55hn9z0IAX7ZZz/XM8KgAuFu4hYtgNOE9y988ONtn83B1DnhKce197mJNRT5nkUM 0dzVvyJc2CuMiZMt0fRtdy8ZqtDdEq3afWmcSk+TgwCK+MBeDnuSUWDtmZc6//B/x8ap a6mrhBYU0ZOi9L36n8qplZlGnffqB7utgJzupFsDWN53ZVU2U8jv6MEBJ03IVudVOYDR p9cSMd98w0bYTALmWfJk+NXJf+CUVMPjBw7AoEZ43Tw2ENQcdeURa1mOCaaZpbahjigT 20+g== X-Gm-Message-State: AJcUukdPFYZfH0u6ShWFLIOi29cpgjLlllcRuGVBx5IoZCtnrE+c7jXp uYz7XVZIeCgIRfqorXAvp0FGzg== X-Google-Smtp-Source: ALg8bN67xGmPFowvxVPbfzIvfzfUpQR2qQbQlxTizNILrvC3ermxc7V8zXKdKPZPNQ7S280neLL4Gw== X-Received: by 2002:a63:c848:: with SMTP id l8mr11311427pgi.78.1547685327243; Wed, 16 Jan 2019 16:35:27 -0800 (PST) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id d3sm7730628pgl.64.2019.01.16.16.35.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 Jan 2019 16:35:26 -0800 (PST) Date: Wed, 16 Jan 2019 16:35:25 -0800 From: Kees Cook To: Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Tycho Andersen , James Morris Subject: [PATCH] selftests/seccomp: Abort without user notification support Message-ID: <20190117003525.GA37918@beast> MIME-Version: 1.0 Content-Disposition: inline Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In the face of missing user notification support, the self test needs to stop executing a test (ASSERT_*) instead of just reporting and continuing (EXPECT_*). This adjusts the user notification tests to do that where needed. Reported-by: Shuah Khan Fixes: 6a21cc50f0c7 ("seccomp: add a return code to trap to userspace") Signed-off-by: Kees Cook Reviewed-by: Tycho Andersen --- tools/testing/selftests/seccomp/seccomp_bpf.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c index 067cb4607d6c..496a9a8c773a 100644 --- a/tools/testing/selftests/seccomp/seccomp_bpf.c +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c @@ -3044,7 +3044,7 @@ TEST(user_notification_basic) /* Check that the basic notification machinery works */ listener = user_trap_syscall(__NR_getpid, SECCOMP_FILTER_FLAG_NEW_LISTENER); - EXPECT_GE(listener, 0); + ASSERT_GE(listener, 0); /* Installing a second listener in the chain should EBUSY */ EXPECT_EQ(user_trap_syscall(__NR_getpid, @@ -3103,7 +3103,7 @@ TEST(user_notification_kill_in_middle) listener = user_trap_syscall(__NR_getpid, SECCOMP_FILTER_FLAG_NEW_LISTENER); - EXPECT_GE(listener, 0); + ASSERT_GE(listener, 0); /* * Check that nothing bad happens when we kill the task in the middle @@ -3152,7 +3152,7 @@ TEST(user_notification_signal) listener = user_trap_syscall(__NR_gettid, SECCOMP_FILTER_FLAG_NEW_LISTENER); - EXPECT_GE(listener, 0); + ASSERT_GE(listener, 0); pid = fork(); ASSERT_GE(pid, 0); @@ -3215,7 +3215,7 @@ TEST(user_notification_closed_listener) listener = user_trap_syscall(__NR_getpid, SECCOMP_FILTER_FLAG_NEW_LISTENER); - EXPECT_GE(listener, 0); + ASSERT_GE(listener, 0); /* * Check that we get an ENOSYS when the listener is closed. @@ -3376,7 +3376,7 @@ TEST(seccomp_get_notif_sizes) { struct seccomp_notif_sizes sizes; - EXPECT_EQ(seccomp(SECCOMP_GET_NOTIF_SIZES, 0, &sizes), 0); + ASSERT_EQ(seccomp(SECCOMP_GET_NOTIF_SIZES, 0, &sizes), 0); EXPECT_EQ(sizes.seccomp_notif, sizeof(struct seccomp_notif)); EXPECT_EQ(sizes.seccomp_notif_resp, sizeof(struct seccomp_notif_resp)); }