ion_test: Add compat_ioctl support
PATCH 1/1 ion_test: Add compat_ioctl support
Prior to subitting this, Colin reworked the compat_ioctl support for the ion_test driver, moving the structure to be the same size on both 32 and 64 bit architectures.
Two small things were left out. The compat_ioctl ptr assignment, and the fact that despite having uniform sized types in the structure, the structure pads out to different sizes on different arches.
This patch resolves this issue by setting the write flag as a __u64, and adding the compat_ioctl ptr.
While this does affect the ABI for 32bit users, its only the ABI for the ion_test driver, not ion itself.
--- drivers/staging/android/ion/ion_test.c | 1 + drivers/staging/android/uapi/ion_test.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/staging/android/ion/ion_test.c +1 -0
@@ -231,6 +231,7 @@ static int ion_test_release(struct inode *inode, struct file *file)static const struct file_operations ion_test_fops = { .owner =THIS_MODULE , .unlocked_ioctl = ion_test_ioctl, + .compat_ioctl = ion_test_ioctl, .open = ion_test_open, .release = ion_test_release, };
drivers/staging/android/uapi/ion_test.h +1 -1
@@ -31,7 +31,7 @@ struct ion_test_rw_data {__u64 ptr;__u64 offset;__u64 size; -int write; +__u64 write; };#define ION_IOC_MAGIC 'I'
Signature · 1 line
1.8.3.2
Quoted 29 lines · John Stultz
Prior to subitting this, Colin reworked the
compat_ioctlsupport for theion_testdriver, moving the structure to be the same size on both 32 and 64 bit architectures.Two small things were left out. The
compat_ioctlptr assignment, and the fact that despite having uniform sized types in the structure, the structure pads out to different sizes on different arches.This patch resolves this issue by setting the write flag as a
__u64, and adding thecompat_ioctlptr.While this does affect the ABI for 32bit users, its only the ABI for the
ion_testdriver, not ion itself.Cc Colin Cross <[email protected]>Cc Greg KH <[email protected]>Cc Android Kernel Team <[email protected]>Signed-off-by John Stultz <[email protected]>--- drivers/staging/android/ion/ion_test.c | 1 + drivers/staging/android/uapi/ion_test.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)drivers/staging/android/ion/ion_test.c +0
-0
drivers/staging/android/ion/ion_test.c static int ion_test_release(struct inode *inode, struct file *file) · line 234
Quoted 4 lines
drivers/staging/android/ion/ion_test.c +1
-0@@ -231,6 +231,7 @@ static int ion_test_release(struct inode *inode, struct file *file)static const struct file_operations ion_test_fops = { .owner =THIS_MODULE , .unlocked_ioctl = ion_test_ioctl, + .compat_ioctl = ion_test_ioctl,
Setting the compat_ioctl to the same thing as unlocked_ioctl shouldn't be necessary, compat_sys_ioctl will fall through to do_vfs_ioctl if compat_ioctl is not set, which will call unlocked_ioctl.
Quoted 8 lines
drivers/staging/android/ion/ion_test.c +0
-0.open = ion_test_open, .release = ion_test_release, };drivers/staging/android/uapi/ion_test.h +0
-0
drivers/staging/android/uapi/ion_test.h struct ion_test_rw_data { · line 35
Quoted 6 lines
drivers/staging/android/uapi/ion_test.h +1
-1@@ -31,7 +31,7 @@ struct ion_test_rw_data {__u64 ptr;__u64 offset;__u64 size; -int write; +__u64 write; };
Whoops, missed that one. Can you add "int padding" after "int write" instead? That at least lets us use the 32 bits later.
Quoted 25 lines · Colin Cross
Quoted 24 lines · John Stultz
Prior to subitting this, Colin reworked the
compat_ioctlsupport for theion_testdriver, moving the structure to be the same size on both 32 and 64 bit architectures.Two small things were left out. The
compat_ioctlptr assignment, and the fact that despite having uniform sized types in the structure, the structure pads out to different sizes on different arches.This patch resolves this issue by setting the write flag as a
__u64, and adding thecompat_ioctlptr.While this does affect the ABI for 32bit users, its only the ABI for the
ion_testdriver, not ion itself.Cc Colin Cross <[email protected]>Cc Greg KH <[email protected]>Cc Android Kernel Team <[email protected]>Signed-off-by John Stultz <[email protected]>--- drivers/staging/android/ion/ion_test.c | 1 + drivers/staging/android/uapi/ion_test.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
Quoted 12 lines
drivers/staging/android/ion/ion_test.c static int ion_test_release(struct inode *inode, struct file *file) · line 234
Quoted 9 lines
drivers/staging/android/ion/ion_test.c +1
-0@@ -231,6 +231,7 @@ static int ion_test_release(struct inode *inode, struct file *file)static const struct file_operations ion_test_fops = { .owner =THIS_MODULE , .unlocked_ioctl = ion_test_ioctl, + .compat_ioctl = ion_test_ioctl,Setting the
compat_ioctlto the same thing asunlocked_ioctlshouldn't be necessary,compat_sys_ioctlwill fall through todo_vfs_ioctlifcompat_ioctlis not set, which will callunlocked_ioctl.
Hrm. I've not looked into the implementation, but doesn't seem to be the case on x86_64. Without it I get -1 back when calling the ioctl from a 32bit application. With it the ioctls work.
Quoted 17 lines
Quoted 9 lines
drivers/staging/android/ion/ion_test.c +0
-0.open = ion_test_open, .release = ion_test_release, };drivers/staging/android/uapi/ion_test.h +0
-0drivers/staging/android/uapi/ion_test.h struct ion_test_rw_data { · line 35
Quoted 6 lines
drivers/staging/android/uapi/ion_test.h +1
-1@@ -31,7 +31,7 @@ struct ion_test_rw_data {__u64 ptr;__u64 offset;__u64 size; -int write; +__u64 write; };Whoops, missed that one. Can you add "int padding" after "int write" instead? That at least lets us use the 32 bits later.
Will do.
thanks
-john
Quoted 39 lines · John Stultz
Quoted 25 lines · Colin Cross
Quoted 24 lines · John Stultz
Prior to subitting this, Colin reworked the
compat_ioctlsupport for theion_testdriver, moving the structure to be the same size on both 32 and 64 bit architectures.Two small things were left out. The
compat_ioctlptr assignment, and the fact that despite having uniform sized types in the structure, the structure pads out to different sizes on different arches.This patch resolves this issue by setting the write flag as a
__u64, and adding thecompat_ioctlptr.While this does affect the ABI for 32bit users, its only the ABI for the
ion_testdriver, not ion itself.Cc Colin Cross <[email protected]>Cc Greg KH <[email protected]>Cc Android Kernel Team <[email protected]>Signed-off-by John Stultz <[email protected]>--- drivers/staging/android/ion/ion_test.c | 1 + drivers/staging/android/uapi/ion_test.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)Quoted 12 lines
drivers/staging/android/ion/ion_test.c static int ion_test_release(struct inode *inode, struct file *file) · line 234
Quoted 9 lines
drivers/staging/android/ion/ion_test.c +1
-0@@ -231,6 +231,7 @@ static int ion_test_release(struct inode *inode, struct file *file)static const struct file_operations ion_test_fops = { .owner =THIS_MODULE , .unlocked_ioctl = ion_test_ioctl, + .compat_ioctl = ion_test_ioctl,Setting the
compat_ioctlto the same thing asunlocked_ioctlshouldn't be necessary,compat_sys_ioctlwill fall through todo_vfs_ioctlifcompat_ioctlis not set, which will callunlocked_ioctl.
Quoted 3 lines
Hrm. I've not looked into the implementation, but doesn't seem to be the case on
x86_64. Without it I get -1 back when calling the ioctl from a 32bit application. With it the ioctls work.
I missed that compat_sys_ioctl returns -ENOTTY if do_ioctl_trans fails, so the compat_ioctl is necessary.
Quoted 26 lines
Quoted 17 lines
Quoted 9 lines
drivers/staging/android/ion/ion_test.c +0
-0.open = ion_test_open, .release = ion_test_release, };drivers/staging/android/uapi/ion_test.h +0
-0drivers/staging/android/uapi/ion_test.h struct ion_test_rw_data { · line 35
Quoted 6 lines
drivers/staging/android/uapi/ion_test.h +1
-1@@ -31,7 +31,7 @@ struct ion_test_rw_data {__u64 ptr;__u64 offset;__u64 size; -int write; +__u64 write; };Whoops, missed that one. Can you add "int padding" after "int write" instead? That at least lets us use the 32 bits later.
Will do.
thanks
-johnTo unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
PATCH 1/1 ion_test: Add compat_ioctl support (v2)
Prior to subitting this, Colin reworked the compat_ioctl support for the ion_test driver, moving the structure to be the same size on both 32 and 64 bit architectures.
Two small things were left out. The compat_ioctl ptr assignment, and the fact that despite having uniform sized types in the structure, the structure pads out to different sizes on different arches.
This patch resolves this issue by adding a padding entry after the write flag, and adding the compat_ioctl ptr.
Changes in v2:
- Add a padding int rather then making write a u64
--- drivers/staging/android/ion/ion_test.c | 1 + drivers/staging/android/uapi/ion_test.h | 1 + 2 files changed, 2 insertions(+)
drivers/staging/android/ion/ion_test.c +1 -0
@@ -231,6 +231,7 @@ static int ion_test_release(struct inode *inode, struct file *file)static const struct file_operations ion_test_fops = { .owner =THIS_MODULE , .unlocked_ioctl = ion_test_ioctl, + .compat_ioctl = ion_test_ioctl, .open = ion_test_open, .release = ion_test_release, };
drivers/staging/android/uapi/ion_test.h +1 -0
@@ -32,6 +32,7 @@ struct ion_test_rw_data {__u64 offset;__u64 size;int write; +int __padding; };#define ION_IOC_MAGIC 'I'
Signature · 1 line
1.8.3.2
Re: [PATCH] ion_test: Add compat_ioctl support (v2)
Quoted 51 lines · John Stultz
Prior to subitting this, Colin reworked the
compat_ioctlsupport for theion_testdriver, moving the structure to be the same size on both 32 and 64 bit architectures.Two small things were left out. The
compat_ioctlptr assignment, and the fact that despite having uniform sized types in the structure, the structure pads out to different sizes on different arches.This patch resolves this issue by adding a padding entry after the write flag, and adding the
compat_ioctlptr.Changes in v2:
- Add a padding int rather then making write a u64Cc Colin Cross <[email protected]>Cc Greg KH <[email protected]>Cc Android Kernel Team <[email protected]>Signed-off-by John Stultz <[email protected]>--- drivers/staging/android/ion/ion_test.c | 1 + drivers/staging/android/uapi/ion_test.h | 1 + 2 files changed, 2 insertions(+)drivers/staging/android/ion/ion_test.c +1
-0@@ -231,6 +231,7 @@ static int ion_test_release(struct inode *inode, struct file *file)static const struct file_operations ion_test_fops = { .owner =THIS_MODULE , .unlocked_ioctl = ion_test_ioctl, + .compat_ioctl = ion_test_ioctl, .open = ion_test_open, .release = ion_test_release, };drivers/staging/android/uapi/ion_test.h +1
-1@@ -32,6 +32,7 @@ struct ion_test_rw_data {__u64 offset;__u64 size;int write; +int __padding; };#define ION_IOC_MAGIC 'I' --1.8.3.2
Quoted 1 line
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].