Skip to contentSkip to conversation

selftests: drv-net: ncdevmem: Open /dev/udmabuf O_RDONLY

PATCH Applied T.J. Mercier 2 participants 2 messages Jul 22 – Jul 24

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests: drv-net: ncdevmem: Open /dev/udmabuf O_RDONLY

Write permissions on the /dev/udmabuf device file are not required to issue ioctls and allocate udmabufs. Applications should be opening this file as O_RDONLY. The BPF dmabuf_iter selftest already does this. [1]

Users are pointing to these selftests as examples of how use udmabuf, and encountering permission errors on systems where write permissions are not available on /dev/udmabuf. Apply the principle of least privilege to selftests which use udmabuf by removing the write access mode from drivers/dma-buf/udmabuf.c and drivers/net/hw/ncdevmem.c.

[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

---
 tools/testing/selftests/drivers/net/hw/ncdevmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/drivers/net/hw/ncdevmem.c +1 -1
index d96e8a3b5a65..ffe1d5c1fa4e 100644
@@ -150,7 +150,7 @@ static struct memory_buffer *udmabuf_alloc(size_t size)
 
 	ctx->size = size;
 
-	ctx->devfd = open("/dev/udmabuf", O_RDWR);
+	ctx->devfd = open("/dev/udmabuf", O_RDONLY);
 	if (ctx->devfd < 0) {
 		pr_err("[skip,no-udmabuf: Unable to access DMA buffer device file]");
 		goto err_free_ctx;
Signature · 1 line
2.55.0.229.g6434b31f56-goog
#1 lore raw
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 11 lines · On Wed, 22 Jul 2026 13:54:42 -0700 you wrote:

Write permissions on the /dev/udmabuf device file are not required to issue ioctls and allocate udmabufs. Applications should be opening this file as O_RDONLY. The BPF dmabuf_iter selftest already does this. [1]

Users are pointing to these selftests as examples of how use udmabuf, and encountering permission errors on systems where write permissions are not available on /dev/udmabuf. Apply the principle of least privilege to selftests which use udmabuf by removing the write access mode from drivers/dma-buf/udmabuf.c and drivers/net/hw/ncdevmem.c.

[...]

Here is the summary with links:
- [net-next] selftests: drv-net: ncdevmem: Open /dev/udmabuf O_RDONLY

    https://git.kernel.org/netdev/net-next/c/be6f0d0bae22

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html