Skip to contentSkip to conversation

arch/sparc64/kernel/sunos_ioctl32.c: sys_ioctl wrong?

Bug 2683 Adrian Bunk 2 participants 2 messages Sep 2, 2005 – Sep 7, 2005

lore
Share & tools
lore
#0 lore raw

Kernel Bugzilla #2683 contains the following report:

<-- snip -->

Problem Description:
The potential error is detected by a static analysis tool in /arch/sparc64/kernel/sunos_ioctl32.c:163-168

163 case _IOW('i', 21, struct ifreq): /* SIOCSIFMTU */
164 ret = sys_ioctl(fd, SIOCSIFMTU, arg);
165 goto out;
166 case _IOWR('i', 22, struct ifreq): /* SIOCGIFMTU */
167 ret = sys_ioctl(fd, SIOCGIFMTU, arg);
168 goto out;

May be changed to:
163 case _IOW('i', 21, struct ifreq32): /* SIOCSIFMTU */
164 ret = compat_sys_ioctl(fd, SIOCSIFMTU, arg);
165 goto out;
166 case _IOWR('i', 22, struct ifreq32): /* SIOCGIFMTU */
167 ret = compat_sys_ioctl(fd, SIOCGIFMTU, arg);
168 goto out;

Can anyone confirm whether it is a bug or not?

<-- snip -->

Please review this issue.

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
#1 lore raw

Re: [Bug 2683] arch/sparc64/kernel/sunos_ioctl32.c: sys_ioctl

From: Adrian Bunk <[email protected]>
Date: Sat, 3 Sep 2005 00:38:16 +0200

Quoted 1 line

Can anyone confirm whether it is a bug or not?

Yep, it's a bug. I've checked in the suggested fix as follows:

diff-tree 09bbe1043a65903c93f6b6df123e36e3584bfac7 (from 93c37f292110a37dd77e4cc0aaf1c341d79bf6aa)

Author: David S. Miller <[email protected]>
Date:   Tue Sep 6 20:12:15 2005 -0700

[SPARC64]: Fix set/get MTU cases in sunos_ioctl()

Need to use compat struct sizes and compat_sys_ioctl(). Reported by Adrian Bunk via kernel bugzilla #2683

arch/sparc64/kernel/sunos_ioctl32.c +5 -4
@@ -152,11 +152,12 @@ asmlinkage int sunos_ioctl (int fd, u32 
 		ret = compat_sys_ioctl(fd, SIOCGIFCONF, arg);
 		goto out;
 
-	case _IOW('i', 21, struct ifreq): /* SIOCSIFMTU */
-		ret = sys_ioctl(fd, SIOCSIFMTU, arg);
+	case _IOW('i', 21, struct ifreq32):
+		ret = compat_sys_ioctl(fd, SIOCSIFMTU, arg);
 		goto out;
-	case _IOWR('i', 22, struct ifreq): /* SIOCGIFMTU */
-		ret = sys_ioctl(fd, SIOCGIFMTU, arg);
+
+	case _IOWR('i', 22, struct ifreq32):
+		ret = compat_sys_ioctl(fd, SIOCGIFMTU, arg);
 		goto out;
 
 	case _IOWR('i', 23, struct ifreq32):