From: Madhavan Srinivasan maddy@linux.ibm.com
[ Upstream commit ab107276607af90b13a5994997e19b7b9731e251 ]
Since termio interface is now obsolete, include/uapi/asm/ioctls.h has some constant macros referring to "struct termio", this caused build failure at userspace.
In file included from /usr/include/asm/ioctl.h:12, from /usr/include/asm/ioctls.h:5, from tst-ioctls.c:3: tst-ioctls.c: In function 'get_TCGETA': tst-ioctls.c:12:10: error: invalid application of 'sizeof' to incomplete type 'struct termio' 12 | return TCGETA; | ^~~~~~
Even though termios.h provides "struct termio", trying to juggle definitions around to make it compile could introduce regressions. So better to open code it.
Reported-by: Tulio Magno tuliom@ascii.art.br Suggested-by: Nicholas Piggin npiggin@gmail.com Tested-by: Justin M. Forbes jforbes@fedoraproject.org Reviewed-by: Michael Ellerman mpe@ellerman.id.au Closes: https://lore.kernel.org/linuxppc-dev/8734dji5wl.fsf@ascii.art.br/ Signed-off-by: Madhavan Srinivasan maddy@linux.ibm.com Link: https://patch.msgid.link/20250517142237.156665-1-maddy@linux.ibm.com Signed-off-by: Sasha Levin sashal@kernel.org ---
**YES**
This commit should be backported to stable kernel trees for the following reasons:
1. **Fixes a real build failure**: The commit message clearly documents a userspace build failure when `asm/ioctls.h` is included without `struct termio` being defined. This breaks userspace programs that use these ioctl definitions.
2. **Simple and contained fix**: The change is minimal and low-risk - it merely replaces macro calls with their hardcoded equivalents. The hardcoded values (0x40147417, 0x80147418, 0x80147419, 0x8014741c) are the exact expansion of the original macros for a 20-byte `struct termio` on PowerPC.
3. **Follows established patterns**: Other architectures (sh and xtensa) already use this same approach of hardcoding the values with comments showing the original macro. This indicates it's a known and accepted solution.
4. **No functional changes**: The ioctl values remain exactly the same - only the way they're defined changes. This ensures binary compatibility is maintained.
5. **Prevents future issues**: As noted in the commit message, the termio interface is obsolete, and trying to reorganize header files to fix this properly could introduce regressions. The hardcoded approach is safer.
6. **Clear user impact**: The commit includes a specific example of the build failure with line numbers and error messages, demonstrating this affects real users (reported by Tulio Magno).
7. **Tested**: The commit indicates it was tested by Justin M. Forbes, providing confidence in the fix.
The commit follows the stable tree rules by fixing an important bug (build failure) with minimal risk of regression, making it an ideal candidate for backporting.
arch/powerpc/include/uapi/asm/ioctls.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/powerpc/include/uapi/asm/ioctls.h b/arch/powerpc/include/uapi/asm/ioctls.h index 2c145da3b774a..b5211e413829a 100644 --- a/arch/powerpc/include/uapi/asm/ioctls.h +++ b/arch/powerpc/include/uapi/asm/ioctls.h @@ -23,10 +23,10 @@ #define TCSETSW _IOW('t', 21, struct termios) #define TCSETSF _IOW('t', 22, struct termios)
-#define TCGETA _IOR('t', 23, struct termio) -#define TCSETA _IOW('t', 24, struct termio) -#define TCSETAW _IOW('t', 25, struct termio) -#define TCSETAF _IOW('t', 28, struct termio) +#define TCGETA 0x40147417 /* _IOR('t', 23, struct termio) */ +#define TCSETA 0x80147418 /* _IOW('t', 24, struct termio) */ +#define TCSETAW 0x80147419 /* _IOW('t', 25, struct termio) */ +#define TCSETAF 0x8014741c /* _IOW('t', 28, struct termio) */
#define TCSBRK _IO('t', 29) #define TCXONC _IO('t', 30)