Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2537090rbb; Wed, 28 Feb 2024 05:11:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWTgy8zQlpeiM8XJPtjvwwjaA/DQSmQySoANlibaxTLcM/k6mhpQ1bCg7DFUpt+XltgfTvZoNEZk4EhspmH6V9XC+FArg0inexVC7BRWg== X-Google-Smtp-Source: AGHT+IFwXrhf4OliLzhrkVGBRfXmFiOHhCdw0c2N77zlD4KqLMFsE0nbjo5XrJ8cibYJKUCCewFC X-Received: by 2002:a9d:6aca:0:b0:6e4:8fa3:d86a with SMTP id m10-20020a9d6aca000000b006e48fa3d86amr12345776otq.11.1709125872614; Wed, 28 Feb 2024 05:11:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709125872; cv=pass; d=google.com; s=arc-20160816; b=ZYase1hvG/ZxK0pEDa7wem/KUlomFC8oQ54eXUwsiNPPZg6EQTkUTpYIJ3iEq3Nl0F IgA1kDV5brAbAjLfX4qByPknCFRQNyTFOVX5JRVeDxH9ggoiM7MPGokgfhos/niaDAnp rYjRrCz19Xa5WP8Q5MJ+KYEd1mb7WiwatNiPYWwGdPewFPFieQ6PNkso9XYReAM43atL GP9R8kVNna4m2Iu2/Cytf3LEMalOtFB6U8HYgKeLrwGi1UC4dwkyuFKqQujqkL3OqZKR iEFSFCRTf5iuz6//BlvmjDtV+9c7DHsu1thT3fOICJ9tu7sNSH0ryO/a/UshoBtxYFIU 4sIQ== 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:references:to :content-language:subject:cc:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=gGOhD3aQGxNZ6bY8rpGsX1fPYuuEnzGDz/PW/eht2ok=; fh=7A4N4iZ1lngNOMSLFthzcU83sBBTdSAupCxgT8WWYOY=; b=iZRezLiBPjzCvhsAmqXwK22qLa0z3431To+wstpwbuIATGu8QBXlMfZWmOguYzkmMd EAwn4mwZGc4gcJ+z9qydzQERv+VRjvUJOrXLGhY35Lnee8SYpwtRaNGaPduOB94W9N92 RxETAf201TT7+Cvm4h1ilwvb0Fnuzju3RcWOhTV+Y7cgw2PIJ5mRm5k94DkGB5IWNPt8 sbY5scUC6F5x8EDcm+TWj2TITpBFlyQoD7p1tHQjhvh5Xga9EPj+HZStanpSwcLtCQWR PKYfD14/Oojo3JojLWZs6LWjKdrY0F7cHycgkGdXSHQ8kLmtq4OflyduY5LKOopuZ0D0 X8+Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=XYBUPHep; 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-85070-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85070-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 9-20020a630009000000b005dc98dad591si7413980pga.707.2024.02.28.05.11.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 05:11:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85070-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=XYBUPHep; 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-85070-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85070-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 8FA7628A549 for ; Wed, 28 Feb 2024 13:10:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 198BD14AD34; Wed, 28 Feb 2024 13:10:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="XYBUPHep" 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 3C4D414A4C9; Wed, 28 Feb 2024 13:10:22 +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=1709125824; cv=none; b=W0Zx55j6CLsoAR0dFbXwJ7jl4+hNhSwfThwIfjsq3Kfrt2YBqHbavXHgfZCuNhiztkxhoUo+y5cenDZQ2z0l+h52YtJoGXwTJXn01YRi5HQPVU7LSYEulKOpCaq4VsAQUre4CQpH9Ltp1koHoRHOz2moTJf/bMITf93QUwvU5MU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709125824; c=relaxed/simple; bh=KK4eUV2BkPuaHFWcsp8DbzSeNW1LjGIibof8skYkCrk=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=Hh+iQCCGrrBzU87ZNmfgMNK9CQYzJ/AGrZw8aqxXDObWkDLdm/fd2BMg8Cdm3EX49W0Ba6I3VG3ZqLW+2YCr814h1EpyRdive8KQsKVxseSiiIY4Wl2Yj5HiUgKEffORobrslYX0g9h/+jcYnbqlfme0d7RjLL3EvB8BREi7r7w= 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=XYBUPHep; 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=1709125819; bh=KK4eUV2BkPuaHFWcsp8DbzSeNW1LjGIibof8skYkCrk=; h=Date:Cc:Subject:To:References:From:In-Reply-To:From; b=XYBUPHepFB/FbuXIlOwXGmJFQBd2NtJRtbpn5gJNKX2wbYpzJgyGY7F7OoKKbCTNf AYyHM+vds/M+jc6Z4jd4DnHIMxl4p9IIeDO9Ay/VJmrYBQgq2x1cPt6rTPN3ri1fiL 9wN3gnN6i37PANI6HilgOrS2rNplaRR9InQt85+tglY3xxwJhrkqDFItP+9Z4WyO8c mFQtsi2i/W8FXsURb5h0/49sZa6GoRbNwosTS8Dh2M76hqL+n550Ff14beJQlp6Ash Jt9eVc/d00f9QKQIlDJXNktDGmtQ2GiUFAeF7YQ3y1gEXg2EBhxk4KrmhiddslFlwQ PYJTvHT73EqhQ== 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 A35D937820D4; Wed, 28 Feb 2024 13:10:09 +0000 (UTC) Message-ID: <765ac086-621e-40b9-bbdf-bc1fbbdebf06@collabora.com> Date: Wed, 28 Feb 2024 18:10:32 +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 Content-Language: en-US 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> From: Muhammad Usama Anjum In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2/21/24 7:06 PM, Muhammad Usama Anjum wrote: > On 2/21/24 2:22 PM, Muhammad Usama Anjum wrote: >> Move test_dev_cgroup.c to prog_tests/dev_cgroup.c to be able to run it >> with test_progs. Replace dev_cgroup.bpf.o with skel header file, >> dev_cgroup.skel.h and load program from it accourdingly. >> >> ./test_progs -t test_dev_cgroup >> mknod: /tmp/test_dev_cgroup_null: Operation not permitted >> 64+0 records in >> 64+0 records out >> 32768 bytes (33 kB, 32 KiB) copied, 0.000856684 s, 38.2 MB/s >> dd: failed to open '/dev/full': Operation not permitted >> dd: failed to open '/dev/random': Operation not permitted >> #365 test_dev_cgroup:OK >> Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED >> >> Signed-off-by: Muhammad Usama Anjum >> --- >> I've tested the patch with vmtest.sh on bpf-next/for-next and linux >> next. It is passing on both. Not sure why it was failed on BPFCI. >> Test run with vmtest.h: >> sudo LDLIBS=-static PKG_CONFIG='pkg-config --static' ./vmtest.sh ./test_progs -t dev_cgroup >> ./test_progs -t dev_cgroup >> mknod: /tmp/test_dev_cgroup_null: Operation not permitted >> 64+0 records in >> 64+0 records out >> 32768 bytes (33 kB, 32 KiB) copied, 0.000403432 s, 81.2 MB/s >> dd: failed to open '/dev/full': Operation not permitted >> dd: failed to open '/dev/random': Operation not permitted >> #69 dev_cgroup:OK >> Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED > Locally this test passes, but fails on BPFCI: > https://github.com/kernel-patches/bpf/actions/runs/7986809998/job/21808178301#step:5:9744 The test run results with vmtest.sh and BPFCI are conflicting. What should we do to debug the problem now? Any ideas are welcome. I've tried to debug on my end. Not sure why it fails on the BPF CI. > >> >> Changes since v1: >> - Rename file from test_dev_cgroup.c to dev_cgroup.c >> - Use ASSERT_* in-place of CHECK >> --- >> .../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 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"); > Access to major number 1 and minor number 5 is allowed. The return code of > 0 is expected, but on CI we are getting 256 which indicates error. mknod > help page mentions the same: > >> An exit status of zero indicates success, and a nonzero value indicates > failure. > -- BR, Muhammad Usama Anjum