lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAPhsuW4t5eSCOQdzJGygG0PjFkyivyAgtCXJFwz_t=dL+ESPRw@mail.gmail.com>
Date: Mon, 21 Apr 2025 11:08:27 -0700
From: Song Liu <song@...nel.org>
To: "T.J. Mercier" <tjmercier@...gle.com>
Cc: sumit.semwal@...aro.org, christian.koenig@....com, ast@...nel.org, 
	daniel@...earbox.net, andrii@...nel.org, martin.lau@...ux.dev, 
	skhan@...uxfoundation.org, linux-kernel@...r.kernel.org, 
	linux-media@...r.kernel.org, dri-devel@...ts.freedesktop.org, 
	linaro-mm-sig@...ts.linaro.org, linux-doc@...r.kernel.org, 
	bpf@...r.kernel.org, linux-kselftest@...r.kernel.org, android-mm@...gle.com, 
	simona@...ll.ch, corbet@....net, eddyz87@...il.com, yonghong.song@...ux.dev, 
	john.fastabend@...il.com, kpsingh@...nel.org, sdf@...ichev.me, 
	jolsa@...nel.org, mykolal@...com
Subject: Re: [PATCH 3/4] selftests/bpf: Add test for dmabuf_iter

On Mon, Apr 14, 2025 at 3:53 PM T.J. Mercier <tjmercier@...gle.com> wrote:
>
> This test creates a udmabuf and uses a BPF program that prints dmabuf
> metadata with the new dmabuf_iter to verify it can be found.
>
> Signed-off-by: T.J. Mercier <tjmercier@...gle.com>
> ---
[...]
> +
> +
> +static void subtest_dmabuf_iter_check_udmabuf(struct dmabuf_iter *skel)
> +{
> +       static const char test_buffer_name[] = "udmabuf_test_buffer_for_iter";
> +       const size_t test_buffer_size = 10 * getpagesize();
> +
> +       ASSERT_LE(sizeof(test_buffer_name), DMA_BUF_NAME_LEN, "NAMETOOLONG");
> +
> +       int memfd = memfd_create("memfd_test", MFD_ALLOW_SEALING);
> +       ASSERT_OK_FD(memfd, "memfd_create");

Please do not mix variable declaration with the rest of the code. Also,
please run checkpatch.pl on the patches. I see a few warnings.

> +
> +       ASSERT_OK(ftruncate(memfd, test_buffer_size), "ftruncate");
> +
> +       ASSERT_OK(fcntl(memfd, F_ADD_SEALS, F_SEAL_SHRINK), "seal");
> +
> +       int dev_udmabuf = open("/dev/udmabuf", O_RDONLY);
> +       ASSERT_OK_FD(dev_udmabuf, "open udmabuf");
> +
[...]
> +
> +       ASSERT_TRUE(found_test_udmabuf, "found_test_buffer");
> +
> +       free(line);
> +       fclose(iter_file);
> +       close(iter_fd);
> +       close(udmabuf);
> +       close(memfd);
> +}
> +
> +void test_dmabuf_iter(void)
> +{
> +       struct dmabuf_iter *skel = NULL;
> +       char buf[256];
> +       int iter_fd;
> +
> +       skel = dmabuf_iter__open_and_load();
> +       if (!ASSERT_OK_PTR(skel, "dmabuf_iter__open_and_load"))
> +               return;
> +
> +       if (!ASSERT_OK(dmabuf_iter__attach(skel), "skel_attach"))
> +               goto destroy;
> +
> +       iter_fd = bpf_iter_create(bpf_link__fd(skel->links.dmabuf_collector));
> +       if (!ASSERT_GE(iter_fd, 0, "iter_create"))

Use ASSERT_OK_FD here?

> +               goto destroy;
> +
> +       memset(buf, 0, sizeof(buf));
> +       while (read(iter_fd, buf, sizeof(buf) > 0)) {
> +               /* Read out all contents */
> +       }
> +

[...]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ