Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp1380651lqz; Mon, 1 Apr 2024 04:51:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVli1xK9CIwNDkVVN2WSpiPbs9+ndChn059gIKTQHUk0dqhOx35Lssjw62emHY4z6s/BHnBP7adyoONFHg1mo/8J/sSATqM8zuyYz+ONg== X-Google-Smtp-Source: AGHT+IERBfVBtMAe/AaeRXAgKy3t6RviwLdAC60Wrr1tYcue9q4/gAJU+V81uZoiV8ZhgYKfPnB1 X-Received: by 2002:a05:622a:1801:b0:432:cbd2:3c4c with SMTP id t1-20020a05622a180100b00432cbd23c4cmr7134418qtc.0.1711972310300; Mon, 01 Apr 2024 04:51:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711972310; cv=pass; d=google.com; s=arc-20160816; b=gxhKkTPTNFHtCyjr/2ERjSyM+h1Ayn6Z0e7pQyrDiIJIeCRJTX3u+X/jfL46lCYyud uOtjDK0XxJaArn81x07+kNMFePBZSeZiWoNdTQbd87wSP4KEfWEEOg2j/eCBIaZHn4pR fn4kVEx1tb6Cljyz2Q5mY8ejiPHjHEkLcqfbXq5kHWILd1T54Ni1am4BF4iIwnv6Q2kF MulNACB5IVqMV/FceHsvevMU6YoLwqDmzXh3brne0u+GA5wcE6iZKxE4FKTFt9PLRRrJ VsBgVaUzi9yCvSoaI6t4puq0r3rwrjvT2b2n4xA8H8Hu3MNAaKm6SmEYIvhSlOhE2cgs 7F0A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:cc:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=hTrgJlcTimNiOUujlCW489xCWp4+gnx3lLnoeFWv/M8=; fh=7A4N4iZ1lngNOMSLFthzcU83sBBTdSAupCxgT8WWYOY=; b=bth+aeCpw5d5PoE87Rn/mQN3ptaPDyq9SDqnseOwc2BJWdrj29Y+7DEf9wEKspmipu RRh7BSpEUOxakdBG9qmC5OrOXh32fPTAVz1Oztpeel0LGKfZTPDqONDDBW7XkjTJz7fE kVJYsqnpZklfxIvin8yxOSnCj5KiyrW3lcQdv/MDf5qSCySjyErJRY/3IPv4YOWhs3ru EQ5Z2tszCQHoN0yG3aowmrPz2e71F21smOxO1vQBDbAOBpZDNipS5Yy7HH7X8HCnhsJj 0ASz978bCP9pVSzps52HIBoStoGkBa2VOTN01l3IQQitzIruQ5U3q1L6T+18/wudIYSM aROg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=aSZAhOg7; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-126635-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-126635-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id e19-20020ac85993000000b004310c544ef1si9603525qte.509.2024.04.01.04.51.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Apr 2024 04:51:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-126635-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=aSZAhOg7; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-126635-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-126635-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id F2A981C20DD7 for ; Mon, 1 Apr 2024 11:51:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2324C224C6; Mon, 1 Apr 2024 11:51:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="aSZAhOg7" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4AF3921105; Mon, 1 Apr 2024 11:51:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711972299; cv=none; b=Hqj82nzjqbcSRnzYLaoitKD+zkPlfGsenMHfLKAVA+igP/70UrdOmVupimV/xGgyynQ8wy3/7mVNREjX9ai5+0FgzyMGxDiDXzKJRQSv/x8gG6DF0x3BCkmDGaESeMnbq4wMtoccPakWQdU7O4tRIHRaOSjs54X6I9YIr9gE3g8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711972299; c=relaxed/simple; bh=MiTn1QBDoXu4z3m/p6W/aD6j7Th+QhOgpsn4TJ96pM4=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=hHHkViYMC9bDuTxdaIqK3lO2CqqBfnlhec4TGZ9mXqBDAbek0+CvJJ8JW3XCmaiMBhKQ5JmTIHqWCa7S21wxIi2k3x2G8Eae8+FGqG6142zzHLyor/iBkVJzShxZgY4NVWdSEdphscFIaiAyxWwa1JsOWElOo7o4l5eHEg0I70A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=aSZAhOg7; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1711972295; bh=MiTn1QBDoXu4z3m/p6W/aD6j7Th+QhOgpsn4TJ96pM4=; h=Date:Cc:Subject:To:References:From:In-Reply-To:From; b=aSZAhOg7s9F54Xk9A+/KBlyVHJkYmKnrD3ue0k6/PKYyKxnxXL677aP/EwKzCpiip BFEUDUPTHZ5zimVyg8xRLy15d3h7kSByWUauNJ6dmiWJlvfyGde65fSo4peW+Ujhrt YRtGf5r9L1Kr7Flh4WC5FhftJ8Z1NYcN8FJDoGHsmaX2IO2yzfNVOGgwFpAI8h2FIc ZNOEGVDfNI/bePkYRyVuNpe7zrdq6LmhtmrUEYRNMGjafxYD8dhIxN7uwGB9BJmj3C uEo0o8pxSGSwTAunV+3F1O7IIrh/86DmcN3G9kdSTtXboGgWf03WqdEzJW0gS6aYte N9uIhELEmiC8Q== Received: from [10.193.1.1] (broslavsky.collaboradmins.com [68.183.210.73]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: usama.anjum) by madrid.collaboradmins.com (Postfix) with ESMTPSA id BBED937809D1; Mon, 1 Apr 2024 11:51:30 +0000 (UTC) Message-ID: <737409df-d83e-49cf-bb1a-49436ed2d38a@collabora.com> Date: Mon, 1 Apr 2024 16:52:02 +0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: Muhammad Usama Anjum , kernel@collabora.com, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH bpf-next v2] selftests/bpf: Move test_dev_cgroup to prog_tests To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan References: <20240221092248.1945364-1-usama.anjum@collabora.com> <765ac086-621e-40b9-bbdf-bc1fbbdebf06@collabora.com> Content-Language: en-US From: Muhammad Usama Anjum In-Reply-To: <765ac086-621e-40b9-bbdf-bc1fbbdebf06@collabora.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Trying the BPF CI job again by changing test_dev_cgroup to serial_test_dev_cgroup. I'm not sure if it'll trigger the job or not. Is there any other way to trigger a CI job for a test patch? Signed-off-by: Muhammad Usama Anjum --- .../selftests/bpf/prog_tests/dev_cgroup.c | 58 +++++++++++++ tools/testing/selftests/bpf/test_dev_cgroup.c | 85 ------------------- 2 files changed, 58 insertions(+), 85 deletions(-) create mode 100644 tools/testing/selftests/bpf/prog_tests/dev_cgroup.c delete mode 100644 tools/testing/selftests/bpf/test_dev_cgroup.c diff --git a/tools/testing/selftests/bpf/prog_tests/dev_cgroup.c b/tools/testing/selftests/bpf/prog_tests/dev_cgroup.c new file mode 100644 index 0000000000000..980b015a116ff --- /dev/null +++ b/tools/testing/selftests/bpf/prog_tests/dev_cgroup.c @@ -0,0 +1,58 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* Copyright (c) 2017 Facebook + */ + +#include +#include +#include "cgroup_helpers.h" +#include "dev_cgroup.skel.h" + +#define TEST_CGROUP "/test-bpf-based-device-cgroup/" + +void serial_test_dev_cgroup(void) +{ + struct dev_cgroup *skel; + int cgroup_fd, err; + __u32 prog_cnt; + + skel = dev_cgroup__open_and_load(); + if (!ASSERT_OK_PTR(skel, "skel_open_and_load")) + goto cleanup; + + cgroup_fd = cgroup_setup_and_join(TEST_CGROUP); + if (!ASSERT_GT(cgroup_fd, 0, "cgroup_setup_and_join")) + goto cleanup; + + err = bpf_prog_attach(bpf_program__fd(skel->progs.bpf_prog1), cgroup_fd, + BPF_CGROUP_DEVICE, 0); + if (!ASSERT_EQ(err, 0, "bpf_attach")) + goto cleanup; + + err = bpf_prog_query(cgroup_fd, BPF_CGROUP_DEVICE, 0, NULL, NULL, &prog_cnt); + if (!ASSERT_EQ(err, 0, "bpf_query") || (!ASSERT_EQ(prog_cnt, 1, "bpf_query"))) + goto cleanup; + + /* All operations with /dev/zero and /dev/urandom are allowed, + * everything else is forbidden. + */ + ASSERT_EQ(system("rm -f /tmp/test_dev_cgroup_null"), 0, "rm"); + ASSERT_NEQ(system("mknod /tmp/test_dev_cgroup_null c 1 3"), 0, "mknod"); + ASSERT_EQ(system("rm -f /tmp/test_dev_cgroup_null"), 0, "rm"); + + /* /dev/zero is whitelisted */ + ASSERT_EQ(system("rm -f /tmp/test_dev_cgroup_zero"), 0, "rm"); + ASSERT_EQ(system("mknod /tmp/test_dev_cgroup_zero c 1 5"), 0, "mknod"); + ASSERT_EQ(system("rm -f /tmp/test_dev_cgroup_zero"), 0, "rm"); + + ASSERT_EQ(system("dd if=/dev/urandom of=/dev/zero count=64"), 0, "dd"); + + /* src is allowed, target is forbidden */ + ASSERT_NEQ(system("dd if=/dev/urandom of=/dev/full count=64"), 0, "dd"); + + /* src is forbidden, target is allowed */ + ASSERT_NEQ(system("dd if=/dev/random of=/dev/zero count=64"), 0, "dd"); + +cleanup: + cleanup_cgroup_environment(); + dev_cgroup__destroy(skel); +} diff --git a/tools/testing/selftests/bpf/test_dev_cgroup.c b/tools/testing/selftests/bpf/test_dev_cgroup.c deleted file mode 100644 index adeaf63cb6fa3..0000000000000 --- a/tools/testing/selftests/bpf/test_dev_cgroup.c +++ /dev/null @@ -1,85 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2017 Facebook - */ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "cgroup_helpers.h" -#include "testing_helpers.h" - -#define DEV_CGROUP_PROG "./dev_cgroup.bpf.o" - -#define TEST_CGROUP "/test-bpf-based-device-cgroup/" - -int main(int argc, char **argv) -{ - struct bpf_object *obj; - int error = EXIT_FAILURE; - int prog_fd, cgroup_fd; - __u32 prog_cnt; - - /* Use libbpf 1.0 API mode */ - libbpf_set_strict_mode(LIBBPF_STRICT_ALL); - - if (bpf_prog_test_load(DEV_CGROUP_PROG, BPF_PROG_TYPE_CGROUP_DEVICE, - &obj, &prog_fd)) { - printf("Failed to load DEV_CGROUP program\n"); - goto out; - } - - cgroup_fd = cgroup_setup_and_join(TEST_CGROUP); - if (cgroup_fd < 0) { - printf("Failed to create test cgroup\n"); - goto out; - } - - /* Attach bpf program */ - if (bpf_prog_attach(prog_fd, cgroup_fd, BPF_CGROUP_DEVICE, 0)) { - printf("Failed to attach DEV_CGROUP program"); - goto err; - } - - if (bpf_prog_query(cgroup_fd, BPF_CGROUP_DEVICE, 0, NULL, NULL, - &prog_cnt)) { - printf("Failed to query attached programs"); - goto err; - } - - /* All operations with /dev/zero and and /dev/urandom are allowed, - * everything else is forbidden. - */ - assert(system("rm -f /tmp/test_dev_cgroup_null") == 0); - assert(system("mknod /tmp/test_dev_cgroup_null c 1 3")); - assert(system("rm -f /tmp/test_dev_cgroup_null") == 0); - - /* /dev/zero is whitelisted */ - assert(system("rm -f /tmp/test_dev_cgroup_zero") == 0); - assert(system("mknod /tmp/test_dev_cgroup_zero c 1 5") == 0); - assert(system("rm -f /tmp/test_dev_cgroup_zero") == 0); - - assert(system("dd if=/dev/urandom of=/dev/zero count=64") == 0); - - /* src is allowed, target is forbidden */ - assert(system("dd if=/dev/urandom of=/dev/full count=64")); - - /* src is forbidden, target is allowed */ - assert(system("dd if=/dev/random of=/dev/zero count=64")); - - error = 0; - printf("test_dev_cgroup:PASS\n"); - -err: - cleanup_cgroup_environment(); - -out: - return error; -} -- 2.42.0