diff options
author | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2009-04-06 22:01:52 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-07 11:31:18 -0400 |
commit | dc498d09be28172846cacded35ca2378222a8c7b (patch) | |
tree | 42b31073a0fb4eb74d6c09c2f4b9711262e97d2a | |
parent | 1088dcf4c3a0a27fdad5214781d5084b11405238 (diff) |
nilfs2: use fixed sized types for ioctl structures
Nilfs ioctl had structures not having fixed sized types such as:
struct nilfs_argv {
void *v_base;
size_t v_nmembs;
size_t v_size;
int v_index;
int v_flags;
};
Further, some of them are wrongly aligned:
e.g.
struct nilfs_cpmode {
__u64 cm_cno;
int cm_mode;
};
The size of wrongly aligned structures varies depending on
architectures, and it breaks the identity of ioctl commands, which
leads to arch dependent errors.
Previously, these are compensated by using compat_ioctl.
This fixes these problems and allows removal of compat ioctl.
Since this will change sizes of those structures, binary compatibility
for the past utilities will once break; new utilities have to be used
instead. However, it would be helpful to avoid platform dependent
problems in the long term.
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | fs/nilfs2/ioctl.c | 11 | ||||
-rw-r--r-- | include/linux/nilfs2_fs.h | 23 |
2 files changed, 19 insertions, 15 deletions
diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c index 85a291ccc1be..7fbd9fe1d035 100644 --- a/fs/nilfs2/ioctl.c +++ b/fs/nilfs2/ioctl.c | |||
@@ -41,6 +41,7 @@ static int nilfs_ioctl_wrap_copy(struct the_nilfs *nilfs, | |||
41 | void *, size_t, size_t)) | 41 | void *, size_t, size_t)) |
42 | { | 42 | { |
43 | void *buf; | 43 | void *buf; |
44 | void __user *base = (void __user *)(unsigned long)argv->v_base; | ||
44 | size_t maxmembs, total, n; | 45 | size_t maxmembs, total, n; |
45 | ssize_t nr; | 46 | ssize_t nr; |
46 | int ret, i; | 47 | int ret, i; |
@@ -64,9 +65,8 @@ static int nilfs_ioctl_wrap_copy(struct the_nilfs *nilfs, | |||
64 | n = (argv->v_nmembs - i < maxmembs) ? | 65 | n = (argv->v_nmembs - i < maxmembs) ? |
65 | argv->v_nmembs - i : maxmembs; | 66 | argv->v_nmembs - i : maxmembs; |
66 | if ((dir & _IOC_WRITE) && | 67 | if ((dir & _IOC_WRITE) && |
67 | copy_from_user(buf, | 68 | copy_from_user(buf, base + argv->v_size * i, |
68 | (void __user *)argv->v_base + argv->v_size * i, | 69 | argv->v_size * n)) { |
69 | argv->v_size * n)) { | ||
70 | ret = -EFAULT; | 70 | ret = -EFAULT; |
71 | break; | 71 | break; |
72 | } | 72 | } |
@@ -78,9 +78,8 @@ static int nilfs_ioctl_wrap_copy(struct the_nilfs *nilfs, | |||
78 | break; | 78 | break; |
79 | } | 79 | } |
80 | if ((dir & _IOC_READ) && | 80 | if ((dir & _IOC_READ) && |
81 | copy_to_user( | 81 | copy_to_user(base + argv->v_size * i, buf, |
82 | (void __user *)argv->v_base + argv->v_size * i, | 82 | argv->v_size * nr)) { |
83 | buf, argv->v_size * nr)) { | ||
84 | ret = -EFAULT; | 83 | ret = -EFAULT; |
85 | break; | 84 | break; |
86 | } | 85 | } |
diff --git a/include/linux/nilfs2_fs.h b/include/linux/nilfs2_fs.h index b0a6b39eedbc..8fb64ce285fd 100644 --- a/include/linux/nilfs2_fs.h +++ b/include/linux/nilfs2_fs.h | |||
@@ -499,6 +499,7 @@ NILFS_CHECKPOINT_FNS(SKETCH, sketch) | |||
499 | /** | 499 | /** |
500 | * struct nilfs_cpinfo - checkpoint information | 500 | * struct nilfs_cpinfo - checkpoint information |
501 | * @ci_flags: flags | 501 | * @ci_flags: flags |
502 | * @ci_pad: padding | ||
502 | * @ci_cno: checkpoint number | 503 | * @ci_cno: checkpoint number |
503 | * @ci_create: creation timestamp | 504 | * @ci_create: creation timestamp |
504 | * @ci_nblk_inc: number of blocks incremented by this checkpoint | 505 | * @ci_nblk_inc: number of blocks incremented by this checkpoint |
@@ -508,6 +509,7 @@ NILFS_CHECKPOINT_FNS(SKETCH, sketch) | |||
508 | */ | 509 | */ |
509 | struct nilfs_cpinfo { | 510 | struct nilfs_cpinfo { |
510 | __u32 ci_flags; | 511 | __u32 ci_flags; |
512 | __u32 ci_pad; | ||
511 | __u64 ci_cno; | 513 | __u64 ci_cno; |
512 | __u64 ci_create; | 514 | __u64 ci_create; |
513 | __u64 ci_nblk_inc; | 515 | __u64 ci_nblk_inc; |
@@ -668,7 +670,8 @@ enum { | |||
668 | */ | 670 | */ |
669 | struct nilfs_cpmode { | 671 | struct nilfs_cpmode { |
670 | __u64 cm_cno; | 672 | __u64 cm_cno; |
671 | int cm_mode; | 673 | __u32 cm_mode; |
674 | __u32 cm_pad; | ||
672 | }; | 675 | }; |
673 | 676 | ||
674 | /** | 677 | /** |
@@ -676,15 +679,15 @@ struct nilfs_cpmode { | |||
676 | * @v_base: | 679 | * @v_base: |
677 | * @v_nmembs: | 680 | * @v_nmembs: |
678 | * @v_size: | 681 | * @v_size: |
679 | * @v_index: | ||
680 | * @v_flags: | 682 | * @v_flags: |
683 | * @v_index: | ||
681 | */ | 684 | */ |
682 | struct nilfs_argv { | 685 | struct nilfs_argv { |
683 | void *v_base; | 686 | __u64 v_base; |
684 | size_t v_nmembs; /* number of members */ | 687 | __u32 v_nmembs; /* number of members */ |
685 | size_t v_size; /* size of members */ | 688 | __u16 v_size; /* size of members */ |
686 | int v_index; | 689 | __u16 v_flags; |
687 | int v_flags; | 690 | __u64 v_index; |
688 | }; | 691 | }; |
689 | 692 | ||
690 | /** | 693 | /** |
@@ -721,8 +724,8 @@ struct nilfs_sustat { | |||
721 | __u64 ss_nsegs; | 724 | __u64 ss_nsegs; |
722 | __u64 ss_ncleansegs; | 725 | __u64 ss_ncleansegs; |
723 | __u64 ss_ndirtysegs; | 726 | __u64 ss_ndirtysegs; |
724 | time_t ss_ctime; | 727 | __u64 ss_ctime; |
725 | time_t ss_nongc_ctime; | 728 | __u64 ss_nongc_ctime; |
726 | }; | 729 | }; |
727 | 730 | ||
728 | /** | 731 | /** |
@@ -750,6 +753,7 @@ struct nilfs_vdesc { | |||
750 | __u64 vd_blocknr; | 753 | __u64 vd_blocknr; |
751 | __u64 vd_offset; | 754 | __u64 vd_offset; |
752 | __u32 vd_flags; | 755 | __u32 vd_flags; |
756 | __u32 vd_pad; | ||
753 | }; | 757 | }; |
754 | 758 | ||
755 | /** | 759 | /** |
@@ -761,6 +765,7 @@ struct nilfs_bdesc { | |||
761 | __u64 bd_blocknr; | 765 | __u64 bd_blocknr; |
762 | __u64 bd_offset; | 766 | __u64 bd_offset; |
763 | __u32 bd_level; | 767 | __u32 bd_level; |
768 | __u32 bd_pad; | ||
764 | }; | 769 | }; |
765 | 770 | ||
766 | #define NILFS_IOCTL_IDENT 'n' | 771 | #define NILFS_IOCTL_IDENT 'n' |