From patchwork Sun Jan 27 09:43:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10782743 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 C4BDA1823 for ; Sun, 27 Jan 2019 09:44:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABF8C2881C for ; Sun, 27 Jan 2019 09:44:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D7F628817; Sun, 27 Jan 2019 09:44:00 +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 2FC5C28812 for ; Sun, 27 Jan 2019 09:44:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726671AbfA0Jn7 (ORCPT ); Sun, 27 Jan 2019 04:43:59 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:41898 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726419AbfA0Jn7 (ORCPT ); Sun, 27 Jan 2019 04:43:59 -0500 Received: by mail-pl1-f195.google.com with SMTP id u6so6450061plm.8 for ; Sun, 27 Jan 2019 01:43:58 -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=4wt96ezv21X1O+EFi8O9ramir52ck0BWI5x6GktBbJY=; b=Z95qUwXkhvKOLOyHkPKceuSKDClXQUBMS3157K9afZ2TgwBC8Fy9nm8OS17A5uCjlN qE2Wy1y5km6hlMyidwWZBLdjR07tfQQxYhlINZBPsBLuJaueAlNbQDC+BEuiLMg58QUM wF4LWQc5MUheFNd70xznWLsgcs3diRK4uhtvY= 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=4wt96ezv21X1O+EFi8O9ramir52ck0BWI5x6GktBbJY=; b=Q6jbW3/ZWiHn/Q0wIgfRHc5lnPRCNOCb7xiJQIlqUFw9sOwG1EL0x6hddV6gE62H68 xY1nGTn8SIG0b97W5+e+JgOVg8PY7O3SkXxnajZ6syVGUApNl5KgZBLDWf6kA8lW3ykF IjUPuhJ8rH5jByQz3RNyIP1WznEuc9wbyLpeiX6krvlz7Cofn7UkQQlI5S1+IsmalKww VkHZOt8+E16JhQdhed1n8SZ9Rp+xvy1yhx5dy2+mu5AzjdmQb3DR3I57gaPYnaQ9M5ML YPN6TzqejuxQ1Y/pegQvmyuUfukBUuBD9mys+l2oVYSPzzgeIAdxDjTT9n/qMGfGVNfK 9RyQ== X-Gm-Message-State: AJcUukf0L2yTQDfG41CfPG2yxZ15oDHwB8/3071ELzPa8jcB7s9vUwB4 UsXm4oRYYavWlOF6xKfUG+4Kr2isqLw= X-Google-Smtp-Source: ALg8bN6kobbEzXRunvrsIBXKYTv54dvAGl0GvYxWjjpxX2Ey+UdII3q+gq8ncnWRU/bD/TTzM6Xc/g== X-Received: by 2002:a17:902:7c82:: with SMTP id y2mr17393048pll.33.1548582238647; Sun, 27 Jan 2019 01:43:58 -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 h69sm37401699pge.4.2019.01.27.01.43.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 27 Jan 2019 01:43:57 -0800 (PST) Date: Sun, 27 Jan 2019 01:43:57 -0800 From: Kees Cook To: Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, ndesaulniers@google.com Subject: [PATCH] selftests/seccomp: Actually sleep for 1/10th second Message-ID: <20190127094357.GA9436@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 Clang noticed that some none-zero sleep()s were actually using zero anyway. This switches to nanosleep() to gain sub-second granularity. seccomp_bpf.c:2625:9: warning: implicit conversion from 'double' to 'unsigned int' changes value from 0.1 to 0 [-Wliteral-conversion] sleep(0.1); ~~~~~ ^~~ Signed-off-by: Kees Cook Reviewed-by: Nick Desaulniers --- tools/testing/selftests/seccomp/seccomp_bpf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c index 067cb4607d6c..a9f278c13f13 100644 --- a/tools/testing/selftests/seccomp/seccomp_bpf.c +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c @@ -2569,6 +2569,7 @@ TEST_F(TSYNC, two_siblings_not_under_filter) { long ret, sib; void *status; + struct timespec delay = { .tv_nsec = 100000000 }; ASSERT_EQ(0, prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)) { TH_LOG("Kernel does not support PR_SET_NO_NEW_PRIVS!"); @@ -2622,7 +2623,7 @@ TEST_F(TSYNC, two_siblings_not_under_filter) EXPECT_EQ(SIBLING_EXIT_UNKILLED, (long)status); /* Poll for actual task death. pthread_join doesn't guarantee it. */ while (!kill(self->sibling[sib].system_tid, 0)) - sleep(0.1); + nanosleep(&delay, NULL); /* Switch to the remaining sibling */ sib = !sib; @@ -2647,7 +2648,7 @@ TEST_F(TSYNC, two_siblings_not_under_filter) EXPECT_EQ(0, (long)status); /* Poll for actual task death. pthread_join doesn't guarantee it. */ while (!kill(self->sibling[sib].system_tid, 0)) - sleep(0.1); + nanosleep(&delay, NULL); ret = seccomp(SECCOMP_SET_MODE_FILTER, SECCOMP_FILTER_FLAG_TSYNC, &self->apply_prog);