Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp768525ybt; Fri, 10 Jul 2020 11:52:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0LLxGr3mzK1DQyZ+XjB/husg9zp5DT2uvQ0ZNeLBU/AesqULeMEDtgnb7uAhIRKE42wFk X-Received: by 2002:a05:6402:1d97:: with SMTP id dk23mr80197451edb.1.1594407158159; Fri, 10 Jul 2020 11:52:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594407158; cv=none; d=google.com; s=arc-20160816; b=wd/s7NeIWVT1Wbs30cKhGZqxOeBlWfWqUZcnavC0hapzPjMrt7xYvlkyB/0Y/AJYNX MXZ0ddoYaoMxKy0i5irU/RsbVTwDArGaIZS3gk3ZXVhb7r8zNOzYizvluRV9/zJubr+O trUg6YkchKXwxVT0Hl15Tz6ABYZBWPllsVFtj9QK6ntczBidxt4GLEtf+oMzKaZXiuIO QNhjYiV5iQSwvgHynGq0FlXlzq8/uiTP4cGFZJYqPAgksbYoDaTtnPG2iR0ZibPjAqj/ 0RWRbooX5j3B73EhFc+if4G/wEAHYAlZSkMqBckzlpO+t0KRlBkIQG4j0qyTe7c5TgLY 0crQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Bl55R7MkjCz9LQEDWeY819kEKM3Vq/nTi6UOAyX5DJc=; b=dcKDVkaVgZQswFfc8ofnc+WrNzb6MeM/d+cpJYRsyi+qres0Ug9OkoAkRBwN7LTIkZ wvrUM9NsHSY/GxT0EFkr4CIc5gjdA43czY9SUUwkxT3riEX8X7l8EXZ4/57SrI3WHWSv RKkIPmUbWaasIeSqkI3+5m7EMI+5V9iO6uqYmA3jkMxnkass7QMQvvghPaVpxBEFGDsJ WMh2adun3ImZsE4AcoezSdAeKa2d02ERXVsW+lVTse99M8QxKp+WW0xs0RmaShIMBNTz HuU8DWRC8MjaFlcktjxVihF0Jg0AXrFcIKZaroZVb8FBeGT6l12GbV7+6vubny4/sKu9 Jrnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=GJY6d9mN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c2si5118780edf.278.2020.07.10.11.52.15; Fri, 10 Jul 2020 11:52:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=GJY6d9mN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728183AbgGJSwC (ORCPT + 99 others); Fri, 10 Jul 2020 14:52:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728003AbgGJSwB (ORCPT ); Fri, 10 Jul 2020 14:52:01 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B823C08C5DC for ; Fri, 10 Jul 2020 11:52:01 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id 72so2623267ple.0 for ; Fri, 10 Jul 2020 11:52:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Bl55R7MkjCz9LQEDWeY819kEKM3Vq/nTi6UOAyX5DJc=; b=GJY6d9mNhmHw5jxxiLKCkRvwD/9havQMHLpzsemfm1jjrvdMDw+5WU4aVAmEqoLClz I92VYQ0wYKYPa8AZDU6DpMIWIqt3/EyZQOy8ZhfVf5naadqj3KSGniFyIwLBwTauuzEH t+M4J78v3NdK0hBZqEMnv+ZIppeQFEIPr8G6s= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=Bl55R7MkjCz9LQEDWeY819kEKM3Vq/nTi6UOAyX5DJc=; b=WUIxB3nchDnE2dAs7glg7BUcOsbUxcg5QJt+Ib44/UMzL1Z0Ph+zzBMdbSueBRzlPp GDt4XupF/bmesY6Jn9y6odpcXQDyYPKvM76dBXZFOx/0+FK5jbbGCwdSJ5EMhG0Fciia d5qTfCvJUFwSXywNzh28HPinrzjEAVYNwyhuiOS8Lfu0aq6N8IW3K4N8rBZ/daJ7lZpA vGhmiZVo27fsKMSXj8/JvjEwckJZm85YZj1TxBtXeKf6VsmTRhGLnm3T6Kw1h99bjEMW 94H9ro/g5jihZYK28Xy5VxyXaYkw3zxcYsBEMC66BeDhlYQh5V/bovPWh0Dlpk4gwRuy Pc0g== X-Gm-Message-State: AOAM532bXvL9M4TDg6SK7uiPtOlk90ENRv9JZh/KV3nOPU0BrTfpOdzL tOT1bvkabmnHYrwXqwqFUKO3/UX02nk= X-Received: by 2002:a17:90a:1f08:: with SMTP id u8mr7416985pja.154.1594407121035; Fri, 10 Jul 2020 11:52:01 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id w123sm6938932pfd.2.2020.07.10.11.51.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jul 2020 11:51:59 -0700 (PDT) From: Kees Cook To: Will Deacon Cc: Kees Cook , Tycho Andersen , linux-kernel@vger.kernel.org Subject: [PATCH for-next/seccomp 1/2] selftests/seccomp: Add SKIPs for failed unshare() Date: Fri, 10 Jul 2020 11:51:55 -0700 Message-Id: <20200710185156.2437687-2-keescook@chromium.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200710185156.2437687-1-keescook@chromium.org> References: <20200710185156.2437687-1-keescook@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Running the seccomp tests as a regular user shouldn't just fail tests that require CAP_SYS_ADMIN (for getting a PID namespace). Instead, detect those cases and SKIP them. Signed-off-by: Kees Cook --- tools/testing/selftests/seccomp/seccomp_bpf.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c index bd97a985c9e6..08bfbb7fc1c2 100644 --- a/tools/testing/selftests/seccomp/seccomp_bpf.c +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c @@ -3420,7 +3420,10 @@ TEST(user_notification_child_pid_ns) struct seccomp_notif req = {}; struct seccomp_notif_resp resp = {}; - ASSERT_EQ(unshare(CLONE_NEWUSER | CLONE_NEWPID), 0); + ASSERT_EQ(unshare(CLONE_NEWUSER | CLONE_NEWPID), 0) { + if (errno == EPERM) + SKIP(return, "CLONE_NEWPID requires CAP_SYS_ADMIN"); + }; listener = user_notif_syscall(__NR_getppid, SECCOMP_FILTER_FLAG_NEW_LISTENER); @@ -3485,7 +3488,10 @@ TEST(user_notification_sibling_pid_ns) } /* Create the sibling ns, and sibling in it. */ - ASSERT_EQ(unshare(CLONE_NEWPID), 0); + ASSERT_EQ(unshare(CLONE_NEWPID), 0) { + if (errno == EPERM) + SKIP(return, "CLONE_NEWPID requires CAP_SYS_ADMIN"); + } ASSERT_EQ(errno, 0); pid2 = fork(); -- 2.25.1