diff options
Diffstat (limited to 'fs/ceph/export.c')
| -rw-r--r-- | fs/ceph/export.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/fs/ceph/export.c b/fs/ceph/export.c index 8e1b60e557b6..02ce90972d81 100644 --- a/fs/ceph/export.c +++ b/fs/ceph/export.c | |||
| @@ -99,7 +99,7 @@ static int ceph_encode_fh(struct inode *inode, u32 *rawfh, int *max_len, | |||
| 99 | * FIXME: we should try harder by querying the mds for the ino. | 99 | * FIXME: we should try harder by querying the mds for the ino. |
| 100 | */ | 100 | */ |
| 101 | static struct dentry *__fh_to_dentry(struct super_block *sb, | 101 | static struct dentry *__fh_to_dentry(struct super_block *sb, |
| 102 | struct ceph_nfs_fh *fh) | 102 | struct ceph_nfs_fh *fh, int fh_len) |
| 103 | { | 103 | { |
| 104 | struct ceph_mds_client *mdsc = ceph_sb_to_client(sb)->mdsc; | 104 | struct ceph_mds_client *mdsc = ceph_sb_to_client(sb)->mdsc; |
| 105 | struct inode *inode; | 105 | struct inode *inode; |
| @@ -107,6 +107,9 @@ static struct dentry *__fh_to_dentry(struct super_block *sb, | |||
| 107 | struct ceph_vino vino; | 107 | struct ceph_vino vino; |
| 108 | int err; | 108 | int err; |
| 109 | 109 | ||
| 110 | if (fh_len < sizeof(*fh) / 4) | ||
| 111 | return ERR_PTR(-ESTALE); | ||
| 112 | |||
| 110 | dout("__fh_to_dentry %llx\n", fh->ino); | 113 | dout("__fh_to_dentry %llx\n", fh->ino); |
| 111 | vino.ino = fh->ino; | 114 | vino.ino = fh->ino; |
| 112 | vino.snap = CEPH_NOSNAP; | 115 | vino.snap = CEPH_NOSNAP; |
| @@ -150,7 +153,7 @@ static struct dentry *__fh_to_dentry(struct super_block *sb, | |||
| 150 | * convert connectable fh to dentry | 153 | * convert connectable fh to dentry |
| 151 | */ | 154 | */ |
| 152 | static struct dentry *__cfh_to_dentry(struct super_block *sb, | 155 | static struct dentry *__cfh_to_dentry(struct super_block *sb, |
| 153 | struct ceph_nfs_confh *cfh) | 156 | struct ceph_nfs_confh *cfh, int fh_len) |
| 154 | { | 157 | { |
| 155 | struct ceph_mds_client *mdsc = ceph_sb_to_client(sb)->mdsc; | 158 | struct ceph_mds_client *mdsc = ceph_sb_to_client(sb)->mdsc; |
| 156 | struct inode *inode; | 159 | struct inode *inode; |
| @@ -158,6 +161,9 @@ static struct dentry *__cfh_to_dentry(struct super_block *sb, | |||
| 158 | struct ceph_vino vino; | 161 | struct ceph_vino vino; |
| 159 | int err; | 162 | int err; |
| 160 | 163 | ||
| 164 | if (fh_len < sizeof(*cfh) / 4) | ||
| 165 | return ERR_PTR(-ESTALE); | ||
| 166 | |||
| 161 | dout("__cfh_to_dentry %llx (%llx/%x)\n", | 167 | dout("__cfh_to_dentry %llx (%llx/%x)\n", |
| 162 | cfh->ino, cfh->parent_ino, cfh->parent_name_hash); | 168 | cfh->ino, cfh->parent_ino, cfh->parent_name_hash); |
| 163 | 169 | ||
| @@ -207,9 +213,11 @@ static struct dentry *ceph_fh_to_dentry(struct super_block *sb, struct fid *fid, | |||
| 207 | int fh_len, int fh_type) | 213 | int fh_len, int fh_type) |
| 208 | { | 214 | { |
| 209 | if (fh_type == 1) | 215 | if (fh_type == 1) |
| 210 | return __fh_to_dentry(sb, (struct ceph_nfs_fh *)fid->raw); | 216 | return __fh_to_dentry(sb, (struct ceph_nfs_fh *)fid->raw, |
| 217 | fh_len); | ||
| 211 | else | 218 | else |
| 212 | return __cfh_to_dentry(sb, (struct ceph_nfs_confh *)fid->raw); | 219 | return __cfh_to_dentry(sb, (struct ceph_nfs_confh *)fid->raw, |
| 220 | fh_len); | ||
| 213 | } | 221 | } |
| 214 | 222 | ||
| 215 | /* | 223 | /* |
| @@ -230,6 +238,8 @@ static struct dentry *ceph_fh_to_parent(struct super_block *sb, | |||
| 230 | 238 | ||
| 231 | if (fh_type == 1) | 239 | if (fh_type == 1) |
| 232 | return ERR_PTR(-ESTALE); | 240 | return ERR_PTR(-ESTALE); |
| 241 | if (fh_len < sizeof(*cfh) / 4) | ||
| 242 | return ERR_PTR(-ESTALE); | ||
| 233 | 243 | ||
| 234 | pr_debug("fh_to_parent %llx/%d\n", cfh->parent_ino, | 244 | pr_debug("fh_to_parent %llx/%d\n", cfh->parent_ino, |
| 235 | cfh->parent_name_hash); | 245 | cfh->parent_name_hash); |
