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: <CABdmKX200iB3+_6mVQpCH7agdcwsjbfR5cJKRyySuu-2BsL2gA@mail.gmail.com>
Date: Mon, 12 May 2025 12:10:31 -0700
From: "T.J. Mercier" <tjmercier@...gle.com>
To: Song Liu <song@...nel.org>
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 11:58 AM Song Liu <song@...nel.org> wrote:
>
> 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;

We don't really need the -1 since the rework in this version
initializes them to -1 on failure, but I'll add it anyway.

> > +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.

Ok, done.

>
> > +       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?

We should fallthrough on error, but let's add the early out.

>
> > +
> > +       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)
>
> ?

Yes! Thanks.

> Thanks,
> Song
>
> [...]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ