提交 4d92dc0f 编写于 作者: B Ben Hutchings 提交者: Theodore Ts'o

ext4: Fix compat EXT4_IOC_ADD_GROUP

struct ext4_new_group_input needs to be converted because u64 has
only 32-bit alignment on some 32-bit architectures, notably i386.
Signed-off-by: NBen Hutchings <ben@decadent.org.uk>
Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
上级 899ad0ce
...@@ -29,6 +29,9 @@ ...@@ -29,6 +29,9 @@
#include <linux/wait.h> #include <linux/wait.h>
#include <linux/blockgroup_lock.h> #include <linux/blockgroup_lock.h>
#include <linux/percpu_counter.h> #include <linux/percpu_counter.h>
#ifdef __KERNEL__
#include <linux/compat.h>
#endif
/* /*
* The fourth extended filesystem constants/structures * The fourth extended filesystem constants/structures
...@@ -432,6 +435,18 @@ struct ext4_new_group_input { ...@@ -432,6 +435,18 @@ struct ext4_new_group_input {
__u16 unused; __u16 unused;
}; };
#if defined(__KERNEL__) && defined(CONFIG_COMPAT)
struct compat_ext4_new_group_input {
u32 group;
compat_u64 block_bitmap;
compat_u64 inode_bitmap;
compat_u64 inode_table;
u32 blocks_count;
u16 reserved_blocks;
u16 unused;
};
#endif
/* The struct ext4_new_group_input in kernel space, with free_blocks_count */ /* The struct ext4_new_group_input in kernel space, with free_blocks_count */
struct ext4_new_group_data { struct ext4_new_group_data {
__u32 group; __u32 group;
...@@ -509,6 +524,7 @@ struct ext4_new_group_data { ...@@ -509,6 +524,7 @@ struct ext4_new_group_data {
#define EXT4_IOC32_GETRSVSZ _IOR('f', 5, int) #define EXT4_IOC32_GETRSVSZ _IOR('f', 5, int)
#define EXT4_IOC32_SETRSVSZ _IOW('f', 6, int) #define EXT4_IOC32_SETRSVSZ _IOW('f', 6, int)
#define EXT4_IOC32_GROUP_EXTEND _IOW('f', 7, unsigned int) #define EXT4_IOC32_GROUP_EXTEND _IOW('f', 7, unsigned int)
#define EXT4_IOC32_GROUP_ADD _IOW('f', 8, struct compat_ext4_new_group_input)
#ifdef CONFIG_JBD2_DEBUG #ifdef CONFIG_JBD2_DEBUG
#define EXT4_IOC32_WAIT_FOR_READONLY _IOR('f', 99, int) #define EXT4_IOC32_WAIT_FOR_READONLY _IOR('f', 99, int)
#endif #endif
......
...@@ -373,8 +373,29 @@ long ext4_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -373,8 +373,29 @@ long ext4_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
case EXT4_IOC32_SETRSVSZ: case EXT4_IOC32_SETRSVSZ:
cmd = EXT4_IOC_SETRSVSZ; cmd = EXT4_IOC_SETRSVSZ;
break; break;
case EXT4_IOC_GROUP_ADD: case EXT4_IOC32_GROUP_ADD: {
break; struct compat_ext4_new_group_input __user *uinput;
struct ext4_new_group_input input;
mm_segment_t old_fs;
int err;
uinput = compat_ptr(arg);
err = get_user(input.group, &uinput->group);
err |= get_user(input.block_bitmap, &uinput->block_bitmap);
err |= get_user(input.inode_bitmap, &uinput->inode_bitmap);
err |= get_user(input.inode_table, &uinput->inode_table);
err |= get_user(input.blocks_count, &uinput->blocks_count);
err |= get_user(input.reserved_blocks,
&uinput->reserved_blocks);
if (err)
return -EFAULT;
old_fs = get_fs();
set_fs(KERNEL_DS);
err = ext4_ioctl(file, EXT4_IOC_GROUP_ADD,
(unsigned long) &input);
set_fs(old_fs);
return err;
}
case EXT4_IOC_MOVE_EXT: case EXT4_IOC_MOVE_EXT:
break; break;
default: default:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册