Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20240602222141.31969-1-ismael@iodev.co.uk>
Date: Mon,  3 Jun 2024 00:21:40 +0200
From: Ismael Luceno <ismael@...ev.co.uk>
To: musl@...ts.openwall.com
Cc: Rich Felker <dalias@...c.org>,
	Ismael Luceno <ismael@...ev.co.uk>
Subject: [PATCH v2] ioctl: Fix implicit constant conversion overflow

The last parameter (result of sizeof) to _IOC in _IOR/_IOW/_IOWR causes
the underlying expression's value to be promoted to size_t. Casting it
to unsigned int resolves the issue.

Signed-off-by: Ismael Luceno <ismael@...ev.co.uk>
---
 arch/generic/bits/ioctl.h   | 6 +++---
 arch/mips/bits/ioctl.h      | 6 +++---
 arch/mipsn32/bits/ioctl.h   | 6 +++---
 arch/powerpc/bits/ioctl.h   | 6 +++---
 arch/powerpc64/bits/ioctl.h | 6 +++---
 arch/sh/bits/ioctl.h        | 6 +++---
 6 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/arch/generic/bits/ioctl.h b/arch/generic/bits/ioctl.h
index 60ae8b850b17..524a03ca9d8d 100644
--- a/arch/generic/bits/ioctl.h
+++ b/arch/generic/bits/ioctl.h
@@ -4,9 +4,9 @@
 #define _IOC_READ  2U
 
 #define _IO(a,b) _IOC(_IOC_NONE,(a),(b),0)
-#define _IOW(a,b,c) _IOC(_IOC_WRITE,(a),(b),sizeof(c))
-#define _IOR(a,b,c) _IOC(_IOC_READ,(a),(b),sizeof(c))
-#define _IOWR(a,b,c) _IOC(_IOC_READ|_IOC_WRITE,(a),(b),sizeof(c))
+#define _IOW(a,b,c) _IOC(_IOC_WRITE,(a),(b),(unsigned)sizeof(c))
+#define _IOR(a,b,c) _IOC(_IOC_READ,(a),(b),(unsigned)sizeof(c))
+#define _IOWR(a,b,c) _IOC(_IOC_READ|_IOC_WRITE,(a),(b),(unsigned)sizeof(c))
 
 #define TCGETS		0x5401
 #define TCSETS		0x5402
diff --git a/arch/mips/bits/ioctl.h b/arch/mips/bits/ioctl.h
index e20bf19eaa77..d4eb0cfc5aba 100644
--- a/arch/mips/bits/ioctl.h
+++ b/arch/mips/bits/ioctl.h
@@ -4,9 +4,9 @@
 #define _IOC_WRITE 4U
 
 #define _IO(a,b) _IOC(_IOC_NONE,(a),(b),0)
-#define _IOW(a,b,c) _IOC(_IOC_WRITE,(a),(b),sizeof(c))
-#define _IOR(a,b,c) _IOC(_IOC_READ,(a),(b),sizeof(c))
-#define _IOWR(a,b,c) _IOC(_IOC_READ|_IOC_WRITE,(a),(b),sizeof(c))
+#define _IOW(a,b,c) _IOC(_IOC_WRITE,(a),(b),(unsigned)sizeof(c))
+#define _IOR(a,b,c) _IOC(_IOC_READ,(a),(b),(unsigned)sizeof(c))
+#define _IOWR(a,b,c) _IOC(_IOC_READ|_IOC_WRITE,(a),(b),(unsigned)sizeof(c))
 
 #define TCGETA		0x5401
 #define TCSETA		0x5402
diff --git a/arch/mipsn32/bits/ioctl.h b/arch/mipsn32/bits/ioctl.h
index e20bf19eaa77..d4eb0cfc5aba 100644
--- a/arch/mipsn32/bits/ioctl.h
+++ b/arch/mipsn32/bits/ioctl.h
@@ -4,9 +4,9 @@
 #define _IOC_WRITE 4U
 
 #define _IO(a,b) _IOC(_IOC_NONE,(a),(b),0)
-#define _IOW(a,b,c) _IOC(_IOC_WRITE,(a),(b),sizeof(c))
-#define _IOR(a,b,c) _IOC(_IOC_READ,(a),(b),sizeof(c))
-#define _IOWR(a,b,c) _IOC(_IOC_READ|_IOC_WRITE,(a),(b),sizeof(c))
+#define _IOW(a,b,c) _IOC(_IOC_WRITE,(a),(b),(unsigned)sizeof(c))
+#define _IOR(a,b,c) _IOC(_IOC_READ,(a),(b),(unsigned)sizeof(c))
+#define _IOWR(a,b,c) _IOC(_IOC_READ|_IOC_WRITE,(a),(b),(unsigned)sizeof(c))
 
 #define TCGETA		0x5401
 #define TCSETA		0x5402
diff --git a/arch/powerpc/bits/ioctl.h b/arch/powerpc/bits/ioctl.h
index ac9bfd204a84..b5d45d0c4170 100644
--- a/arch/powerpc/bits/ioctl.h
+++ b/arch/powerpc/bits/ioctl.h
@@ -4,9 +4,9 @@
 #define _IOC_READ  2U
 
 #define _IO(a,b) _IOC(_IOC_NONE,(a),(b),0)
-#define _IOW(a,b,c) _IOC(_IOC_WRITE,(a),(b),sizeof(c))
-#define _IOR(a,b,c) _IOC(_IOC_READ,(a),(b),sizeof(c))
-#define _IOWR(a,b,c) _IOC(_IOC_READ|_IOC_WRITE,(a),(b),sizeof(c))
+#define _IOW(a,b,c) _IOC(_IOC_WRITE,(a),(b),(unsigned)sizeof(c))
+#define _IOR(a,b,c) _IOC(_IOC_READ,(a),(b),(unsigned)sizeof(c))
+#define _IOWR(a,b,c) _IOC(_IOC_READ|_IOC_WRITE,(a),(b),(unsigned)sizeof(c))
 
 #define FIONCLEX	_IO('f', 2)
 #define FIOCLEX		_IO('f', 1)
diff --git a/arch/powerpc64/bits/ioctl.h b/arch/powerpc64/bits/ioctl.h
index b6cbb18f4776..02b84afff108 100644
--- a/arch/powerpc64/bits/ioctl.h
+++ b/arch/powerpc64/bits/ioctl.h
@@ -4,9 +4,9 @@
 #define _IOC_READ  2U
 
 #define _IO(a,b) _IOC(_IOC_NONE,(a),(b),0)
-#define _IOW(a,b,c) _IOC(_IOC_WRITE,(a),(b),sizeof(c))
-#define _IOR(a,b,c) _IOC(_IOC_READ,(a),(b),sizeof(c))
-#define _IOWR(a,b,c) _IOC(_IOC_READ|_IOC_WRITE,(a),(b),sizeof(c))
+#define _IOW(a,b,c) _IOC(_IOC_WRITE,(a),(b),(unsigned)sizeof(c))
+#define _IOR(a,b,c) _IOC(_IOC_READ,(a),(b),(unsigned)sizeof(c))
+#define _IOWR(a,b,c) _IOC(_IOC_READ|_IOC_WRITE,(a),(b),(unsigned)sizeof(c))
 
 #define FIONCLEX	_IO('f', 2)
 #define FIOCLEX		_IO('f', 1)
diff --git a/arch/sh/bits/ioctl.h b/arch/sh/bits/ioctl.h
index 370b6901e261..c918510302d7 100644
--- a/arch/sh/bits/ioctl.h
+++ b/arch/sh/bits/ioctl.h
@@ -4,9 +4,9 @@
 #define _IOC_READ  2U
 
 #define _IO(a,b) _IOC(_IOC_NONE,(a),(b),0)
-#define _IOW(a,b,c) _IOC(_IOC_WRITE,(a),(b),sizeof(c))
-#define _IOR(a,b,c) _IOC(_IOC_READ,(a),(b),sizeof(c))
-#define _IOWR(a,b,c) _IOC(_IOC_READ|_IOC_WRITE,(a),(b),sizeof(c))
+#define _IOW(a,b,c) _IOC(_IOC_WRITE,(a),(b),(unsigned)sizeof(c))
+#define _IOR(a,b,c) _IOC(_IOC_READ,(a),(b),(unsigned)sizeof(c))
+#define _IOWR(a,b,c) _IOC(_IOC_READ|_IOC_WRITE,(a),(b),(unsigned)sizeof(c))
 
 #define FIOCLEX             _IO('f',  1)
 #define FIONCLEX            _IO('f',  2)
-- 
2.44.0

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.