[PATCH AUTOSEL 6.19-5.10] dma-buf: Include ioctl.h in UAPI header
From: Sasha Levin
Date: Tue Mar 10 2026 - 05:08:34 EST
From: "Isaac J. Manjarres" <isaacmanjarres@xxxxxxxxxx>
[ Upstream commit a116bac87118903925108e57781bbfc7a7eea27b ]
include/uapi/linux/dma-buf.h uses several macros from ioctl.h to define
its ioctl commands. However, it does not include ioctl.h itself. So,
if userspace source code tries to include the dma-buf.h file without
including ioctl.h, it can result in build failures.
Therefore, include ioctl.h in the dma-buf UAPI header.
Signed-off-by: Isaac J. Manjarres <isaacmanjarres@xxxxxxxxxx>
Reviewed-by: T.J. Mercier <tjmercier@xxxxxxxxxx>
Reviewed-by: Christian König <christian.koenig@xxxxxxx>
Signed-off-by: Christian König <christian.koenig@xxxxxxx>
Link: https://lore.kernel.org/r/20260303002309.1401849-1-isaacmanjarres@xxxxxxxxxx
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
LLM Generated explanations, may be completely bogus:
Good - `_IOW` is defined in `include/uapi/asm-generic/ioctl.h`, which is
included via `<linux/ioctl.h>`.
## Analysis
**What the commit does:** Adds `#include <linux/ioctl.h>` to the UAPI
header `include/uapi/linux/dma-buf.h`.
**Problem:** The header uses `_IOW` and `_IOWR` macros (lines 172,
177-181) to define ioctl commands but never includes the header that
defines those macros. If userspace includes `dma-buf.h` without
separately including `ioctl.h` first, compilation fails.
**Category:** This is a **build fix** for userspace programs. The dma-
buf UAPI header is broken in the sense that it is not self-contained —
it relies on a transitive include that may or may not exist depending on
what other headers the user includes first.
**Stable kernel criteria assessment:**
1. **Obviously correct:** Yes — the header uses macros from ioctl.h, so
it should include it. This is a textbook missing-include fix.
2. **Fixes a real bug:** Yes — userspace build failures when including
this header standalone.
3. **Small and contained:** Yes — single line addition of an include.
4. **No new features:** Correct — this adds no new functionality.
5. **Risk:** Essentially zero. Adding a missing include to a UAPI header
cannot break anything. The macros were already being used; this just
makes the dependency explicit.
**User impact:** dma-buf is widely used in graphics (GPU drivers,
Vulkan, OpenGL), media, and Android. Any userspace program trying to
include this header in isolation would fail to compile. This has been a
latent bug since 2016.
**Reviews:** Reviewed by T.J. Mercier (Google) and Christian König (AMD,
dma-buf maintainer), giving strong confidence in correctness.
**Verification:**
- Read the file and confirmed `_IOW` is used on lines 172, 177-179 and
`_IOWR` on line 180, without a prior include of ioctl.h (before this
commit).
- Confirmed `_IOW` is defined in `include/uapi/asm-generic/ioctl.h`
(reached via `<linux/ioctl.h>`).
- Confirmed the header was introduced in commit c11e391da2a8f (2016) and
has never included ioctl.h — longstanding bug present in all stable
trees.
- The change is a single-line include addition with zero risk of
regression.
- Reviewed-by from the subsystem maintainer (Christian König).
This is a trivial, zero-risk build fix for a UAPI header that affects
userspace compilation. It meets all stable kernel criteria and falls
squarely into the "build fixes" exception category.
**YES**
include/uapi/linux/dma-buf.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/uapi/linux/dma-buf.h b/include/uapi/linux/dma-buf.h
index 5a6fda66d9adf..e827c9d20c5d3 100644
--- a/include/uapi/linux/dma-buf.h
+++ b/include/uapi/linux/dma-buf.h
@@ -20,6 +20,7 @@
#ifndef _DMA_BUF_UAPI_H_
#define _DMA_BUF_UAPI_H_
+#include <linux/ioctl.h>
#include <linux/types.h>
/**
--
2.51.0