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: <CAPhsuW6sgGvjeAcciskmGO7r6+eeDo_KVS3y7C8fCDPptzCebw@mail.gmail.com>
Date: Wed, 16 Apr 2025 15:02: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 2/4] bpf: Add dmabuf iterator

On Mon, Apr 14, 2025 at 3:53 PM T.J. Mercier <tjmercier@...gle.com> wrote:
[...]
> +
> +BTF_ID_LIST_GLOBAL_SINGLE(bpf_dmabuf_btf_id, struct, dma_buf)
> +DEFINE_BPF_ITER_FUNC(dmabuf, struct bpf_iter_meta *meta, struct dma_buf *dmabuf)
> +
> +static void *dmabuf_iter_seq_start(struct seq_file *seq, loff_t *pos)
> +{
> +       struct dma_buf *dmabuf, *ret = NULL;
> +
> +       if (*pos) {
> +               *pos = 0;
> +               return NULL;
> +       }
> +       /* Look for the first buffer we can obtain a reference to.
> +        * The list mutex does not protect a dmabuf's refcount, so it can be
> +        * zeroed while we are iterating. Therefore we cannot call get_dma_buf()
> +        * since the caller of this program may not already own a reference to
> +        * the buffer.
> +        */
> +       mutex_lock(&dmabuf_debugfs_list_mutex);
> +       list_for_each_entry(dmabuf, &dmabuf_debugfs_list, list_node) {
> +               if (file_ref_get(&dmabuf->file->f_ref)) {
> +                       ret = dmabuf;
> +                       break;
> +               }
> +       }
> +       mutex_unlock(&dmabuf_debugfs_list_mutex);

IIUC, the iterator simply traverses elements in a linked list. I feel it is
an overkill to implement a new BPF iterator for it. Maybe we simply
use debugging tools like crash or drgn for this? The access with
these tools will not be protected by the mutex. But from my personal
experience, this is not a big issue for user space debugging tools.

Thanks,
Song


> +
> +       return ret;
> +}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ