aboutsummaryrefslogtreecommitdiffstats
path: root/fs/compat_ioctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/compat_ioctl.c')
-rw-r--r--fs/compat_ioctl.c100
1 files changed, 48 insertions, 52 deletions
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index c5ded5ff72b5..626c7483b4de 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -31,6 +31,7 @@
31#include <linux/skbuff.h> 31#include <linux/skbuff.h>
32#include <linux/netlink.h> 32#include <linux/netlink.h>
33#include <linux/vt.h> 33#include <linux/vt.h>
34#include <linux/falloc.h>
34#include <linux/fs.h> 35#include <linux/fs.h>
35#include <linux/file.h> 36#include <linux/file.h>
36#include <linux/ppp_defs.h> 37#include <linux/ppp_defs.h>
@@ -94,7 +95,6 @@
94#include <linux/atm_tcp.h> 95#include <linux/atm_tcp.h>
95#include <linux/sonet.h> 96#include <linux/sonet.h>
96#include <linux/atm_suni.h> 97#include <linux/atm_suni.h>
97#include <linux/mtd/mtd.h>
98 98
99#include <linux/usb.h> 99#include <linux/usb.h>
100#include <linux/usbdevice_fs.h> 100#include <linux/usbdevice_fs.h>
@@ -1405,46 +1405,6 @@ static int ioc_settimeout(unsigned int fd, unsigned int cmd, unsigned long arg)
1405#define HIDPGETCONNLIST _IOR('H', 210, int) 1405#define HIDPGETCONNLIST _IOR('H', 210, int)
1406#define HIDPGETCONNINFO _IOR('H', 211, int) 1406#define HIDPGETCONNINFO _IOR('H', 211, int)
1407 1407
1408struct mtd_oob_buf32 {
1409 u_int32_t start;
1410 u_int32_t length;
1411 compat_caddr_t ptr; /* unsigned char* */
1412};
1413
1414#define MEMWRITEOOB32 _IOWR('M',3,struct mtd_oob_buf32)
1415#define MEMREADOOB32 _IOWR('M',4,struct mtd_oob_buf32)
1416
1417static int mtd_rw_oob(unsigned int fd, unsigned int cmd, unsigned long arg)
1418{
1419 struct mtd_oob_buf __user *buf = compat_alloc_user_space(sizeof(*buf));
1420 struct mtd_oob_buf32 __user *buf32 = compat_ptr(arg);
1421 u32 data;
1422 char __user *datap;
1423 unsigned int real_cmd;
1424 int err;
1425
1426 real_cmd = (cmd == MEMREADOOB32) ?
1427 MEMREADOOB : MEMWRITEOOB;
1428
1429 if (copy_in_user(&buf->start, &buf32->start,
1430 2 * sizeof(u32)) ||
1431 get_user(data, &buf32->ptr))
1432 return -EFAULT;
1433 datap = compat_ptr(data);
1434 if (put_user(datap, &buf->ptr))
1435 return -EFAULT;
1436
1437 err = sys_ioctl(fd, real_cmd, (unsigned long) buf);
1438
1439 if (!err) {
1440 if (copy_in_user(&buf32->start, &buf->start,
1441 2 * sizeof(u32)))
1442 err = -EFAULT;
1443 }
1444
1445 return err;
1446}
1447
1448#ifdef CONFIG_BLOCK 1408#ifdef CONFIG_BLOCK
1449struct raw32_config_request 1409struct raw32_config_request
1450{ 1410{
@@ -1820,6 +1780,41 @@ lp_timeout_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1820 return sys_ioctl(fd, cmd, (unsigned long)tn); 1780 return sys_ioctl(fd, cmd, (unsigned long)tn);
1821} 1781}
1822 1782
1783/* on ia32 l_start is on a 32-bit boundary */
1784#if defined(CONFIG_IA64) || defined(CONFIG_X86_64)
1785struct space_resv_32 {
1786 __s16 l_type;
1787 __s16 l_whence;
1788 __s64 l_start __attribute__((packed));
1789 /* len == 0 means until end of file */
1790 __s64 l_len __attribute__((packed));
1791 __s32 l_sysid;
1792 __u32 l_pid;
1793 __s32 l_pad[4]; /* reserve area */
1794};
1795
1796#define FS_IOC_RESVSP_32 _IOW ('X', 40, struct space_resv_32)
1797#define FS_IOC_RESVSP64_32 _IOW ('X', 42, struct space_resv_32)
1798
1799/* just account for different alignment */
1800static int compat_ioctl_preallocate(struct file *file, unsigned long arg)
1801{
1802 struct space_resv_32 __user *p32 = (void __user *)arg;
1803 struct space_resv __user *p = compat_alloc_user_space(sizeof(*p));
1804
1805 if (copy_in_user(&p->l_type, &p32->l_type, sizeof(s16)) ||
1806 copy_in_user(&p->l_whence, &p32->l_whence, sizeof(s16)) ||
1807 copy_in_user(&p->l_start, &p32->l_start, sizeof(s64)) ||
1808 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
1809 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
1810 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
1811 copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
1812 return -EFAULT;
1813
1814 return ioctl_preallocate(file, p);
1815}
1816#endif
1817
1823 1818
1824typedef int (*ioctl_trans_handler_t)(unsigned int, unsigned int, 1819typedef int (*ioctl_trans_handler_t)(unsigned int, unsigned int,
1825 unsigned long, struct file *); 1820 unsigned long, struct file *);
@@ -2426,15 +2421,6 @@ COMPATIBLE_IOCTL(USBDEVFS_SUBMITURB32)
2426COMPATIBLE_IOCTL(USBDEVFS_REAPURB32) 2421COMPATIBLE_IOCTL(USBDEVFS_REAPURB32)
2427COMPATIBLE_IOCTL(USBDEVFS_REAPURBNDELAY32) 2422COMPATIBLE_IOCTL(USBDEVFS_REAPURBNDELAY32)
2428COMPATIBLE_IOCTL(USBDEVFS_CLEAR_HALT) 2423COMPATIBLE_IOCTL(USBDEVFS_CLEAR_HALT)
2429/* MTD */
2430COMPATIBLE_IOCTL(MEMGETINFO)
2431COMPATIBLE_IOCTL(MEMERASE)
2432COMPATIBLE_IOCTL(MEMLOCK)
2433COMPATIBLE_IOCTL(MEMUNLOCK)
2434COMPATIBLE_IOCTL(MEMGETREGIONCOUNT)
2435COMPATIBLE_IOCTL(MEMGETREGIONINFO)
2436COMPATIBLE_IOCTL(MEMGETBADBLOCK)
2437COMPATIBLE_IOCTL(MEMSETBADBLOCK)
2438/* NBD */ 2424/* NBD */
2439ULONG_IOCTL(NBD_SET_SOCK) 2425ULONG_IOCTL(NBD_SET_SOCK)
2440ULONG_IOCTL(NBD_SET_BLKSIZE) 2426ULONG_IOCTL(NBD_SET_BLKSIZE)
@@ -2544,8 +2530,6 @@ COMPATIBLE_IOCTL(JSIOCGBUTTONS)
2544COMPATIBLE_IOCTL(JSIOCGNAME(0)) 2530COMPATIBLE_IOCTL(JSIOCGNAME(0))
2545 2531
2546/* now things that need handlers */ 2532/* now things that need handlers */
2547HANDLE_IOCTL(MEMREADOOB32, mtd_rw_oob)
2548HANDLE_IOCTL(MEMWRITEOOB32, mtd_rw_oob)
2549#ifdef CONFIG_NET 2533#ifdef CONFIG_NET
2550HANDLE_IOCTL(SIOCGIFNAME, dev_ifname32) 2534HANDLE_IOCTL(SIOCGIFNAME, dev_ifname32)
2551HANDLE_IOCTL(SIOCGIFCONF, dev_ifconf) 2535HANDLE_IOCTL(SIOCGIFCONF, dev_ifconf)
@@ -2808,6 +2792,18 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
2808 case FIOQSIZE: 2792 case FIOQSIZE:
2809 break; 2793 break;
2810 2794
2795#if defined(CONFIG_IA64) || defined(CONFIG_X86_64)
2796 case FS_IOC_RESVSP_32:
2797 case FS_IOC_RESVSP64_32:
2798 error = compat_ioctl_preallocate(filp, arg);
2799 goto out_fput;
2800#else
2801 case FS_IOC_RESVSP:
2802 case FS_IOC_RESVSP64:
2803 error = ioctl_preallocate(filp, (void __user *)arg);
2804 goto out_fput;
2805#endif
2806
2811 case FIBMAP: 2807 case FIBMAP:
2812 case FIGETBSZ: 2808 case FIGETBSZ:
2813 case FIONREAD: 2809 case FIONREAD: