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: <CAPhsuW6TUogokra2mJQG6jeuZ1_RZPwr4xGbBOUJZBUg9AqW3g@mail.gmail.com>
Date: Mon, 12 May 2025 11:58:09 -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, alexei.starovoitov@...il.com, 
	linux-kernel@...r.kernel.org, linux-media@...r.kernel.org, 
	dri-devel@...ts.freedesktop.org, linaro-mm-sig@...ts.linaro.org, 
	bpf@...r.kernel.org, linux-kselftest@...r.kernel.org, android-mm@...gle.com, 
	simona@...ll.ch, eddyz87@...il.com, yonghong.song@...ux.dev, 
	john.fastabend@...il.com, kpsingh@...nel.org, sdf@...ichev.me, 
	jolsa@...nel.org, mykolal@...com, shuah@...nel.org
Subject: Re: [PATCH bpf-next v5 4/5] selftests/bpf: Add test for dmabuf_iter

On Mon, May 12, 2025 at 10:41 AM T.J. Mercier <tjmercier@...gle.com> wrote:
[...]
> +
> +static int udmabuf;

static int udmabuf = -1;

> +static const char udmabuf_test_buffer_name[DMA_BUF_NAME_LEN] = "udmabuf_test_buffer_for_iter";
> +static size_t udmabuf_test_buffer_size;
> +static int sysheap_dmabuf;

static int sysheap_dmabuf = -1;

> +static const char sysheap_test_buffer_name[DMA_BUF_NAME_LEN] = "sysheap_test_buffer_for_iter";
> +static size_t sysheap_test_buffer_size;
> +
> +static int create_udmabuf(void)
> +{
> +       struct udmabuf_create create;

nit: zero initialize create to be future proof.

> +       int dev_udmabuf, memfd, local_udmabuf;
> +
> +       udmabuf_test_buffer_size = 10 * getpagesize();

[...]

> +static void subtest_dmabuf_iter_check_default_iter(struct dmabuf_iter *skel)
> +{
> +       bool found_test_sysheap_dmabuf = false;
> +       bool found_test_udmabuf = false;
> +       struct DmabufInfo bufinfo;
> +       size_t linesize = 0;
> +       char *line = NULL;
> +       FILE *iter_file;
> +       int iter_fd, f = INODE;
> +
> +       iter_fd = bpf_iter_create(bpf_link__fd(skel->links.dmabuf_collector));
> +       ASSERT_OK_FD(iter_fd, "iter_create");

Should we check ASSERT_OK_FD() and exit early on
failures?

> +
> +       iter_file = fdopen(iter_fd, "r");
> +       ASSERT_OK_PTR(iter_file, "fdopen");

Same here.
[...]
> +/*
> + * Fields output by this iterator are delimited by newlines. Convert any
> + * newlines in user-provided printed strings to spaces.
> + */
> +static void sanitize_string(char *src, size_t size)
> +{
> +       for (char *c = src; c && (size_t)(c - src) < size; ++c)

Should this be:

  for (char *c = src; *c && (size_t)(c - src) < size; ++c)

?

Thanks,
Song

[...]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ