selftests: Open /dev/udmabuf O_RDONLY
Subsystems (4)
PATCH v2 1/1 selftests: 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.
--- tools/testing/selftests/drivers/dma-buf/udmabuf.c | 2 +- tools/testing/selftests/drivers/net/hw/ncdevmem.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/drivers/dma-buf/udmabuf.c +1 -1
@@ -140,7 +140,7 @@ int main(int argc, char *argv[])ksft_print_header ();ksft_set_plan (7 ); - devfd =open ("/dev/udmabuf" ,O_RDWR ); + devfd =open ("/dev/udmabuf" ,O_RDONLY );if (devfd <0 ) { ksft_print_msg( "%s: [skip,no-udmabuf: Unable to access DMA buffer device file]\n",
tools/testing/selftests/drivers/net/hw/ncdevmem.c +1 -1
@@ -149,7 +149,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;
base-commit: fbb7ad31ab376c5101b2ac7205fad0344fd2de60
Signature · 1 line
2.55.0.rc0.799.gd6f94ed593-goog
Quoted 45 lines · T.J. Mercier
Write permissions on the
/dev/udmabufdevice file are not required to issue ioctls and allocate udmabufs. Applications should be opening this file asO_RDONLY. The BPFdmabuf_iterselftest 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 fromdrivers/dma-buf/udmabuf.canddrivers/net/hw/ncdevmem.c.Signed-off-by T.J. Mercier <[email protected]>--- tools/testing/selftests/drivers/dma-buf/udmabuf.c | 2 +- tools/testing/selftests/drivers/net/hw/ncdevmem.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)tools/testing/selftests/drivers/dma-buf/udmabuf.c +1
-1@@ -140,7 +140,7 @@ int main(int argc, char *argv[])ksft_print_header ();ksft_set_plan (7 ); - devfd =open ("/dev/udmabuf" ,O_RDWR ); + devfd =open ("/dev/udmabuf" ,O_RDONLY );if (devfd <0 ) { ksft_print_msg( "%s: [skip,no-udmabuf: Unable to access DMA buffer device file]\n",tools/testing/selftests/drivers/net/hw/ncdevmem.c +1
-1@@ -149,7 +149,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;
Quoted 4 lines
base-commit:
fbb7ad31ab376c5101b2ac7205fad0344fd2de60Signature · 1 line
2.55.0.rc0.799.gd6f94ed593-goog
Quoted 47 lines · Bobby Eshleman
Quoted 45 lines · T.J. Mercier
Write permissions on the
/dev/udmabufdevice file are not required to issue ioctls and allocate udmabufs. Applications should be opening this file asO_RDONLY. The BPFdmabuf_iterselftest 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 fromdrivers/dma-buf/udmabuf.canddrivers/net/hw/ncdevmem.c.Signed-off-by T.J. Mercier <[email protected]>--- tools/testing/selftests/drivers/dma-buf/udmabuf.c | 2 +- tools/testing/selftests/drivers/net/hw/ncdevmem.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)tools/testing/selftests/drivers/dma-buf/udmabuf.c +1
-1@@ -140,7 +140,7 @@ int main(int argc, char *argv[])ksft_print_header ();ksft_set_plan (7 ); - devfd =open ("/dev/udmabuf" ,O_RDWR ); + devfd =open ("/dev/udmabuf" ,O_RDONLY );if (devfd <0 ) { ksft_print_msg( "%s: [skip,no-udmabuf: Unable to access DMA buffer device file]\n",tools/testing/selftests/drivers/net/hw/ncdevmem.c +1
-1@@ -149,7 +149,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;
Quoted 6 lines
Quoted 4 lines
base-commit:
fbb7ad31ab376c5101b2ac7205fad0344fd2de60--
2.55.0.rc0.799.gd6f94ed593-googReviewed-by Bobby Eshleman <[email protected]>
Thanks Bobby.
Shuah, would you mind picking this up?
Jakub Kicinski
maintainerQuoted 5 lines · On Fri, 17 Jul 2026 09:29:40 -0700 T.J. Mercier wrote:
Quoted 1 line
Reviewed-by Bobby Eshleman <[email protected]>Thanks Bobby.
Shuah, would you mind picking this up?
Please split the networking part off, networking selftests must go via networking trees.
Quoted 11 lines · Jakub Kicinski
Quoted 5 lines · On Fri, 17 Jul 2026 09:29:40 -0700 T.J. Mercier wrote:
Quoted 1 line
Reviewed-by Bobby Eshleman <[email protected]>Thanks Bobby.
Shuah, would you mind picking this up?
Please split the networking part off, networking selftests must go via networking trees.
Ack, done here:
https://lore.kernel.org/all/[email protected]/