Commit dc498d09 authored by Ryusuke Konishi's avatar Ryusuke Konishi Committed by Linus Torvalds

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: default avatarRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 1088dcf4
...@@ -41,6 +41,7 @@ static int nilfs_ioctl_wrap_copy(struct the_nilfs *nilfs, ...@@ -41,6 +41,7 @@ static int nilfs_ioctl_wrap_copy(struct the_nilfs *nilfs,
void *, size_t, size_t)) void *, size_t, size_t))
{ {
void *buf; void *buf;
void __user *base = (void __user *)(unsigned long)argv->v_base;
size_t maxmembs, total, n; size_t maxmembs, total, n;
ssize_t nr; ssize_t nr;
int ret, i; int ret, i;
...@@ -64,9 +65,8 @@ static int nilfs_ioctl_wrap_copy(struct the_nilfs *nilfs, ...@@ -64,9 +65,8 @@ static int nilfs_ioctl_wrap_copy(struct the_nilfs *nilfs,
n = (argv->v_nmembs - i < maxmembs) ? n = (argv->v_nmembs - i < maxmembs) ?
argv->v_nmembs - i : maxmembs; argv->v_nmembs - i : maxmembs;
if ((dir & _IOC_WRITE) && if ((dir & _IOC_WRITE) &&
copy_from_user(buf, copy_from_user(buf, base + argv->v_size * i,
(void __user *)argv->v_base + argv->v_size * i, argv->v_size * n)) {
argv->v_size * n)) {
ret = -EFAULT; ret = -EFAULT;
break; break;
} }
...@@ -78,9 +78,8 @@ static int nilfs_ioctl_wrap_copy(struct the_nilfs *nilfs, ...@@ -78,9 +78,8 @@ static int nilfs_ioctl_wrap_copy(struct the_nilfs *nilfs,
break; break;
} }
if ((dir & _IOC_READ) && if ((dir & _IOC_READ) &&
copy_to_user( copy_to_user(base + argv->v_size * i, buf,
(void __user *)argv->v_base + argv->v_size * i, argv->v_size * nr)) {
buf, argv->v_size * nr)) {
ret = -EFAULT; ret = -EFAULT;
break; break;
} }
......
...@@ -499,6 +499,7 @@ NILFS_CHECKPOINT_FNS(SKETCH, sketch) ...@@ -499,6 +499,7 @@ NILFS_CHECKPOINT_FNS(SKETCH, sketch)
/** /**
* struct nilfs_cpinfo - checkpoint information * struct nilfs_cpinfo - checkpoint information
* @ci_flags: flags * @ci_flags: flags
* @ci_pad: padding
* @ci_cno: checkpoint number * @ci_cno: checkpoint number
* @ci_create: creation timestamp * @ci_create: creation timestamp
* @ci_nblk_inc: number of blocks incremented by this checkpoint * @ci_nblk_inc: number of blocks incremented by this checkpoint
...@@ -508,6 +509,7 @@ NILFS_CHECKPOINT_FNS(SKETCH, sketch) ...@@ -508,6 +509,7 @@ NILFS_CHECKPOINT_FNS(SKETCH, sketch)
*/ */
struct nilfs_cpinfo { struct nilfs_cpinfo {
__u32 ci_flags; __u32 ci_flags;
__u32 ci_pad;
__u64 ci_cno; __u64 ci_cno;
__u64 ci_create; __u64 ci_create;
__u64 ci_nblk_inc; __u64 ci_nblk_inc;
...@@ -668,7 +670,8 @@ enum { ...@@ -668,7 +670,8 @@ enum {
*/ */
struct nilfs_cpmode { struct nilfs_cpmode {
__u64 cm_cno; __u64 cm_cno;
int cm_mode; __u32 cm_mode;
__u32 cm_pad;
}; };
/** /**
...@@ -676,15 +679,15 @@ struct nilfs_cpmode { ...@@ -676,15 +679,15 @@ struct nilfs_cpmode {
* @v_base: * @v_base:
* @v_nmembs: * @v_nmembs:
* @v_size: * @v_size:
* @v_index:
* @v_flags: * @v_flags:
* @v_index:
*/ */
struct nilfs_argv { struct nilfs_argv {
void *v_base; __u64 v_base;
size_t v_nmembs; /* number of members */ __u32 v_nmembs; /* number of members */
size_t v_size; /* size of members */ __u16 v_size; /* size of members */
int v_index; __u16 v_flags;
int v_flags; __u64 v_index;
}; };
/** /**
...@@ -721,8 +724,8 @@ struct nilfs_sustat { ...@@ -721,8 +724,8 @@ struct nilfs_sustat {
__u64 ss_nsegs; __u64 ss_nsegs;
__u64 ss_ncleansegs; __u64 ss_ncleansegs;
__u64 ss_ndirtysegs; __u64 ss_ndirtysegs;
time_t ss_ctime; __u64 ss_ctime;
time_t ss_nongc_ctime; __u64 ss_nongc_ctime;
}; };
/** /**
...@@ -750,6 +753,7 @@ struct nilfs_vdesc { ...@@ -750,6 +753,7 @@ struct nilfs_vdesc {
__u64 vd_blocknr; __u64 vd_blocknr;
__u64 vd_offset; __u64 vd_offset;
__u32 vd_flags; __u32 vd_flags;
__u32 vd_pad;
}; };
/** /**
...@@ -761,6 +765,7 @@ struct nilfs_bdesc { ...@@ -761,6 +765,7 @@ struct nilfs_bdesc {
__u64 bd_blocknr; __u64 bd_blocknr;
__u64 bd_offset; __u64 bd_offset;
__u32 bd_level; __u32 bd_level;
__u32 bd_pad;
}; };
#define NILFS_IOCTL_IDENT 'n' #define NILFS_IOCTL_IDENT 'n'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment