RFC: compat ioctl fixes/cleanups/additions
cover RFC: compat ioctl fixes/cleanups/additions
This should properly hook up all ioctls which need compat handlers on intel or ppc; it passes the auto qa group on intel, and does ok on ppc (there are still issues with xfsdump itself if the ppc page size is large (64k in my case))
This might be a little overboard; I'm half tempted to remove the handlers that only intel boxes need; would anyone be running 32-bit apps calling xfs ioctls on x86_64 or ia64? Seems unlikely; and removing them would cut down the size of this patchset:
linux-2.6/xfs_ioctl.c | 6 linux-2.6/xfs_ioctl32.c | 651 +++++++++++++++++++++++++++++++++--------------- linux-2.6/xfs_ioctl32.h | 209 +++++++++++++++ xfs_fs.h | 6 xfs_itable.c | 45 ++- xfs_itable.h | 14 + 6 files changed, 716 insertions(+), 215 deletions(-)
If the sgi guys can toss this into qa, I'd be much obliged. I hope to have some xfsdump fixes at some point so we can actually see most things pass (if your ppc box has < 64k pages, it might work fine for you already...)
Thanks,
-Eric
Signature · 4 lines
_______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 1/11 Move compat ioctl structs & numbers into xfs_ioctl32.h
This makes the c file less cluttered and a bit more
readable Consistently name the ioctl number
macros with "_32" and the compatibility stuctures with "_compat." Rename the helpers which simply copy in the arg with "_copyin" for easy identification.
--
fs/xfs/linux-2.6/xfs_ioctl32.c +33 -157
@@ -49,36 +49,11 @@#define _NATIVE_IOC (cmd, type) \ _IOC(_IOC_DIR(cmd), _IOC_TYPE(cmd), _IOC_NR(cmd), sizeof(type)) -#if defined(CONFIG_IA64 ) || defined(CONFIG_X86_64 ) -#define BROKEN_X86_ALIGNMENT -#define _PACKED __attribute__((packed)) -/* on ia32 l_start is on a 32-bit boundary */ -typedef struct xfs_flock64_32 { -__s16 l_type; -__s16 l_whence; -__s64 l_start __attribute__((packed)); -/* len == 0 means until end of file */ -__s64 l_len __attribute__((packed)); -__s32 l_sysid; -__u32 l_pid; -__s32 l_pad[4 ];/* reserve area */ -}xfs_flock64_32_t ; - -#define XFS_IOC_ALLOCSP_32 _IOW ('X', 10, struct xfs_flock64_32) -#define XFS_IOC_FREESP_32 _IOW ('X', 11, struct xfs_flock64_32) -#define XFS_IOC_ALLOCSP64_32 _IOW ('X', 36, struct xfs_flock64_32) -#define XFS_IOC_FREESP64_32 _IOW ('X', 37, struct xfs_flock64_32) -#define XFS_IOC_RESVSP_32 _IOW ('X', 40, struct xfs_flock64_32) -#define XFS_IOC_UNRESVSP_32 _IOW ('X', 41, struct xfs_flock64_32) -#define XFS_IOC_RESVSP64_32 _IOW ('X', 42, struct xfs_flock64_32) -#define XFS_IOC_UNRESVSP64_32 _IOW ('X', 43, struct xfs_flock64_32) - -/* just account for different alignment */ +#ifdef BROKEN_X86_ALIGNMENT STATIC unsigned long -xfs_ioctl32_flock ( -unsigned long arg) +xfs_ioctl32_flock_copyin (unsigned long arg) { -xfs_flock64_32_t __user *p32 = (void __user *)arg; +compat_xfs_flock64_t __user *p32 = (void __user *)arg;xfs_flock64_t __user *p =compat_alloc_user_space (sizeof (*p)); if (copy_in_user(&p->l_type, &p32->l_type, sizeof(s16)) ||
@@ -88,54 +63,24 @@ xfs_ioctl32_flock(copy_in_user (&p->l_sysid, &p32->l_sysid,sizeof (s32)) ||copy_in_user (&p->l_pid, &p32->l_pid,sizeof (u32)) || copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32))) - return -EFAULT; + return -XFS_ERROR(EFAULT);return (unsigned long )p; } -typedef struct compat_xfs_fsop_geom_v1 { -__u32 blocksize;/* filesystem (data) block size */ -__u32 rtextsize;/* realtime extent size */ -__u32 agblocks;/* fsblocks in an AG */ -__u32 agcount;/* number of allocation groups */ -__u32 logblocks;/* fsblocks in the log */ -__u32 sectsize;/* (data) sector size, bytes */ -__u32 inodesize;/* inode size in bytes */ -__u32 imaxpct;/* max allowed inode space(%) */ -__u64 datablocks;/* fsblocks in data subvolume */ -__u64 rtblocks;/* fsblocks in realtime subvol */ -__u64 rtextents;/* rt extents in realtime subvol*/ -__u64 logstart;/* starting fsblock of the log */ -unsigned char uuid[16 ];/* unique id of the filesystem */ -__u32 sunit;/* stripe unit, fsblocks */ -__u32 swidth;/* stripe width, fsblocks */ -__s32 version;/* structure version */ -__u32 flags;/* superblock version flags */ -__u32 logsectsize;/* log sector size, bytes */ -__u32 rtsectsize;/* realtime sector size, bytes */ -__u32 dirblocksize;/* directory block size, bytes */ -} __attribute__((packed))compat_xfs_fsop_geom_v1_t ; - -#define XFS_IOC_FSGEOMETRY_V1_32 \ - _IOR ('X', 100, struct compat_xfs_fsop_geom_v1) - -STATIC unsigned long xfs_ioctl32_geom_v1 (unsigned long arg) +STATIC unsigned long +xfs_ioctl32_geom_v1_copyin (unsigned long arg) {compat_xfs_fsop_geom_v1_t __user *p32 = (void __user *)arg;xfs_fsop_geom_v1_t __user *p =compat_alloc_user_space (sizeof (*p));if (copy_in_user (p, p32,sizeof (*p32))) -return -EFAULT ; +return -XFS_ERROR (EFAULT );return (unsigned long )p; } -typedef struct compat_xfs_inogrp { -__u64 xi_startino;/* starting inode number */ -__s32 xi_alloccount;/* # bits set in allocmask */ -__u64 xi_allocmask;/* mask of allocated inodes */ -} __attribute__((packed))compat_xfs_inogrp_t ; - -STATIC int xfs_inumbers_fmt_compat( +STATIC int +xfs_inumbers_fmt_compat( void __user *ubuffer, const xfs_inogrp_t *buffer, long count,
@@ -148,7 +93,7 @@ STATIC int xfs_inumbers_fmt_compat(if (put_user (buffer[i].xi_startino, &p32[i].xi_startino) ||put_user (buffer[i].xi_alloccount, &p32[i].xi_alloccount) ||put_user (buffer[i].xi_allocmask, &p32[i].xi_allocmask)) -return -EFAULT ; +return -XFS_ERROR (EFAULT ); } *written = count *sizeof (*p32);return 0 ;
@@ -163,49 +108,22 @@ STATIC int xfs_inumbers_fmt_compat(/* XFS_IOC_FSBULKSTAT and friends */ -typedef struct compat_xfs_bstime { -__s32 tv_sec;/* seconds */ -__s32 tv_nsec;/* and nanoseconds */ -}compat_xfs_bstime_t ; - -STATIC int xfs_bstime_store_compat( +STATIC int +xfs_bstime_store_compat (compat_xfs_bstime_t __user *p32,const xfs_bstime_t *p) { -__s32 sec32; +compat_time_t sec32; sec32 = p->tv_sec;if (put_user (sec32, &p32->tv_sec) ||put_user (p->tv_nsec, &p32->tv_nsec)) -return -EFAULT ; +return -XFS_ERROR (EFAULT );return 0 ; } -typedef struct compat_xfs_bstat { -__u64 bs_ino;/* inode number */ -__u16 bs_mode;/* type and mode */ -__u16 bs_nlink;/* number of links */ -__u32 bs_uid;/* user id */ -__u32 bs_gid;/* group id */ -__u32 bs_rdev;/* device value */ -__s32 bs_blksize;/* block size */ -__s64 bs_size;/* file size */ -compat_xfs_bstime_t bs_atime;/* access time */ -compat_xfs_bstime_t bs_mtime;/* modify time */ -compat_xfs_bstime_t bs_ctime;/* inode change time */ -int64_t bs_blocks;/* number of blocks */ -__u32 bs_xflags;/* extended flags */ -__s32 bs_extsize;/* extent size */ -__s32 bs_extents;/* number of extents */ -__u32 bs_gen;/* generation count */ -__u16 bs_projid;/* project id */ -unsigned char bs_pad[14 ];/* pad space, unused */ -__u32 bs_dmevmask;/* DMIG event mask */ -__u16 bs_dmstate;/* DMIG state info */ -__u16 bs_aextents;/* attribute number of extents */ -} _PACKED compat_xfs_bstat_t; - -STATIC int xfs_bulkstat_one_fmt_compat( +STATIC int +xfs_bulkstat_one_fmt_compat (void __user *ubuffer,const xfs_bstat_t *buffer) {
@@ -231,26 +149,10 @@ STATIC int xfs_bulkstat_one_fmt_compat(put_user (buffer->bs_dmevmask, &p32->bs_dmevmask) ||put_user (buffer->bs_dmstate, &p32->bs_dmstate) || put_user(buffer->bs_aextents, &p32->bs_aextents)) - return -EFAULT; + return -XFS_ERROR(EFAULT);return sizeof (*p32); } - - -typedef struct compat_xfs_fsop_bulkreq { -compat_uptr_t lastip;/* last inode # pointer */ -__s32 icount;/* count of entries in buffer */ -compat_uptr_t ubuffer;/* user buffer for inode desc. */ -compat_uptr_t ocount;/* output count pointer */ -}compat_xfs_fsop_bulkreq_t ; - -#define XFS_IOC_FSBULKSTAT_32 \ - _IOWR('X', 101, struct compat_xfs_fsop_bulkreq) -#define XFS_IOC_FSBULKSTAT_SINGLE_32 \ - _IOWR('X', 102, struct compat_xfs_fsop_bulkreq) -#define XFS_IOC_FSINUMBERS_32 \ - _IOWR('X', 103, struct compat_xfs_fsop_bulkreq) -/* copied from xfs_ioctl.c */ STATIC int xfs_ioc_bulkstat_compat(
@@ -270,20 +172,20 @@ xfs_ioc_bulkstat_compat(/* should be called again (unused here, but used in dmapi) */ if (!capable (CAP_SYS_ADMIN )) -return -EPERM ; +return -XFS_ERROR (EPERM );if (XFS_FORCED_SHUTDOWN (mp))return -XFS_ERROR (EIO );if (get_user (addr, &p32->lastip)) -return -EFAULT ; +return -XFS_ERROR (EFAULT ); bulkreq.lastip =compat_ptr (addr);if (get_user (bulkreq.icount, &p32->icount) ||get_user (addr, &p32->ubuffer)) -return -EFAULT ; +return -XFS_ERROR (EFAULT ); bulkreq.ubuffer =compat_ptr (addr);if (get_user (addr, &p32->ocount)) -return -EFAULT ; +return -XFS_ERROR (EFAULT ); bulkreq.ocount =compat_ptr (addr);if (copy_from_user (&inlast, bulkreq.lastip,sizeof (__s64)))
@@ -310,41 +212,16 @@ xfs_ioc_bulkstat_compat(return -error;if (bulkreq.ocount !=NULL ) { -if (copy_to_user (bulkreq.lastip, &inlast, -sizeof (xfs_ino_t))) -return -XFS_ERROR (EFAULT ); - -if (copy_to_user (bulkreq.ocount, &count,sizeof (count))) +if (copy_to_user (bulkreq.lastip, &inlast,sizeof (xfs_ino_t)) || +copy_to_user (bulkreq.ocount, &count,sizeof (count)))return -XFS_ERROR (EFAULT ); }return 0 ; } - - -typedef struct compat_xfs_fsop_handlereq { -__u32 fd;/* fd for FD_TO_HANDLE */ -compat_uptr_t path;/* user pathname */ -__u32 oflags;/* open flags */ -compat_uptr_t ihandle;/* user supplied handle */ -__u32 ihandlen;/* user supplied length */ -compat_uptr_t ohandle;/* user buffer for handle */ -compat_uptr_t ohandlen;/* user buffer length */ -}compat_xfs_fsop_handlereq_t ; - -#define XFS_IOC_PATH_TO_FSHANDLE_32 \ - _IOWR('X', 104, struct compat_xfs_fsop_handlereq) -#define XFS_IOC_PATH_TO_HANDLE_32 \ - _IOWR('X', 105, struct compat_xfs_fsop_handlereq) -#define XFS_IOC_FD_TO_HANDLE_32 \ - _IOWR('X', 106, struct compat_xfs_fsop_handlereq) -#define XFS_IOC_OPEN_BY_HANDLE_32 \ - _IOWR('X', 107, struct compat_xfs_fsop_handlereq) -#define XFS_IOC_READLINK_BY_HANDLE_32 \ - _IOWR('X', 108, struct compat_xfs_fsop_handlereq) - -STATIC unsigned long xfs_ioctl32_fshandle (unsigned long arg) +STATIC unsigned long +xfs_ioctl32_fshandle_copyin (unsigned long arg) {compat_xfs_fsop_handlereq_t __user *p32 = (void __user *)arg;xfs_fsop_handlereq_t __user *p =compat_alloc_user_space (sizeof (*p));
@@ -361,12 +238,11 @@ STATIC unsigned long xfs_ioctl32_fshandlput_user (compat_ptr (addr), &p->ohandle) ||get_user (addr, &p32->ohandlen) || put_user(compat_ptr(addr), &p->ohandlen)) - return -EFAULT; + return -XFS_ERROR(EFAULT);return (unsigned long )p; } - STATIC long xfs_compat_ioctl( int mode,
@@ -405,9 +281,9 @@ xfs_compat_ioctl(case XFS_IOC_ERROR_CLEARALL :break ; -case XFS_IOC32_GETXFLAGS : -case XFS_IOC32_SETXFLAGS : -case XFS_IOC32_GETVERSION : +case XFS_IOC_GETXFLAGS_32 : +case XFS_IOC_SETXFLAGS_32 : +case XFS_IOC_GETVERSION_32 : cmd =_NATIVE_IOC (cmd, long);break ;#ifdef BROKEN_X86_ALIGNMENT
@@ -420,11 +296,11 @@ xfs_compat_ioctl(case XFS_IOC_UNRESVSP_32 :case XFS_IOC_RESVSP64_32 :case XFS_IOC_UNRESVSP64_32 : - arg =xfs_ioctl32_flock (arg); + arg =xfs_ioctl32_flock_copyin (arg); cmd = _NATIVE_IOC(cmd, struct xfs_flock64);break ;case XFS_IOC_FSGEOMETRY_V1_32 : - arg =xfs_ioctl32_geom_v1 (arg); + arg =xfs_ioctl32_geom_v1_copyin (arg); cmd = _NATIVE_IOC(cmd, struct xfs_fsop_geom_v1);break ;
@@ -456,11 +332,11 @@ xfs_compat_ioctl(case XFS_IOC_PATH_TO_FSHANDLE_32 :case XFS_IOC_OPEN_BY_HANDLE_32 :case XFS_IOC_READLINK_BY_HANDLE_32 : - arg =xfs_ioctl32_fshandle (arg); + arg =xfs_ioctl32_fshandle_copyin (arg); cmd = _NATIVE_IOC(cmd, struct xfs_fsop_handlereq);break ;default : -return -ENOIOCTLCMD ; +return -XFS_ERROR (ENOIOCTLCMD ); } error =xfs_ioctl (XFS_I (inode), file, mode, cmd, (void __user *)arg);
fs/xfs/linux-2.6/xfs_ioctl32.h +140 -0
147 lines not on this page · raw message
fs/xfs/xfs_fs.h +3 -3
@@ -427,9 +427,9 @@ typedef struct xfs_handle {#define XFS_IOC_SETXFLAGS FS_IOC_SETFLAGS#define XFS_IOC_GETVERSION FS_IOC_GETVERSION/* 32-bit compat counterparts */ -#define XFS_IOC32_GETXFLAGS FS_IOC32_GETFLAGS -#define XFS_IOC32_SETXFLAGS FS_IOC32_SETFLAGS -#define XFS_IOC32_GETVERSION FS_IOC32_GETVERSION +#define XFS_IOC_GETXFLAGS_32 FS_IOC32_GETFLAGS +#define XFS_IOC_SETXFLAGS_32 FS_IOC32_SETFLAGS +#define XFS_IOC_GETVERSION_32 FS_IOC32_GETVERSION/* * ioctl commands that replace IRIX fcntl()'s
Signature · 4 lines
_______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [patch 01/11] Move compat ioctl structs & numbers into xfs_ioctl32.h
Quoted 8 lines · Christoph Hellwig
fs/xfs/linux-2.6/xfs_ioctl32.c line 54
Quoted 5 lines · On Tue, Nov 18, 2008 at 10:44:02PM -0600, [email protected] wrote:
fs/xfs/linux-2.6/xfs_ioctl32.c +2
-2+#ifdef BROKEN_X86_ALIGNMENT STATIC unsigned long -xfs_ioctl32_flock ( -unsigned long arg) +xfs_ioctl32_flock_copyin (unsigned long arg)Any reason this deflect from the standard xfs formatting?
eh, not really. I can change it back.
Quoted 8 lines
Also when you touch these helpers it would be a lot nice to already pass a void
__user* pointer to them with just a single case in the main handler alavoid__user * argp = (void __user *)arg;And then use that directly in the places where it works, e.g. copy_{from,to,in}_user.
ok, sounds good.
Quoted 4 lines
I must also say that I don't really like these
_copyinghelpers at all, just adding an explicit call to the underlying ioctl from them seems much clener than dispatching control back to the main routine with a changed argument and ioc number.
Ok, either way is fine by me, was just following what was there already.
Quoted 9 lines
fs/xfs/xfs_fs.h typedef struct xfs_handle { · line 432
Quoted 6 lines
fs/xfs/xfs_fs.h +3
-3-#define XFS_IOC32_GETXFLAGS FS_IOC32_GETFLAGS -#define XFS_IOC32_SETXFLAGS FS_IOC32_SETFLAGS -#define XFS_IOC32_GETVERSION FS_IOC32_GETVERSION +#define XFS_IOC_GETXFLAGS_32 FS_IOC32_GETFLAGS +#define XFS_IOC_SETXFLAGS_32 FS_IOC32_SETFLAGS +#define XFS_IOC_GETVERSION_32 FS_IOC32_GETVERSIONI think these should go into
xfs_ioctl32.h, too.
ah, good point.
-Eric
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [patch 01/11] Move compat ioctl structs & numbers into xfs_ioctl32.h
Quoted 6 lines · Eric Sandeen
Quoted 4 lines
I must also say that I don't really like these
_copyinghelpers at all, just adding an explicit call to the underlying ioctl from them seems much clener than dispatching control back to the main routine with a changed argument and ioc number.Ok, either way is fine by me, was just following what was there already.
So I went off to do it this way, and while I certainly can, (I'm almost done rewriting it this way) after a bit more thought I really don't see much wrong with just translating in the 32-bit args for any ioctl which is _IOW only... it doesn't seem that bad... any particular reason you're against it?
-Eric
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 2/11 Fix the compat XFS_IOC_FSGEOMETRY_V1 ioctl
In reply to [email protected]This ioctl copies kernel data to the user, so we must have a compat helper to copy it out to the 32-bit structure; the current code had it backward, and translated the 32-bit arg to 64-bit, and called the native ioctl, which copied it back as if it were talking to 64-bit userspace. Because the 64-bit arg has padding on the end on intel, I think this risked corruption in userspace..
--
fs/xfs/linux-2.6/xfs_ioctl32.c +16 -9
@@ -44,6 +44,7 @@#include "xfs_error.h" #include "xfs_dfrag.h" #include "xfs_vnodeops.h" +#include "xfs_fsops.h" #include "xfs_ioctl32.h" #define _NATIVE_IOC (cmd, type) \
@@ -68,15 +69,22 @@ xfs_ioctl32_flock_copyin(unsigned long areturn (unsigned long )p; } -STATIC unsigned long -xfs_ioctl32_geom_v1_copyin (unsigned long arg) +/* This handles a copy-out, where the 32-bit user struct lacks padding */ +STATIC int +xfs_ioc_fsgeometry_v1_compat ( +xfs_mount_t *mp, +void __user *arg) { -compat_xfs_fsop_geom_v1_t __user *p32 = (void __user *)arg; -xfs_fsop_geom_v1_t __user *p =compat_alloc_user_space (sizeof (*p)); +xfs_fsop_geom_v1_t fsgeo; +int error; -if (copy_in_user (p, p32,sizeof (*p32))) + error =xfs_fs_geometry (mp, (xfs_fsop_geom_t *)&fsgeo,3 ); +if (error) +return -error; + +if (copy_to_user (arg, &fsgeo,sizeof (struct compat_xfs_fsop_geom_v1 )))return -XFS_ERROR (EFAULT ); -return (unsigned long )p; +return 0 ; }STATIC int
@@ -300,9 +308,8 @@ xfs_compat_ioctl( cmd = _NATIVE_IOC(cmd, struct xfs_flock64);break ;case XFS_IOC_FSGEOMETRY_V1_32 : - arg =xfs_ioctl32_geom_v1_copyin (arg); - cmd = _NATIVE_IOC(cmd, struct xfs_fsop_geom_v1); -break ; +return xfs_ioc_fsgeometry_v1_compat (XFS_I (inode)->i_mount, + (void __user *)arg);#else /* These are handled fine if no alignment issues */ case XFS_IOC_ALLOCSP :
Signature · 4 lines
_______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 3/11 Add compat handlers for data & rt growfs ioctls
In reply to [email protected]The args for XFS_IOC_FSGROWFSDATA and XFS_IOC_FSGROWFSRTA have padding on the end on intel, so add arg copyin functions, and then just call the native ioctl.
--
fs/xfs/linux-2.6/xfs_ioctl32.c +30 -2
@@ -87,6 +87,28 @@ xfs_ioc_fsgeometry_v1_compat(return 0 ; } +STATIC unsigned long +xfs_ioctl32_growfs_data_copyin (unsigned long arg) +{ +compat_xfs_growfs_data_t __user *p32 = (void __user *)arg; +xfs_growfs_data_t __user *p =compat_alloc_user_space (sizeof (*p)); + +if (copy_in_user (p, p32,sizeof (*p32))) +return -XFS_ERROR (EFAULT ); +return (unsigned long )p; +} + +STATIC unsigned long +xfs_ioctl32_growfs_rt_copyin (unsigned long arg) +{ +compat_xfs_growfs_rt_t __user *p32 = (void __user *)arg; +xfs_growfs_rt_t __user *p =compat_alloc_user_space (sizeof (*p)); + +if (copy_in_user (p, p32,sizeof (*p32))) +return -XFS_ERROR (EFAULT ); +return (unsigned long )p; +} + STATIC int xfs_inumbers_fmt_compat( void __user *ubuffer,
@@ -310,7 +332,14 @@ xfs_compat_ioctl(case XFS_IOC_FSGEOMETRY_V1_32 :return xfs_ioc_fsgeometry_v1_compat (XFS_I (inode)->i_mount, (void __user *)arg); - +case XFS_IOC_FSGROWFSDATA_32 : + arg =xfs_ioctl32_growfs_data_copyin (arg); + cmd = _NATIVE_IOC(cmd, struct xfs_growfs_data); +break ; +case XFS_IOC_FSGROWFSRT_32 : + arg =xfs_ioctl32_growfs_rt_copyin (arg); + cmd = _NATIVE_IOC(cmd, struct xfs_growfs_rt); +break ;#else /* These are handled fine if no alignment issues */ case XFS_IOC_ALLOCSP :case XFS_IOC_FREESP :
@@ -322,7 +351,6 @@ xfs_compat_ioctl(case XFS_IOC_UNRESVSP64 :case XFS_IOC_FSGEOMETRY_V1 :break ; -/* xfs_bstat_t still has wrong u32 vs u64 alignment */ case XFS_IOC_SWAPEXT :break ;
fs/xfs/linux-2.6/xfs_ioctl32.h +14 -0
@@ -159,6 +159,20 @@ typedef struct compat_xfs_inogrp {__u64 xi_allocmask;/* mask of allocated inodes */ } __attribute__((packed)) compat_xfs_inogrp_t; +/* These growfs input structures have padding on the end, so must translate */ +typedef struct compat_xfs_growfs_data { +__u64 newblocks;/* new data subvol size, fsblocks */ +__u32 imaxpct;/* new inode space percentage limit */ +} __attribute__((packed))compat_xfs_growfs_data_t ; + +typedef struct compat_xfs_growfs_rt { +__u64 newblocks;/* new realtime size, fsblocks */ +__u32 extsize;/* new realtime extent size, fsblocks */ +} __attribute__((packed))compat_xfs_growfs_rt_t ; + +#define XFS_IOC_FSGROWFSDATA_32 _IOW ('X', 110, struct compat_xfs_growfs_data) +#define XFS_IOC_FSGROWFSRT_32 _IOW ('X', 112, struct compat_xfs_growfs_rt) +#endif /* BROKEN_X86_ALIGNMENT */ #endif /* __XFS_IOCTL32_H__ */
Signature · 4 lines
_______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 4/11 Add compat handlers for swapext ioctl
In reply to [email protected]The big hitter here was the bstat field, which contains different sized time_t on 32 vs. 64 bit. Add a copyin function to translate the 32-bit arg to 64-bit, and call the native ioctl.
--
fs/xfs/linux-2.6/xfs_ioctl32.c +63 -4
@@ -136,6 +136,65 @@ xfs_inumbers_fmt_compat(#endif +/* tv_sec differs on 64 vs. 32 */ +STATIC int +xfs_ioctl32_bstime_copyin ( +xfs_bstime_t __user *p, +compat_xfs_bstime_t __user *p32) +{ +compat_time_t sec32; +s32 nsec; + +if (get_user (sec32, &p32->tv_sec) || +put_user (sec32, &p->tv_sec) || +get_user (nsec, &p32->tv_nsec)|| +put_user (nsec, &p->tv_nsec)) +return -XFS_ERROR (EFAULT ); +return 0 ; +} + +/* xfs_bstat_t has differing alignment on intel, & bstime_t sizes everywhere */ +STATIC int +xfs_ioctl32_bstat_copyin ( +xfs_bstat_t __user *p, +compat_xfs_bstat_t __user *p32) +{ +if (copy_in_user (&p->bs_ino, &p32->bs_ino,sizeof (u64)) || +copy_in_user (&p->bs_mode, &p32->bs_mode,sizeof (u16)) || +copy_in_user (&p->bs_nlink, &p32->bs_nlink,sizeof (u16)) || +copy_in_user (&p->bs_uid, &p32->bs_uid,sizeof (u32)) || +copy_in_user (&p->bs_gid, &p32->bs_gid,sizeof (u32)) || +copy_in_user (&p->bs_rdev, &p32->bs_rdev,sizeof (u32)) || +copy_in_user (&p->bs_blksize, &p32->bs_blksize,sizeof (s32)) || +copy_in_user (&p->bs_size, &p32->bs_size,sizeof (s64)) || +xfs_ioctl32_bstime_copyin (&p->bs_atime, &p32->bs_atime) || +xfs_ioctl32_bstime_copyin (&p->bs_mtime, &p32->bs_mtime) || +xfs_ioctl32_bstime_copyin (&p->bs_ctime, &p32->bs_ctime) || +copy_in_user (&p->bs_blocks, &p32->bs_size,sizeof (s64)) || +copy_in_user (&p->bs_xflags, &p32->bs_size,sizeof (u32)) || +copy_in_user (&p->bs_extsize, &p32->bs_extsize,sizeof (s32)) || +copy_in_user (&p->bs_extents, &p32->bs_extents,sizeof (s32)) || +copy_in_user (&p->bs_gen, &p32->bs_gen,sizeof (u32)) || +copy_in_user (&p->bs_projid, &p32->bs_projid,sizeof (u16)) || +copy_in_user (&p->bs_dmevmask, &p32->bs_dmevmask,sizeof (u32)) || +copy_in_user (&p->bs_dmstate, &p32->bs_dmstate,sizeof (u16)) || +copy_in_user (&p->bs_aextents, &p32->bs_aextents,sizeof (u16))) +return -XFS_ERROR (EFAULT ); +return 0 ; +} + +STATIC unsigned long +xfs_ioctl32_swapext_copyin (unsigned long arg) +{ +compat_xfs_swapext_t __user *p32 = (void __user *)arg; +xfs_swapext_t __user *p =compat_alloc_user_space (sizeof (*p)); + +if (copy_in_user (p, p32, offsetof(xfs_swapext_t , sx_stat)) || +xfs_ioctl32_bstat_copyin (&p->sx_stat, &p32->sx_stat)) +return -XFS_ERROR (EFAULT ); +return (unsigned long )p; +} +/* XFS_IOC_FSBULKSTAT and friends */ STATIC int
@@ -351,11 +410,11 @@ xfs_compat_ioctl(case XFS_IOC_UNRESVSP64 :case XFS_IOC_FSGEOMETRY_V1 :break ; -/* xfs_bstat_t still has wrong u32 vs u64 alignment */ -case XFS_IOC_SWAPEXT : -break ; -#endif +case XFS_IOC_SWAPEXT_32 : + arg =xfs_ioctl32_swapext_copyin (arg); + cmd = _NATIVE_IOC(cmd, struct xfs_swapext); +break ;case XFS_IOC_FSBULKSTAT_32 :case XFS_IOC_FSBULKSTAT_SINGLE_32 :case XFS_IOC_FSINUMBERS_32 :
fs/xfs/linux-2.6/xfs_ioctl32.h +14 -0
@@ -105,6 +105,20 @@ typedef struct compat_xfs_fsop_handlereq#define XFS_IOC_READLINK_BY_HANDLE_32 \ _IOWR('X', 108, struct compat_xfs_fsop_handlereq) +/* The bstat field in the swapext struct needs translation */ +typedef struct compat_xfs_swapext +{ +__int64_t sx_version;/* version */ +__int64_t sx_fdtarget;/* fd of target file */ +__int64_t sx_fdtmp;/* fd of tmp file */ +xfs_off_t sx_offset;/* offset into file */ +xfs_off_t sx_length;/* leng from offset */ +char sx_pad[16 ];/* pad space, unused */ +compat_xfs_bstat_t sx_stat;/* stat of target b4 copy */ +} _PACKED compat_xfs_swapext_t; + +#define XFS_IOC_SWAPEXT_32 _IOWR('X', 109, struct compat_xfs_swapext) + #ifdef BROKEN_X86_ALIGNMENT /* on ia32 l_start is on a 32-bit boundary */ typedef struct compat_xfs_flock64 {
Signature · 4 lines
_______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 5/11 Make the bulkstat_one compat ioctl handling more sane
In reply to [email protected]Currently the compat formatter was handled by passing in "private_data" for the xfs_bulkstat_one formatter, which was really just another formatter... IMHO this got confusing.
Instead, just make a new xfs_bulkstat_one_compat formatter for xfs_bulkstat, and call it via a wrapper.
Also, don't translate the ioctl nrs into their native counterparts, that just clouds the issue; we're in a compat handler anyway, just switch on the 32-bit cmds.
--
fs/xfs/linux-2.6/xfs_ioctl32.c +19 -5
@@ -242,6 +242,23 @@ xfs_bulkstat_one_fmt_compat(return sizeof (*p32); } +STATIC int +xfs_bulkstat_one_compat ( +xfs_mount_t *mp,/* mount point for filesystem */ +xfs_ino_t ino,/* inode number to get data for */ +void __user *buffer,/* buffer to place output in */ +int ubsize,/* size of buffer */ +void *private_data,/* my private data */ +xfs_daddr_t bno,/* starting bno of inode cluster */ +int *ubused,/* bytes used by me */ +void *dibuff,/* on-disk inode buffer */ +int *stat)/* BULKSTAT_RV_... */ +{ +return xfs_bulkstat_one_int (mp, ino, buffer, ubsize, + xfs_bulkstat_one_fmt_compat, bno, + ubused, dibuff, stat); +} +/* copied from xfs_ioctl.c */ STATIC int xfs_ioc_bulkstat_compat(
@@ -286,14 +303,12 @@ xfs_ioc_bulkstat_compat(if (bulkreq.ubuffer ==NULL )return -XFS_ERROR (EINVAL ); -if (cmd ==XFS_IOC_FSINUMBERS ) +if (cmd ==XFS_IOC_FSINUMBERS_32 ) error =xfs_inumbers (mp, &inlast, &count, bulkreq.ubuffer, xfs_inumbers_fmt_compat);else { -/* declare a var to get a warning in case the type changes */ -bulkstat_one_fmt_pf formatter = xfs_bulkstat_one_fmt_compat; error =xfs_bulkstat (mp, &inlast, &count, - xfs_bulkstat_one, formatter, + xfs_bulkstat_one_compat,NULL ,sizeof (compat_xfs_bstat_t), bulkreq.ubuffer,BULKSTAT_FG_QUICK , &done); }
@@ -418,7 +433,6 @@ xfs_compat_ioctl(case XFS_IOC_FSBULKSTAT_32 :case XFS_IOC_FSBULKSTAT_SINGLE_32 :case XFS_IOC_FSINUMBERS_32 : - cmd = _NATIVE_IOC(cmd, struct xfs_fsop_bulkreq);return xfs_ioc_bulkstat_compat (XFS_I (inode)->i_mount, cmd, (void __user *)arg);case XFS_IOC_FD_TO_HANDLE_32 :
fs/xfs/xfs_itable.c +20 -4
@@ -206,13 +206,13 @@ xfs_bulkstat_one_fmt(* Return stat information for one inode. * Return 0 if ok, else errno. */ -int /* error status */ -xfs_bulkstat_one( +int /* error status */ +xfs_bulkstat_one_int( xfs_mount_t *mp, /* mount point for filesystem */ xfs_ino_t ino, /* inode number to get data for */ void __user *buffer, /* buffer to place output in */ int ubsize, /* size of buffer */ - void *private_data, /* my private data */ + bulkstat_one_fmt_pf formatter, /* formatter, copy to user */ xfs_daddr_t bno, /* starting bno of inode cluster */ int *ubused, /* bytes used by me */ void *dibuff, /* on-disk inode buffer */
@@ -221,7 +221,6 @@ xfs_bulkstat_one(xfs_bstat_t *buf;/* return buffer */ int error =0 ;/* error value */ xfs_dinode_t *dip;/* dinode inode pointer */ -bulkstat_one_fmt_pf formatter = private_data ? : xfs_bulkstat_one_fmt; dip = (xfs_dinode_t *)dibuff; *stat =BULKSTAT_RV_NOTHING ;
@@ -259,6 +258,23 @@ xfs_bulkstat_one(return error; } +int +xfs_bulkstat_one ( +xfs_mount_t *mp,/* mount point for filesystem */ +xfs_ino_t ino,/* inode number to get data for */ +void __user *buffer,/* buffer to place output in */ +int ubsize,/* size of buffer */ +void *private_data,/* my private data */ +xfs_daddr_t bno,/* starting bno of inode cluster */ +int *ubused,/* bytes used by me */ +void *dibuff,/* on-disk inode buffer */ +int *stat)/* BULKSTAT_RV_... */ +{ +return xfs_bulkstat_one_int (mp, ino, buffer, ubsize, + xfs_bulkstat_one_fmt, bno, + ubused, dibuff, stat); +} +/* * Test to see whether we can use the ondisk inode directly, based * on the given bulkstat flags, filling in dipp accordingly.
fs/xfs/xfs_itable.h +12 -0
@@ -74,6 +74,18 @@ typedef int (*bulkstat_one_fmt_pf)( /* const xfs_bstat_t *buffer); /* buffer to read from */int +xfs_bulkstat_one_int ( +xfs_mount_t *mp, +xfs_ino_t ino, +void __user *buffer, +int ubsize, +bulkstat_one_fmt_pf formatter, +xfs_daddr_t bno, +int *ubused, +void *dibuff, +int *stat); + +int xfs_bulkstat_one( xfs_mount_t *mp, xfs_ino_t ino,
Signature · 4 lines
_______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 6/11 Fix xfs_bulkstat_one size checks & error handling
In reply to [email protected]The 32-bit xfs_blkstat_one handler was failing because a size check checked whether the remaining (32-bit) user buffer was less than the (64-bit) bulkstat buffer, and failed with ENOMEM if so. Move this check into the respective handlers so that they check the correct sizes.
Also, the formatters were returning negative errors or positive bytes copied; this was odd in the positive error value world of xfs, and handled wrong by at least some of the callers, which treated the bytes returned as an error value. Move the bytes-used assignment into the formatters.
--
fs/xfs/linux-2.6/xfs_ioctl32.c +9 -2
@@ -211,13 +211,18 @@ xfs_bstime_store_compat(return 0 ; } +/* Return 0 on success or positive error (to xfs_bulkstat()) */ STATIC intxfs_bulkstat_one_fmt_compat (void __user *ubuffer, +int ubsize, +int *ubused,const xfs_bstat_t *buffer) {compat_xfs_bstat_t __user *p32 = ubuffer; +if (ubsize <sizeof (*p32)) +return XFS_ERROR (ENOMEM ); if (put_user(buffer->bs_ino, &p32->bs_ino) || put_user(buffer->bs_mode, &p32->bs_mode) || put_user(buffer->bs_nlink, &p32->bs_nlink) ||
@@ -238,8 +243,10 @@ xfs_bulkstat_one_fmt_compat( put_user(buffer->bs_dmevmask, &p32->bs_dmevmask) || put_user(buffer->bs_dmstate, &p32->bs_dmstate) || put_user(buffer->bs_aextents, &p32->bs_aextents)) - return -XFS_ERROR(EFAULT); -return sizeof (*p32); +return XFS_ERROR (EFAULT ); +if (ubused) + *ubused =sizeof (*p32); +return 0 ; }STATIC int
fs/xfs/xfs_itable.c +11 -10
@@ -192,14 +192,21 @@ xfs_bulkstat_one_dinode( } } +/* Return 0 on success or positive error */ STATIC intxfs_bulkstat_one_fmt (void __user *ubuffer, +int ubsize, +int *ubused,const xfs_bstat_t *buffer) { +if (ubsize <sizeof (*buffer)) +return XFS_ERROR (ENOMEM );if (copy_to_user (ubuffer, buffer,sizeof (*buffer))) -return -EFAULT ; -return sizeof (*buffer); +return XFS_ERROR (EFAULT ); +if (ubused) + *ubused =sizeof (*buffer); +return 0 ; }/*
@@ -227,8 +234,6 @@ xfs_bulkstat_one_int(if (!buffer ||xfs_internal_inum (mp, ino))return XFS_ERROR (EINVAL ); -if (ubsize <sizeof (*buf)) -return XFS_ERROR (ENOMEM ); buf =kmem_alloc (sizeof (*buf),KM_SLEEP );
@@ -243,15 +248,11 @@ xfs_bulkstat_one_int(xfs_bulkstat_one_dinode (mp, ino, dip, buf); } - error =formatter (buffer, buf); -if (error <0 ) { - error =EFAULT ; + error =formatter (buffer, ubsize, ubused, buf); +if (error) goto out_free; - } *stat =BULKSTAT_RV_DIDONE ; -if (ubused) - *ubused = error; out_free:kmem_free (buf);
fs/xfs/xfs_itable.h +2 -0
@@ -71,6 +71,8 @@ xfs_bulkstat_single(typedef int (*bulkstat_one_fmt_pf )(/* used size in bytes or negative error */ void __user *ubuffer,/* buffer to write to */ +int ubsize,/* remaining user buffer sz */ +int *ubused,/* bytes used by formatter */ const xfs_bstat_t *buffer);/* buffer to read from */ int
Signature · 4 lines
_______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 7/11 Fix compat XFS_IOC_FSBULKSTAT_SINGLE ioctl
In reply to [email protected]The XFS_IOC_FSBULKSTAT_SINGLE ioctl passes in the desired inode number, while XFS_IOC_FSBULKSTAT passes in the previous/last-stat'd inode number. The compat handler wasn't differentiating these, so when a XFS_IOC_FSBULKSTAT_SINGLE request for inode 128 was sent in, stat information for 131 was sent out.
--
fs/xfs/linux-2.6/xfs_ioctl32.c +10 -4
@@ -279,7 +279,7 @@ xfs_ioc_bulkstat_compat(int count;/* # of records returned */ xfs_ino_t inlast;/* last inode number */ int done; -int error; +int error =EINVAL ;/* done = 1 if there are more stats to get and if bulkstat */ /* should be called again (unused here, but used in dmapi) */
@@ -310,17 +310,23 @@ xfs_ioc_bulkstat_compat(if (bulkreq.ubuffer ==NULL )return -XFS_ERROR (EINVAL ); -if (cmd ==XFS_IOC_FSINUMBERS_32 ) +if (cmd ==XFS_IOC_FSINUMBERS_32 ) { error =xfs_inumbers (mp, &inlast, &count, bulkreq.ubuffer, xfs_inumbers_fmt_compat); -else { + }else if (cmd ==XFS_IOC_FSBULKSTAT_SINGLE_32 ) { +int res; + + error =xfs_bulkstat_one_compat (mp, inlast, bulkreq.ubuffer, +sizeof (compat_xfs_bstat_t), +NULL ,0 ,NULL ,NULL , &res); + }else if (cmd ==XFS_IOC_FSBULKSTAT_32 ) { error =xfs_bulkstat (mp, &inlast, &count, xfs_bulkstat_one_compat,NULL ,sizeof (compat_xfs_bstat_t), bulkreq.ubuffer,BULKSTAT_FG_QUICK , &done); }if (error) -return -error; +return -XFS_ERROR (error);if (bulkreq.ocount !=NULL ) { if (copy_to_user(bulkreq.lastip, &inlast, sizeof(xfs_ino_t)) ||
Signature · 4 lines
_______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 8/11 Hook up compat XFS_IOC_ATTRLIST_BY_HANDLE ioctl handler
In reply to [email protected]Add a compat handler for XFS_IOC_ATTRLIST_BY_HANDLE
--
fs/xfs/linux-2.6/xfs_ioctl32.h +12 -0
@@ -119,6 +119,18 @@ typedef struct compat_xfs_swapext#define XFS_IOC_SWAPEXT_32 _IOWR('X', 109, struct compat_xfs_swapext) +typedef struct compat_xfs_fsop_attrlist_handlereq { +struct compat_xfs_fsop_handlereq hreq;/* handle interface structure */ +struct xfs_attrlist_cursor pos;/* opaque cookie, list offset */ +__u32 flags;/* which namespace to use */ +__u32 buflen;/* length of buffer supplied */ +compat_uptr_t buffer;/* returned names */ +} _PACKED compat_xfs_fsop_attrlist_handlereq_t; + +/* Note: actually this is read/write */ +#define XFS_IOC_ATTRLIST_BY_HANDLE_32 \ + _IOW ('X', 122, struct compat_xfs_fsop_attrlist_handlereq) + #ifdef BROKEN_X86_ALIGNMENT /* on ia32 l_start is on a 32-bit boundary */ typedef struct compat_xfs_flock64 {
fs/xfs/linux-2.6/xfs_ioctl32.c +135 -1
160 lines not on this page · raw message
Signature · 4 lines
_______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 9/11 Hook up compat XFS_IOC_ATTRMULTI_BY_HANDLE ioctl handler
In reply to [email protected]Add a compat handler for XFS_IOC_ATTRMULTI_BY_HANDLE
--
fs/xfs/linux-2.6/xfs_ioctl32.c +95 -4
@@ -493,6 +493,98 @@ xfs_attrlist_by_handle_compat(return -error; } +extern int +xfs_attrmulti_attr_get (struct inode *,char *,char __user *, +__uint32_t *,__uint32_t ); +extern int +xfs_attrmulti_attr_set (struct inode *,char *,const char __user *, +__uint32_t ,__uint32_t ); +extern int +xfs_attrmulti_attr_remove (struct inode *,char *,__uint32_t ); + +STATIC int +xfs_attrmulti_by_handle_compat ( +void __user *arg, +struct inode *parinode) +{ +int error; +compat_xfs_attr_multiop_t *ops; +compat_xfs_fsop_attrmulti_handlereq_t am_hreq; +struct inode *inode; +unsigned int i, size; +char *attr_name; +xfs_mount_t *mp =XFS_I (parinode)->i_mount; + +if (!capable (CAP_SYS_ADMIN )) +return -XFS_ERROR (EPERM ); +if (copy_from_user (&am_hreq, arg,sizeof (compat_xfs_fsop_attrmulti_handlereq_t))) +return -XFS_ERROR (EFAULT ); + + error =xfs_vget_fsop_handlereq_compat (mp, parinode, &am_hreq.hreq, &inode); +if (error) + goto out; + + error =E2BIG ; + size = am_hreq.opcount *sizeof (compat_xfs_attr_multiop_t); +if (!size || size >16 *PAGE_SIZE ) + goto out_vn_rele; + + error =ENOMEM ; + ops =kmalloc (size,GFP_KERNEL ); +if (!ops) + goto out_vn_rele; + + error =EFAULT ; +if (copy_from_user (ops,compat_ptr (am_hreq.ops), size)) + goto out_kfree_ops; + + attr_name =kmalloc (MAXNAMELEN ,GFP_KERNEL ); +if (!attr_name) + goto out_kfree_ops; + + + error =0 ; +for (i =0 ; i < am_hreq.opcount; i++) { + ops[i].am_error =strncpy_from_user (attr_name, +compat_ptr (ops[i].am_attrname), +MAXNAMELEN ); +if (ops[i].am_error ==0 || ops[i].am_error ==MAXNAMELEN ) + error = -ERANGE ; +if (ops[i].am_error <0 ) +break ; + +switch (ops[i].am_opcode) { +case ATTR_OP_GET : + ops[i].am_error =xfs_attrmulti_attr_get (inode, + attr_name,compat_ptr (ops[i].am_attrvalue), + &ops[i].am_length, ops[i].am_flags); +break ; +case ATTR_OP_SET : + ops[i].am_error =xfs_attrmulti_attr_set (inode, + attr_name,compat_ptr (ops[i].am_attrvalue), + ops[i].am_length, ops[i].am_flags); +break ; +case ATTR_OP_REMOVE : + ops[i].am_error =xfs_attrmulti_attr_remove (inode, + attr_name, ops[i].am_flags); +break ; +default : + ops[i].am_error =EINVAL ; + } + } + +if (copy_to_user (compat_ptr (am_hreq.ops), ops, size)) + error =XFS_ERROR (EFAULT ); + +kfree (attr_name); + out_kfree_ops: +kfree (ops); + out_vn_rele: +iput (inode); + out: +return -error; +} + STATIC long xfs_compat_ioctl( int mode,
@@ -513,10 +605,7 @@ xfs_compat_ioctl(case XFS_IOC_GETBMAP :case XFS_IOC_GETBMAPA :case XFS_IOC_GETBMAPX : -/* not handled -case XFS_IOC_FSSETDM_BY_HANDLE: -case XFS_IOC_ATTRMULTI_BY_HANDLE: -*/ +/* case XFS_IOC_FSSETDM_BY_HANDLE: not handled */ case XFS_IOC_FSCOUNTS :case XFS_IOC_SET_RESBLKS :case XFS_IOC_GET_RESBLKS :
@@ -590,6 +679,8 @@ xfs_compat_ioctl(break ;case XFS_IOC_ATTRLIST_BY_HANDLE_32 :return xfs_attrlist_by_handle_compat ((void __user *)arg, inode); +case XFS_IOC_ATTRMULTI_BY_HANDLE_32 : +return xfs_attrmulti_by_handle_compat ((void __user *)arg, inode);default :return -XFS_ERROR (ENOIOCTLCMD ); }
fs/xfs/linux-2.6/xfs_ioctl32.h +20 -0
@@ -131,6 +131,26 @@ typedef struct compat_xfs_fsop_attrlist_#define XFS_IOC_ATTRLIST_BY_HANDLE_32 \ _IOW ('X', 122, struct compat_xfs_fsop_attrlist_handlereq) +/* am_opcodes defined in xfs_fs.h */ +typedef struct compat_xfs_attr_multiop { +__u32 am_opcode; +__s32 am_error; +compat_uptr_t am_attrname; +compat_uptr_t am_attrvalue; +__u32 am_length; +__u32 am_flags; +}compat_xfs_attr_multiop_t ; + +typedef struct compat_xfs_fsop_attrmulti_handlereq { +struct compat_xfs_fsop_handlereq hreq;/* handle interface structure */ +__u32 opcount;/* count of following multiop */ +/* ptr to compat_xfs_attr_multiop */ +compat_uptr_t ops;/* attr_multi data */ +}compat_xfs_fsop_attrmulti_handlereq_t ; + +#define XFS_IOC_ATTRMULTI_BY_HANDLE_32 \ + _IOW ('X', 123, struct compat_xfs_fsop_attrmulti_handlereq) + #ifdef BROKEN_X86_ALIGNMENT /* on ia32 l_start is on a 32-bit boundary */ typedef struct compat_xfs_flock64 {
fs/xfs/linux-2.6/xfs_ioctl.c +3 -3
@@ -501,7 +501,7 @@ xfs_attrlist_by_handle(return -error; } -STATIC int +int xfs_attrmulti_attr_get( struct inode *inode, char *name,
@@ -530,7 +530,7 @@ xfs_attrmulti_attr_get(return error; } -STATIC int +int xfs_attrmulti_attr_set( struct inode *inode, char *name,
@@ -560,7 +560,7 @@ xfs_attrmulti_attr_set(return error; } -STATIC int +int xfs_attrmulti_attr_remove( struct inode *inode, char *name,
Signature · 4 lines
_______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [patch 09/11] Hook up compat XFS_IOC_ATTRMULTI_BY_HANDLE ioctl handler
Quoted 11 lines · Christoph Hellwig
fs/xfs/linux-2.6/xfs_ioctl32.c xfs_attrlist_by_handle_compat( · line 503
Quoted 8 lines · On Tue, Nov 18, 2008 at 10:44:10PM -0600, [email protected] wrote:
fs/xfs/linux-2.6/xfs_ioctl32.c +8
-0+extern int +xfs_attrmulti_attr_get (struct inode *,char *,char __user *, +__uint32_t *,__uint32_t ); +extern int +xfs_attrmulti_attr_set (struct inode *,char *,const char __user *, +__uint32_t ,__uint32_t ); +extern int +xfs_attrmulti_attr_remove (struct inode *,char *,__uint32_t );These should be in a header.
ah good point.
Quoted 9 lines
fs/xfs/linux-2.6/xfs_ioctl32.c xfs_attrlist_by_handle_compat( · line 523
Quoted 4 lines
fs/xfs/linux-2.6/xfs_ioctl32.c +4
-0+if (copy_from_user (&am_hreq, arg,sizeof (compat_xfs_fsop_attrmulti_handlereq_t))) +return -XFS_ERROR (EFAULT ); + + error =xfs_vget_fsop_handlereq_compat (mp, parinode, &am_hreq.hreq, &inode);Far too long lines, please break them up after 80 chars.
Looks good even if the duplication is rather sad..
yeah, I don't like it. We could refactor stuff, but I'm also just trying to get to something that works right now... :)
-Eric
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH 10/11 Hook up compat XFS_IOC_FSSETDM_BY_HANDLE ioctl handler
In reply to [email protected]Add a compat handler for XFS_IOC_FSSETDM_BY_HANDLE.
I haven't tested this, lacking dmapi tools to do so (unless xfsqa magically gets this somehow?)
--
fs/xfs/linux-2.6/xfs_ioctl32.c +40 -1
@@ -585,6 +585,44 @@ xfs_attrmulti_by_handle_compat(return -error; } +STATIC int +compat_xfs_fssetdm_by_handle ( +void __user *arg, +struct inode *parinode) +{ +int error; +struct fsdmidata fsd; +compat_xfs_fsop_setdm_handlereq_t dmhreq; +struct inode *inode; +xfs_mount_t *mp =XFS_I (parinode)->i_mount; + +if (!capable (CAP_MKNOD )) +return -XFS_ERROR (EPERM ); +if (copy_from_user (&dmhreq, arg,sizeof (compat_xfs_fsop_setdm_handlereq_t))) +return -XFS_ERROR (EFAULT ); + + error =xfs_vget_fsop_handlereq_compat (mp, parinode, &dmhreq.hreq, &inode); +if (error) +return -error; + +if (IS_IMMUTABLE (inode) ||IS_APPEND (inode)) { + error = -XFS_ERROR (EPERM ); + goto out; + } + +if (copy_from_user (&fsd,compat_ptr (dmhreq.data),sizeof (fsd))) { + error = -XFS_ERROR (EFAULT ); + goto out; + } + + error = -xfs_set_dmattrs (XFS_I (inode), fsd.fsd_dmevmask, + fsd.fsd_dmstate); + +out: +iput (inode); +return error; +} + STATIC long xfs_compat_ioctl( int mode,
@@ -605,7 +643,6 @@ xfs_compat_ioctl(case XFS_IOC_GETBMAP :case XFS_IOC_GETBMAPA :case XFS_IOC_GETBMAPX : -/* case XFS_IOC_FSSETDM_BY_HANDLE: not handled */ case XFS_IOC_FSCOUNTS :case XFS_IOC_SET_RESBLKS :case XFS_IOC_GET_RESBLKS :
@@ -681,6 +718,8 @@ xfs_compat_ioctl(return xfs_attrlist_by_handle_compat ((void __user *)arg, inode);case XFS_IOC_ATTRMULTI_BY_HANDLE_32 :return xfs_attrmulti_by_handle_compat ((void __user *)arg, inode); +case XFS_IOC_FSSETDM_BY_HANDLE_32 : +return compat_xfs_fssetdm_by_handle ((void __user *)arg, inode);default :return -XFS_ERROR (ENOIOCTLCMD ); }
fs/xfs/linux-2.6/xfs_ioctl32.h +9 -0
@@ -151,6 +151,15 @@ typedef struct compat_xfs_fsop_attrmulti#define XFS_IOC_ATTRMULTI_BY_HANDLE_32 \ _IOW ('X', 123, struct compat_xfs_fsop_attrmulti_handlereq) +typedef struct compat_xfs_fsop_setdm_handlereq { +struct compat_xfs_fsop_handlereq hreq;/* handle information */ +/* ptr to struct fsdmidata */ +compat_uptr_t data;/* DMAPI data */ +}compat_xfs_fsop_setdm_handlereq_t ; + +#define XFS_IOC_FSSETDM_BY_HANDLE_32 \ + _IOW ('X', 121, struct compat_xfs_fsop_setdm_handlereq) + #ifdef BROKEN_X86_ALIGNMENT /* on ia32 l_start is on a 32-bit boundary */ typedef struct compat_xfs_flock64 {
Signature · 4 lines
_______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH 11/11 Reorder xfs_ioctl32.c for some tidiness
In reply to [email protected]Put things in IMHO a more readable order, now
that it's all done; add some comments.
--
fs/xfs/linux-2.6/xfs_ioctl32.c +26 -26
@@ -634,6 +634,7 @@ xfs_compat_ioctl(int error;switch (cmd) { +/* No size or alignment issues with any of these on any arch */ case XFS_IOC_DIOINFO :case XFS_IOC_FSGEOMETRY :case XFS_IOC_FSGETXATTR :
@@ -655,14 +656,18 @@ xfs_compat_ioctl(case XFS_IOC_ERROR_INJECTION :case XFS_IOC_ERROR_CLEARALL :break ; - -case XFS_IOC_GETXFLAGS_32 : -case XFS_IOC_SETXFLAGS_32 : -case XFS_IOC_GETVERSION_32 : - cmd =_NATIVE_IOC (cmd, long); +#ifndef BROKEN_X86_ALIGNMENT /* handled fine if no alignment issues */ +case XFS_IOC_ALLOCSP : +case XFS_IOC_FREESP : +case XFS_IOC_RESVSP : +case XFS_IOC_UNRESVSP : +case XFS_IOC_ALLOCSP64 : +case XFS_IOC_FREESP64 : +case XFS_IOC_RESVSP64 : +case XFS_IOC_UNRESVSP64 : +case XFS_IOC_FSGEOMETRY_V1 :break ; -#ifdef BROKEN_X86_ALIGNMENT -/* xfs_flock_t has wrong u32 vs u64 alignment */ +#else /* BROKEN_X86_ALIGNMENT */ case XFS_IOC_ALLOCSP_32 :case XFS_IOC_FREESP_32 :case XFS_IOC_ALLOCSP64_32 :
@@ -674,9 +679,6 @@ xfs_compat_ioctl( arg =xfs_ioctl32_flock_copyin (arg); cmd = _NATIVE_IOC(cmd, struct xfs_flock64);break ; -case XFS_IOC_FSGEOMETRY_V1_32 : -return xfs_ioc_fsgeometry_v1_compat (XFS_I (inode)->i_mount, - (void __user *)arg);case XFS_IOC_FSGROWFSDATA_32 : arg =xfs_ioctl32_growfs_data_copyin (arg); cmd = _NATIVE_IOC(cmd, struct xfs_growfs_data);
@@ -684,28 +686,21 @@ xfs_compat_ioctl(case XFS_IOC_FSGROWFSRT_32 : arg =xfs_ioctl32_growfs_rt_copyin (arg); cmd = _NATIVE_IOC(cmd, struct xfs_growfs_rt); +case XFS_IOC_FSGEOMETRY_V1_32 : +return xfs_ioc_fsgeometry_v1_compat (XFS_I (inode)->i_mount, + (void __user *)arg);break ; -#else /* These are handled fine if no alignment issues */ -case XFS_IOC_ALLOCSP : -case XFS_IOC_FREESP : -case XFS_IOC_RESVSP : -case XFS_IOC_UNRESVSP : -case XFS_IOC_ALLOCSP64 : -case XFS_IOC_FREESP64 : -case XFS_IOC_RESVSP64 : -case XFS_IOC_UNRESVSP64 : -case XFS_IOC_FSGEOMETRY_V1 : -break ;#endif +/* long varies in size, but xfs only ever copies out 32 bits */ +case XFS_IOC_GETXFLAGS_32 : +case XFS_IOC_SETXFLAGS_32 : +case XFS_IOC_GETVERSION_32 : + cmd =_NATIVE_IOC (cmd, long); +break ;case XFS_IOC_SWAPEXT_32 : arg =xfs_ioctl32_swapext_copyin (arg); cmd = _NATIVE_IOC(cmd, struct xfs_swapext);break ; -case XFS_IOC_FSBULKSTAT_32 : -case XFS_IOC_FSBULKSTAT_SINGLE_32 : -case XFS_IOC_FSINUMBERS_32 : -return xfs_ioc_bulkstat_compat (XFS_I (inode)->i_mount, - cmd, (void __user *)arg);case XFS_IOC_FD_TO_HANDLE_32 :case XFS_IOC_PATH_TO_HANDLE_32 :case XFS_IOC_PATH_TO_FSHANDLE_32 :
@@ -714,6 +709,11 @@ xfs_compat_ioctl( arg =xfs_ioctl32_fshandle_copyin (arg); cmd = _NATIVE_IOC(cmd, struct xfs_fsop_handlereq);break ; +case XFS_IOC_FSBULKSTAT_32 : +case XFS_IOC_FSBULKSTAT_SINGLE_32 : +case XFS_IOC_FSINUMBERS_32 : +return xfs_ioc_bulkstat_compat (XFS_I (inode)->i_mount, + cmd, (void __user *)arg);case XFS_IOC_ATTRLIST_BY_HANDLE_32 :return xfs_attrlist_by_handle_compat ((void __user *)arg, inode);case XFS_IOC_ATTRMULTI_BY_HANDLE_32 :
Signature · 4 lines
_______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs