* [PATCH] kselftests: dmabuf-heaps: Open heap device files O_RDONLY
@ 2026-08-11 20:41 T.J. Mercier
2026-08-11 20:57 ` John Stultz
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: T.J. Mercier @ 2026-08-11 20:41 UTC (permalink / raw)
To: sumit.semwal, benjamin.gaignard, Brian.Starkey, jstultz,
linux-media, dri-devel, linaro-mm-sig
Cc: christian.koenig, shuah, linux-kselftest, linux-kernel, T.J. Mercier
Write permissions on the /dev/dma_heap/* device files are not required
to issue ioctls and allocate dmabufs. Applications should be opening
these file as O_RDONLY. The BPF dmabuf_iter selftest already does
this. [1]
Users are pointing to these selftests as examples of how use dmabuf,
and encountering permission errors on systems where write permissions
are not available on /dev/dma_heap/*. Apply the principle of least
privilege to selftests which open dmabuf heaps by removing the write
access mode and using O_RDONLY for the open() instead.
The same is true for the vgem test using /dev/dri/card.
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/testing/selftests/bpf/prog_tests/dmabuf_iter.c?h=v7.1#n49
Signed-off-by: T.J. Mercier <tjmercier@google.com>
---
tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
index fc9694fc4e89..45b420e37c97 100644
--- a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
+++ b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
@@ -48,7 +48,7 @@ static int open_vgem(void)
snprintf(name, 80, "%s%u", drmstr, i);
- fd = open(name, O_RDWR);
+ fd = open(name, O_RDONLY);
if (fd < 0)
continue;
@@ -96,7 +96,7 @@ static int dmabuf_heap_open(char *name)
if (ret < 0)
ksft_exit_fail_msg("snprintf failed! %d\n", ret);
- fd = open(buf, O_RDWR);
+ fd = open(buf, O_RDONLY);
if (fd < 0)
ksft_exit_fail_msg("open %s failed: %s\n", buf, strerror(errno));
base-commit: 9a11db68872055e6ead919bad04d6330851c522d
--
2.55.0.679.g6767b8d81c-goog
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] kselftests: dmabuf-heaps: Open heap device files O_RDONLY
2026-08-11 20:41 [PATCH] kselftests: dmabuf-heaps: Open heap device files O_RDONLY T.J. Mercier
@ 2026-08-11 20:57 ` John Stultz
2026-08-12 8:51 ` Christian König
2026-08-12 15:02 ` Sumit Semwal
2 siblings, 0 replies; 7+ messages in thread
From: John Stultz @ 2026-08-11 20:57 UTC (permalink / raw)
To: T.J. Mercier
Cc: sumit.semwal, benjamin.gaignard, Brian.Starkey, linux-media,
dri-devel, linaro-mm-sig, christian.koenig, shuah,
linux-kselftest, linux-kernel
On Tue, Aug 11, 2026 at 1:41 PM T.J. Mercier <tjmercier@google.com> wrote:
>
> Write permissions on the /dev/dma_heap/* device files are not required
> to issue ioctls and allocate dmabufs. Applications should be opening
> these file as O_RDONLY. The BPF dmabuf_iter selftest already does
> this. [1]
>
> Users are pointing to these selftests as examples of how use dmabuf,
> and encountering permission errors on systems where write permissions
> are not available on /dev/dma_heap/*. Apply the principle of least
> privilege to selftests which open dmabuf heaps by removing the write
> access mode and using O_RDONLY for the open() instead.
>
> The same is true for the vgem test using /dev/dri/card.
>
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/testing/selftests/bpf/prog_tests/dmabuf_iter.c?h=v7.1#n49
>
> Signed-off-by: T.J. Mercier <tjmercier@google.com>
Acked-by: John Stultz <jstultz@google.com>
thanks
-john
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] kselftests: dmabuf-heaps: Open heap device files O_RDONLY
2026-08-11 20:41 [PATCH] kselftests: dmabuf-heaps: Open heap device files O_RDONLY T.J. Mercier
2026-08-11 20:57 ` John Stultz
@ 2026-08-12 8:51 ` Christian König
2026-08-12 15:02 ` Sumit Semwal
2 siblings, 0 replies; 7+ messages in thread
From: Christian König @ 2026-08-12 8:51 UTC (permalink / raw)
To: T.J. Mercier, sumit.semwal, benjamin.gaignard, Brian.Starkey,
jstultz, linux-media, dri-devel, linaro-mm-sig
Cc: shuah, linux-kselftest, linux-kernel
On 8/11/26 22:41, T.J. Mercier wrote:
> Write permissions on the /dev/dma_heap/* device files are not required
> to issue ioctls and allocate dmabufs. Applications should be opening
> these file as O_RDONLY. The BPF dmabuf_iter selftest already does
> this. [1]
>
> Users are pointing to these selftests as examples of how use dmabuf,
> and encountering permission errors on systems where write permissions
> are not available on /dev/dma_heap/*. Apply the principle of least
> privilege to selftests which open dmabuf heaps by removing the write
> access mode and using O_RDONLY for the open() instead.
>
> The same is true for the vgem test using /dev/dri/card.
>
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/testing/selftests/bpf/prog_tests/dmabuf_iter.c?h=v7.1#n49
>
> Signed-off-by: T.J. Mercier <tjmercier@google.com>
Acked-by: Christian König <christian.koenig@amd.com>
> ---
> tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
> index fc9694fc4e89..45b420e37c97 100644
> --- a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
> +++ b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
> @@ -48,7 +48,7 @@ static int open_vgem(void)
>
> snprintf(name, 80, "%s%u", drmstr, i);
>
> - fd = open(name, O_RDWR);
> + fd = open(name, O_RDONLY);
> if (fd < 0)
> continue;
>
> @@ -96,7 +96,7 @@ static int dmabuf_heap_open(char *name)
> if (ret < 0)
> ksft_exit_fail_msg("snprintf failed! %d\n", ret);
>
> - fd = open(buf, O_RDWR);
> + fd = open(buf, O_RDONLY);
> if (fd < 0)
> ksft_exit_fail_msg("open %s failed: %s\n", buf, strerror(errno));
>
>
> base-commit: 9a11db68872055e6ead919bad04d6330851c522d
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] kselftests: dmabuf-heaps: Open heap device files O_RDONLY
2026-08-11 20:41 [PATCH] kselftests: dmabuf-heaps: Open heap device files O_RDONLY T.J. Mercier
2026-08-11 20:57 ` John Stultz
2026-08-12 8:51 ` Christian König
@ 2026-08-12 15:02 ` Sumit Semwal
2026-08-12 16:06 ` T.J. Mercier
2 siblings, 1 reply; 7+ messages in thread
From: Sumit Semwal @ 2026-08-12 15:02 UTC (permalink / raw)
To: T.J. Mercier
Cc: benjamin.gaignard, Brian.Starkey, jstultz, linux-media,
dri-devel, linaro-mm-sig, christian.koenig, shuah,
linux-kselftest, linux-kernel
Hello T J,
On Wed, 12 Aug 2026 at 02:11, T.J. Mercier <tjmercier@google.com> wrote:
>
> Write permissions on the /dev/dma_heap/* device files are not required
> to issue ioctls and allocate dmabufs. Applications should be opening
> these file as O_RDONLY. The BPF dmabuf_iter selftest already does
> this. [1]
>
> Users are pointing to these selftests as examples of how use dmabuf,
> and encountering permission errors on systems where write permissions
> are not available on /dev/dma_heap/*. Apply the principle of least
> privilege to selftests which open dmabuf heaps by removing the write
> access mode and using O_RDONLY for the open() instead.
Thanks for the patch.
>
> The same is true for the vgem test using /dev/dri/card.
>
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/testing/selftests/bpf/prog_tests/dmabuf_iter.c?h=v7.1#n49
>
> Signed-off-by: T.J. Mercier <tjmercier@google.com>
Acked-by: Sumit Semwal <sumit.semwal@linaro.org>
> ---
> tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
> index fc9694fc4e89..45b420e37c97 100644
> --- a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
> +++ b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
> @@ -48,7 +48,7 @@ static int open_vgem(void)
>
> snprintf(name, 80, "%s%u", drmstr, i);
>
> - fd = open(name, O_RDWR);
> + fd = open(name, O_RDONLY);
> if (fd < 0)
> continue;
>
> @@ -96,7 +96,7 @@ static int dmabuf_heap_open(char *name)
> if (ret < 0)
> ksft_exit_fail_msg("snprintf failed! %d\n", ret);
>
> - fd = open(buf, O_RDWR);
> + fd = open(buf, O_RDONLY);
> if (fd < 0)
> ksft_exit_fail_msg("open %s failed: %s\n", buf, strerror(errno));
>
>
> base-commit: 9a11db68872055e6ead919bad04d6330851c522d
> --
> 2.55.0.679.g6767b8d81c-goog
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] kselftests: dmabuf-heaps: Open heap device files O_RDONLY
2026-08-12 15:02 ` Sumit Semwal
@ 2026-08-12 16:06 ` T.J. Mercier
2026-11-06 18:42 ` T.J. Mercier
0 siblings, 1 reply; 7+ messages in thread
From: T.J. Mercier @ 2026-08-12 16:06 UTC (permalink / raw)
To: Sumit Semwal
Cc: benjamin.gaignard, Brian.Starkey, jstultz, linux-media,
dri-devel, linaro-mm-sig, christian.koenig, shuah,
linux-kselftest, linux-kernel
On Wed, Aug 12, 2026 at 8:02 AM Sumit Semwal <sumit.semwal@linaro.org> wrote:
>
> Hello T J,
>
> On Wed, 12 Aug 2026 at 02:11, T.J. Mercier <tjmercier@google.com> wrote:
> >
> > Write permissions on the /dev/dma_heap/* device files are not required
> > to issue ioctls and allocate dmabufs. Applications should be opening
> > these file as O_RDONLY. The BPF dmabuf_iter selftest already does
> > this. [1]
> >
> > Users are pointing to these selftests as examples of how use dmabuf,
> > and encountering permission errors on systems where write permissions
> > are not available on /dev/dma_heap/*. Apply the principle of least
> > privilege to selftests which open dmabuf heaps by removing the write
> > access mode and using O_RDONLY for the open() instead.
>
> Thanks for the patch.
> >
> > The same is true for the vgem test using /dev/dri/card.
> >
> > [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/testing/selftests/bpf/prog_tests/dmabuf_iter.c?h=v7.1#n49
> >
> > Signed-off-by: T.J. Mercier <tjmercier@google.com>
> Acked-by: Sumit Semwal <sumit.semwal@linaro.org>
Thanks for the quick revieews John, Christian, and Sumit!
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] kselftests: dmabuf-heaps: Open heap device files O_RDONLY
2026-08-12 16:06 ` T.J. Mercier
@ 2026-11-06 18:42 ` T.J. Mercier
2026-11-09 11:10 ` Christian König
0 siblings, 1 reply; 7+ messages in thread
From: T.J. Mercier @ 2026-11-06 18:42 UTC (permalink / raw)
To: Sumit Semwal, christian.koenig
Cc: benjamin.gaignard, Brian.Starkey, jstultz, linux-media,
dri-devel, linaro-mm-sig, shuah, linux-kselftest, linux-kernel
On Wed, Aug 12, 2026 at 9:06 AM T.J. Mercier <tjmercier@google.com> wrote:
>
> On Wed, Aug 12, 2026 at 8:02 AM Sumit Semwal <sumit.semwal@linaro.org> wrote:
> >
> > Hello T J,
> >
> > On Wed, 12 Aug 2026 at 02:11, T.J. Mercier <tjmercier@google.com> wrote:
> > >
> > > Write permissions on the /dev/dma_heap/* device files are not required
> > > to issue ioctls and allocate dmabufs. Applications should be opening
> > > these file as O_RDONLY. The BPF dmabuf_iter selftest already does
> > > this. [1]
> > >
> > > Users are pointing to these selftests as examples of how use dmabuf,
> > > and encountering permission errors on systems where write permissions
> > > are not available on /dev/dma_heap/*. Apply the principle of least
> > > privilege to selftests which open dmabuf heaps by removing the write
> > > access mode and using O_RDONLY for the open() instead.
> >
> > Thanks for the patch.
> > >
> > > The same is true for the vgem test using /dev/dri/card.
> > >
> > > [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/testing/selftests/bpf/prog_tests/dmabuf_iter.c?h=v7.1#n49
> > >
> > > Signed-off-by: T.J. Mercier <tjmercier@google.com>
> > Acked-by: Sumit Semwal <sumit.semwal@linaro.org>
>
> Thanks for the quick revieews John, Christian, and Sumit!
Hi, I don't think this has made it into any tree. Can this get picked up please?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] kselftests: dmabuf-heaps: Open heap device files O_RDONLY
2026-11-06 18:42 ` T.J. Mercier
@ 2026-11-09 11:10 ` Christian König
0 siblings, 0 replies; 7+ messages in thread
From: Christian König @ 2026-11-09 11:10 UTC (permalink / raw)
To: T.J. Mercier, Sumit Semwal
Cc: benjamin.gaignard, Brian.Starkey, jstultz, linux-media,
dri-devel, linaro-mm-sig, shuah, linux-kselftest, linux-kernel
On 11/6/26 19:42, T.J. Mercier wrote:
> On Wed, Aug 12, 2026 at 9:06 AM T.J. Mercier <tjmercier@google.com> wrote:
>>
>> On Wed, Aug 12, 2026 at 8:02 AM Sumit Semwal <sumit.semwal@linaro.org> wrote:
>>>
>>> Hello T J,
>>>
>>> On Wed, 12 Aug 2026 at 02:11, T.J. Mercier <tjmercier@google.com> wrote:
>>>>
>>>> Write permissions on the /dev/dma_heap/* device files are not required
>>>> to issue ioctls and allocate dmabufs. Applications should be opening
>>>> these file as O_RDONLY. The BPF dmabuf_iter selftest already does
>>>> this. [1]
>>>>
>>>> Users are pointing to these selftests as examples of how use dmabuf,
>>>> and encountering permission errors on systems where write permissions
>>>> are not available on /dev/dma_heap/*. Apply the principle of least
>>>> privilege to selftests which open dmabuf heaps by removing the write
>>>> access mode and using O_RDONLY for the open() instead.
>>>
>>> Thanks for the patch.
>>>>
>>>> The same is true for the vgem test using /dev/dri/card.
>>>>
>>>> [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/testing/selftests/bpf/prog_tests/dmabuf_iter.c?h=v7.1#n49
>>>>
>>>> Signed-off-by: T.J. Mercier <tjmercier@google.com>
>>> Acked-by: Sumit Semwal <sumit.semwal@linaro.org>
>>
>> Thanks for the quick revieews John, Christian, and Sumit!
>
> Hi, I don't think this has made it into any tree. Can this get picked up please?
Pushed to drm-misc-next.
T.J. I think it would be a good idea if you apply for commit rights to drm-misc.
The tooling used for that repo is a bit special, but considering how much Android uses DMA-buf it is probably a good idea that you are able to help pushing code upstream.
Regards,
Christian.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-11-09 11:10 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-11 20:41 [PATCH] kselftests: dmabuf-heaps: Open heap device files O_RDONLY T.J. Mercier
2026-08-11 20:57 ` John Stultz
2026-08-12 8:51 ` Christian König
2026-08-12 15:02 ` Sumit Semwal
2026-08-12 16:06 ` T.J. Mercier
2026-11-06 18:42 ` T.J. Mercier
2026-11-09 11:10 ` Christian König
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®