Skip to contentSkip to conversation

arm64: signal: Fix some under-bracketed UAPI macros

PATCH Applied Dave Martin 3 participants 3 messages Jul 29, 2024 – Aug 16, 2024 arm64

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: signal: Fix some under-bracketed UAPI macros

A few SME-related sigcontext UAPI macros leave an argument unprotected from misparsing during macro expansion.

Add parentheses around references to macro arguments where appropriate.

Fixes ee072cf70804 ("arm64/sme: Implement signal handling for ZT")
Fixes 39782210eb7e ("arm64/sme: Implement ZA signal handling")

---

Based on: v6.11-rc1

These were just spotted by inspection, but it seems a good idea to sort them out anyway. At worst, the change is harmless.

The way the macros are typically used (and the presumed lack of bug reports) means that the chance of actually hitting these issues appears low.

---
 arch/arm64/include/uapi/asm/sigcontext.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm64/include/uapi/asm/sigcontext.h +3 -3
index 8a45b7a411e0..57f76d82077e 100644
@@ -320,10 +320,10 @@ struct zt_context {
 	((sizeof(struct za_context) + (__SVE_VQ_BYTES - 1))	\
 		/ __SVE_VQ_BYTES * __SVE_VQ_BYTES)
 
-#define ZA_SIG_REGS_SIZE(vq) ((vq * __SVE_VQ_BYTES) * (vq * __SVE_VQ_BYTES))
+#define ZA_SIG_REGS_SIZE(vq) (((vq) * __SVE_VQ_BYTES) * ((vq) * __SVE_VQ_BYTES))
 
 #define ZA_SIG_ZAV_OFFSET(vq, n) (ZA_SIG_REGS_OFFSET + \
-				  (SVE_SIG_ZREG_SIZE(vq) * n))
+				  (SVE_SIG_ZREG_SIZE(vq) * (n)))
 
 #define ZA_SIG_CONTEXT_SIZE(vq) \
 		(ZA_SIG_REGS_OFFSET + ZA_SIG_REGS_SIZE(vq))
@@ -334,7 +334,7 @@ struct zt_context {
 
 #define ZT_SIG_REGS_OFFSET sizeof(struct zt_context)
 
-#define ZT_SIG_REGS_SIZE(n) (ZT_SIG_REG_BYTES * n)
+#define ZT_SIG_REGS_SIZE(n) (ZT_SIG_REG_BYTES * (n))
 
 #define ZT_SIG_CONTEXT_SIZE(n) \
 	(sizeof(struct zt_context) + ZT_SIG_REGS_SIZE(n))

base-commit: 8400291e289ee6b2bf9779ff1c83a291501f017b

Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Dave Martin

A few SME-related sigcontext UAPI macros leave an argument unprotected from misparsing during macro expansion.

Add parentheses around references to macro arguments where appropriate.

maintainer Applied
#2 lore raw
In reply to Dave Martin
Quoted 8 lines · Dave Martin

A few SME-related sigcontext UAPI macros leave an argument unprotected from misparsing during macro expansion.

Add parentheses around references to macro arguments where appropriate.

[...]

Applied to arm64 (for-next/misc), thanks!

[1/1] arm64: signal: Fix some under-bracketed UAPI macros

      https://git.kernel.org/arm64/c/fc2220c9b158

Cheers,

Signature · 5 lines
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev