ext4: Fix compat EXT4_IOC_ADD_GROUP

svn path=/dists/sid/linux-2.6/; revision=15767
This commit is contained in:
Ben Hutchings 2010-05-25 23:05:00 +00:00
parent 52b9ef4104
commit 382d2b806f
4 changed files with 139 additions and 0 deletions

1
debian/changelog vendored
View File

@ -18,6 +18,7 @@ linux-2.6 (2.6.32-14) UNRELEASED; urgency=low
instead on some VIA C7 systems. (Closes: #566208)
* nouveau: Fix fbcon corruption with font width not divisible by 8
(Closes: #583162)
* [amd64] ext4: Fix compat EXT4_IOC_ADD_GROUP (used by online resize)
[ Bastian Blank ]
* Update Xen patch.

View File

@ -0,0 +1,39 @@
From: Ben Hutchings <ben@decadent.org.uk>
Date: Mon, 17 May 2010 09:00:00 -0400
Subject: [PATCH 1/2] ext4: Conditionally define compat ioctl numbers
commit 3ad0fa9c3af24b787158aa7d1bca18e401082e33 upstream.
It is unnecessary, and in general impossible, to define the compat
ioctl numbers except when building the filesystem with CONFIG_COMPAT
defined.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
fs/ext4/ext4.h | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 4a825c1..c6d2ad0 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -397,6 +397,7 @@ struct ext4_new_group_data {
#define EXT4_IOC_ALLOC_DA_BLKS _IO('f', 12)
#define EXT4_IOC_MOVE_EXT _IOWR('f', 15, struct move_extent)
+#if defined(__KERNEL__) && defined(CONFIG_COMPAT)
/*
* ioctl commands in 32 bit emulation
*/
@@ -412,6 +413,7 @@ struct ext4_new_group_data {
#endif
#define EXT4_IOC32_GETVERSION_OLD FS_IOC32_GETVERSION
#define EXT4_IOC32_SETVERSION_OLD FS_IOC32_SETVERSION
+#endif
/*
--
1.7.1

View File

@ -0,0 +1,97 @@
From: Ben Hutchings <ben@decadent.org.uk>
Date: Mon, 17 May 2010 10:00:00 -0400
Subject: [PATCH 2/2] ext4: Fix compat EXT4_IOC_ADD_GROUP
commit 53819d0448e4e89d62ed974709565d8623445afb upstream.
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: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
[bwh: Adjust context for 2.6.32]
---
fs/ext4/ext4.h | 16 ++++++++++++++++
fs/ext4/ioctl.c | 25 +++++++++++++++++++++++--
2 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index c6d2ad0..c59cade 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -29,6 +29,9 @@
#include <linux/wait.h>
#include <linux/blockgroup_lock.h>
#include <linux/percpu_counter.h>
+#ifdef __KERNEL__
+#include <linux/compat.h>
+#endif
/*
* The fourth extended filesystem constants/structures
@@ -335,6 +338,18 @@ struct ext4_new_group_input {
__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 */
struct ext4_new_group_data {
__u32 group;
@@ -408,6 +423,7 @@ struct ext4_new_group_data {
#define EXT4_IOC32_GETRSVSZ _IOR('f', 5, int)
#define EXT4_IOC32_SETRSVSZ _IOW('f', 6, 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
#define EXT4_IOC32_WAIT_FOR_READONLY _IOR('f', 99, int)
#endif
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index b63d193..42e6809 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -363,8 +363,29 @@ long ext4_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
case EXT4_IOC32_SETRSVSZ:
cmd = EXT4_IOC_SETRSVSZ;
break;
- case EXT4_IOC_GROUP_ADD:
- break;
+ case EXT4_IOC32_GROUP_ADD: {
+ 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;
+ }
default:
return -ENOIOCTLCMD;
}
--
1.7.1

View File

@ -16,3 +16,5 @@
+ bugfix/all/drm-i915-disable-fbc-on-915gm-and-945gm.patch
+ bugfix/all/drm-nouveau-use-ALIGN-instead-of-open-coding-it.patch
+ bugfix/all/drm-nouveau-Fix-fbcon-corruption-with-font-width-not.patch
+ bugfix/all/ext4-Conditionally-define-compat-ioctl-numbers.patch
+ bugfix/all/ext4-Fix-compat-EXT4_IOC_ADD_GROUP.patch