From: Arun Sharma <arun.sharma@intel.com>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org, "Tian, Kevin" <kevin.tian@intel.com>
Subject: [PATCH] incorrect use of sizeof() in ioctl definitions
Date: Tue, 30 Sep 2003 13:53:52 -0700 [thread overview]
Message-ID: <3F79ED60.2030207@intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 694 bytes --]
Some drivers seem to use macros such as _IOR/_IOW in a way that ends up calling the sizeof() operator twice. For eg:
-#define FBIO_ATY128_GET_MIRROR _IOR('@', 1, sizeof(__u32*))
+#define FBIO_ATY128_GET_MIRROR _IOR('@', 1, __u32*)
from include/asm-ia64/ioctl.h (other archs are similar):
#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size))
While this is not a problem for native 32 bit or native 64 platforms, it is a problem for 32 bit applications running on 64 bit platforms in compatibility mode because
sizeof(sizeof(__u32*)) on a 64 bit kernel != sizeof(sizeof(__u32*)) on a 32 bit app.
The attached patch attempts to fix the instances we could find.
-Arun
[-- Attachment #2: ioctl32-sizeof.txt --]
[-- Type: text/plain, Size: 9003 bytes --]
--- ia64-linux2.6.0/include/linux/matroxfb.h Tue Aug 26 16:47:26 2003
+++ ia64-linux2.6.0-patch/include/linux/matroxfb.h Fri Sep 5 16:24:58 2003
@@ -15,21 +15,21 @@
#define MATROXFB_OUTPUT_MODE_NTSC 0x0002
#define MATROXFB_OUTPUT_MODE_MONITOR 0x0080
};
-#define MATROXFB_SET_OUTPUT_MODE _IOW('n',0xFA,sizeof(struct matroxioc_output_mode))
-#define MATROXFB_GET_OUTPUT_MODE _IOWR('n',0xFA,sizeof(struct matroxioc_output_mode))
+#define MATROXFB_SET_OUTPUT_MODE _IOW('n',0xFA,struct matroxioc_output_mode)
+#define MATROXFB_GET_OUTPUT_MODE _IOWR('n',0xFA,struct matroxioc_output_mode)
/* bitfield */
#define MATROXFB_OUTPUT_CONN_PRIMARY (1 << MATROXFB_OUTPUT_PRIMARY)
#define MATROXFB_OUTPUT_CONN_SECONDARY (1 << MATROXFB_OUTPUT_SECONDARY)
#define MATROXFB_OUTPUT_CONN_DFP (1 << MATROXFB_OUTPUT_DFP)
/* connect these outputs to this framebuffer */
-#define MATROXFB_SET_OUTPUT_CONNECTION _IOW('n',0xF8,sizeof(__u32))
+#define MATROXFB_SET_OUTPUT_CONNECTION _IOW('n',0xF8,__u32)
/* which outputs are connected to this framebuffer */
-#define MATROXFB_GET_OUTPUT_CONNECTION _IOR('n',0xF8,sizeof(__u32))
+#define MATROXFB_GET_OUTPUT_CONNECTION _IOR('n',0xF8,__u32)
/* which outputs are available for this framebuffer */
-#define MATROXFB_GET_AVAILABLE_OUTPUTS _IOR('n',0xF9,sizeof(__u32))
+#define MATROXFB_GET_AVAILABLE_OUTPUTS _IOR('n',0xF9,__u32)
/* which outputs exist on this framebuffer */
-#define MATROXFB_GET_ALL_OUTPUTS _IOR('n',0xFB,sizeof(__u32))
+#define MATROXFB_GET_ALL_OUTPUTS _IOR('n',0xFB,__u32)
enum matroxfb_ctrl_id {
MATROXFB_CID_TESTOUT = V4L2_CID_PRIVATE_BASE,
--- ia64-linux2.6.0/drivers/video/aty/aty128fb.c Fri Sep 5 16:10:59 2003
+++ ia64-linux2.6.0-patch/drivers/video/aty/aty128fb.c Fri Sep 5 16:01:43 2003
@@ -2041,9 +2041,9 @@
#define ATY_MIRROR_CRT_ON 0x00000002
/* out param: u32* backlight value: 0 to 15 */
-#define FBIO_ATY128_GET_MIRROR _IOR('@', 1, sizeof(__u32*))
+#define FBIO_ATY128_GET_MIRROR _IOR('@', 1, __u32*)
/* in param: u32* backlight value: 0 to 15 */
-#define FBIO_ATY128_SET_MIRROR _IOW('@', 2, sizeof(__u32*))
+#define FBIO_ATY128_SET_MIRROR _IOW('@', 2, __u32*)
static int aty128fb_ioctl(struct inode *inode, struct file *file, u_int cmd,
u_long arg, struct fb_info *info)
--- ia64-linux2.6.0/include/linux/coda.h Tue Aug 26 16:47:26 2003
+++ ia64-linux2.6.0-patch/include/linux/coda.h Fri Sep 5 16:15:54 2003
@@ -324,7 +324,7 @@
#define VC_MAXMSGSIZE sizeof(union inputArgs)+sizeof(union outputArgs) +\
VC_MAXDATASIZE
-#define CIOC_KERNEL_VERSION _IOWR('c', 10, sizeof (int))
+#define CIOC_KERNEL_VERSION _IOWR('c', 10, int)
#if 0
#define CODA_KERNEL_VERSION 0 /* don't care about kernel version number */
--- ia64-linux2.6.0/drivers/net/wan/cosa.h Tue Aug 26 16:47:25 2003
+++ ia64-linux2.6.0-patch/drivers/net/wan/cosa.h Fri Sep 5 16:17:52 2003
@@ -73,19 +73,19 @@
#define COSAIORSET _IO('C',0xf0)
/* Start microcode at given address */
-#define COSAIOSTRT _IOW('C',0xf1,sizeof(int))
+#define COSAIOSTRT _IOW('C',0xf1,int)
/* Read the block from the device memory */
-#define COSAIORMEM _IOR('C',0xf2,sizeof(struct cosa_download *))
+#define COSAIORMEM _IOR('C',0xf2,struct cosa_download*)
/* Write the block to the device memory (i.e. download the microcode) */
-#define COSAIODOWNLD _IOW('C',0xf2,sizeof(struct cosa_download *))
+#define COSAIODOWNLD _IOW('C',0xf2,struct cosa_download*)
/* Read the device type (one of "srp", "cosa", and "cosa8" for now) */
-#define COSAIORTYPE _IOR('C',0xf3,sizeof(char *))
+#define COSAIORTYPE _IOR('C',0xf3,char*)
/* Read the device identification string */
-#define COSAIORIDSTR _IOR('C',0xf4,sizeof(char *))
+#define COSAIORIDSTR _IOR('C',0xf4,char*)
/* Maximum length of the identification string. */
#define COSA_MAX_ID_STRING 128
@@ -100,7 +100,7 @@
#define COSAIONRCHANS _IO('C',0xf8)
/* Set the driver for the bus-master operations */
-#define COSAIOBMSET _IOW('C', 0xf9, sizeof(unsigned short))
+#define COSAIOBMSET _IOW('C', 0xf9, unsigned short)
#define COSA_BM_OFF 0 /* Bus-mastering off - use ISA DMA (default) */
#define COSA_BM_ON 1 /* Bus-mastering on - faster but untested */
--- ia64-linux2.6.0/include/linux/fs.h Fri Sep 5 16:14:19 2003
+++ ia64-linux2.6.0-patch/include/linux/fs.h Fri Sep 5 16:18:57 2003
@@ -187,15 +187,15 @@
#define BLKSSZGET _IO(0x12,104)/* get block device sector size */
#if 0
#define BLKPG _IO(0x12,105)/* See blkpg.h */
-#define BLKELVGET _IOR(0x12,106,sizeof(blkelv_ioctl_arg_t))/* elevator get */
-#define BLKELVSET _IOW(0x12,107,sizeof(blkelv_ioctl_arg_t))/* elevator set */
+#define BLKELVGET _IOR(0x12,106,blkelv_ioctl_arg_t)/* elevator get */
+#define BLKELVSET _IOW(0x12,107,blkelv_ioctl_arg_t)/* elevator set */
/* This was here just to show that the number is taken -
probably all these _IO(0x12,*) ioctls should be moved to blkpg.h. */
#endif
/* A jump here: 108-111 have been used for various private purposes. */
-#define BLKBSZGET _IOR(0x12,112,sizeof(int))
-#define BLKBSZSET _IOW(0x12,113,sizeof(int))
-#define BLKGETSIZE64 _IOR(0x12,114,sizeof(u64)) /* return device size in bytes (u64 *arg) */
+#define BLKBSZGET _IOR(0x12,112,int)
+#define BLKBSZSET _IOW(0x12,113,int)
+#define BLKGETSIZE64 _IOR(0x12,114,u64) /* return device size in bytes (u64 *arg) */
#define BMAP_IOCTL 1 /* obsolete - kept for compatibility */
#define FIBMAP _IO(0x00,1) /* bmap access */
--- ia64-linux2.6.0/include/linux/i8k.h Tue Aug 26 16:47:26 2003
+++ ia64-linux2.6.0-patch/include/linux/i8k.h Mon Sep 8 09:25:39 2003
@@ -22,11 +22,11 @@
#define I8K_BIOS_VERSION _IOR ('i', 0x80, 4)
#define I8K_MACHINE_ID _IOR ('i', 0x81, 16)
-#define I8K_POWER_STATUS _IOR ('i', 0x82, sizeof(int))
-#define I8K_FN_STATUS _IOR ('i', 0x83, sizeof(int))
-#define I8K_GET_TEMP _IOR ('i', 0x84, sizeof(int))
-#define I8K_GET_SPEED _IOWR('i', 0x85, sizeof(int))
-#define I8K_GET_FAN _IOWR('i', 0x86, sizeof(int))
+#define I8K_POWER_STATUS _IOR ('i', 0x82, int)
+#define I8K_FN_STATUS _IOR ('i', 0x83, int)
+#define I8K_GET_TEMP _IOR ('i', 0x84, int)
+#define I8K_GET_SPEED _IOWR('i', 0x85, int)
+#define I8K_GET_FAN _IOWR('i', 0x86, int)
#define I8K_SET_FAN _IOWR('i', 0x87, sizeof(int)*2)
#define I8K_FAN_LEFT 1
--- ia64-linux2.6.0/include/linux/if_pppox.h Tue Aug 26 16:47:26 2003
+++ ia64-linux2.6.0-patch/include/linux/if_pppox.h Fri Sep 5 16:22:06 2003
@@ -67,9 +67,9 @@
*
********************************************************************/
-#define PPPOEIOCSFWD _IOW(0xB1 ,0, sizeof(struct sockaddr_pppox))
+#define PPPOEIOCSFWD _IOW(0xB1 ,0, struct sockaddr_pppox)
#define PPPOEIOCDFWD _IO(0xB1 ,1)
-/*#define PPPOEIOCGFWD _IOWR(0xB1,2, sizeof(struct sockaddr_pppox))*/
+/*#define PPPOEIOCGFWD _IOWR(0xB1,2, struct sockaddr_pppox)*/
/* Codes to identify message types */
#define PADI_CODE 0x09
--- ia64-linux2.6.0/include/linux/pmu.h Tue Aug 26 16:47:26 2003
+++ ia64-linux2.6.0-patch/include/linux/pmu.h Fri Sep 5 16:26:16 2003
@@ -107,15 +107,15 @@
/* no param */
#define PMU_IOC_SLEEP _IO('B', 0)
/* out param: u32* backlight value: 0 to 15 */
-#define PMU_IOC_GET_BACKLIGHT _IOR('B', 1, sizeof(__u32*))
+#define PMU_IOC_GET_BACKLIGHT _IOR('B', 1, __u32*)
/* in param: u32 backlight value: 0 to 15 */
-#define PMU_IOC_SET_BACKLIGHT _IOW('B', 2, sizeof(__u32))
+#define PMU_IOC_SET_BACKLIGHT _IOW('B', 2, __u32)
/* out param: u32* PMU model */
-#define PMU_IOC_GET_MODEL _IOR('B', 3, sizeof(__u32*))
+#define PMU_IOC_GET_MODEL _IOR('B', 3, __u32*)
/* out param: u32* has_adb: 0 or 1 */
-#define PMU_IOC_HAS_ADB _IOR('B', 4, sizeof(__u32*))
+#define PMU_IOC_HAS_ADB _IOR('B', 4, __u32*)
/* out param: u32* can_sleep: 0 or 1 */
-#define PMU_IOC_CAN_SLEEP _IOR('B', 5, sizeof(__u32*))
+#define PMU_IOC_CAN_SLEEP _IOR('B', 5, __u32*)
/* no param */
#define PMU_IOC_GRAB_BACKLIGHT _IOR('B', 6, 0)
--- ia64-linux2.6.0/include/linux/radeonfb.h Tue Aug 26 16:47:26 2003
+++ ia64-linux2.6.0-patch/include/linux/radeonfb.h Fri Sep 5 16:26:41 2003
@@ -8,8 +8,8 @@
#define ATY_RADEON_CRT_ON 0x00000002
-#define FBIO_RADEON_GET_MIRROR _IOR('@', 3, sizeof(__u32*))
-#define FBIO_RADEON_SET_MIRROR _IOW('@', 4, sizeof(__u32*))
+#define FBIO_RADEON_GET_MIRROR _IOR('@', 3, __u32*)
+#define FBIO_RADEON_SET_MIRROR _IOW('@', 4, __u32*)
#endif
--- ia64-linux2.6.0/include/video/sisfb.h Tue Aug 26 16:47:26 2003
+++ ia64-linux2.6.0-patch/include/video/sisfb.h Fri Sep 5 16:27:27 2003
@@ -145,9 +145,9 @@
/* If changing this, vgatypes.h must also be changed (for X driver) */
/* TW: ioctl for identifying and giving some info (esp. memory heap start) */
-#define SISFB_GET_INFO _IOR('n',0xF8,sizeof(__u32))
+#define SISFB_GET_INFO _IOR('n',0xF8,__u32)
-#define SISFB_GET_VBRSTATUS _IOR('n',0xF9,sizeof(__u32))
+#define SISFB_GET_VBRSTATUS _IOR('n',0xF9,__u32)
/* TW: Structure argument for SISFB_GET_INFO ioctl */
typedef struct _SISFB_INFO sisfb_info, *psisfb_info;
next reply other threads:[~2003-09-30 20:55 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-30 20:53 Arun Sharma [this message]
2003-09-30 21:08 ` [PATCH] incorrect use of sizeof() in ioctl definitions Andrew Morton
2003-09-30 21:35 ` Russell King
2003-09-30 21:43 ` Andrew Morton
2003-09-30 22:27 ` Maciej Zenczykowski
2003-09-30 22:25 ` Matthew Wilcox
2003-10-01 0:32 ` Andries Brouwer
-- strict thread matches above, loose matches on Subject: below --
2003-10-08 8:40 Tian, Kevin
2003-10-08 10:01 ` Maciej Zenczykowski
2003-10-08 9:58 Tian, Kevin
2003-10-08 13:30 ` Matthew Wilcox
2003-10-08 11:42 Tian, Kevin
2003-10-08 13:33 ` Matthew Wilcox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3F79ED60.2030207@intel.com \
--to=arun.sharma@intel.com \
--cc=akpm@osdl.org \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.