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 862887004d20..9349bb37a2fe 100644 --- a/fs/ceph/export.c +++ b/fs/ceph/export.c | |||
@@ -101,7 +101,7 @@ static int ceph_encode_fh(struct inode *inode, u32 *rawfh, int *max_len, | |||
101 | * FIXME: we should try harder by querying the mds for the ino. | 101 | * FIXME: we should try harder by querying the mds for the ino. |
102 | */ | 102 | */ |
103 | static struct dentry *__fh_to_dentry(struct super_block *sb, | 103 | static struct dentry *__fh_to_dentry(struct super_block *sb, |
104 | struct ceph_nfs_fh *fh) | 104 | struct ceph_nfs_fh *fh, int fh_len) |
105 | { | 105 | { |
106 | struct ceph_mds_client *mdsc = ceph_sb_to_client(sb)->mdsc; | 106 | struct ceph_mds_client *mdsc = ceph_sb_to_client(sb)->mdsc; |
107 | struct inode *inode; | 107 | struct inode *inode; |
@@ -109,6 +109,9 @@ static struct dentry *__fh_to_dentry(struct super_block *sb, | |||
109 | struct ceph_vino vino; | 109 | struct ceph_vino vino; |
110 | int err; | 110 | int err; |
111 | 111 | ||
112 | if (fh_len < sizeof(*fh) / 4) | ||
113 | return ERR_PTR(-ESTALE); | ||
114 | |||
112 | dout("__fh_to_dentry %llx\n", fh->ino); | 115 | dout("__fh_to_dentry %llx\n", fh->ino); |
113 | vino.ino = fh->ino; | 116 | vino.ino = fh->ino; |
114 | vino.snap = CEPH_NOSNAP; | 117 | vino.snap = CEPH_NOSNAP; |
@@ -152,7 +155,7 @@ static struct dentry *__fh_to_dentry(struct super_block *sb, | |||
152 | * convert connectable fh to dentry | 155 | * convert connectable fh to dentry |
153 | */ | 156 | */ |
154 | static struct dentry *__cfh_to_dentry(struct super_block *sb, | 157 | static struct dentry *__cfh_to_dentry(struct super_block *sb, |
155 | struct ceph_nfs_confh *cfh) | 158 | struct ceph_nfs_confh *cfh, int fh_len) |
156 | { | 159 | { |
157 | struct ceph_mds_client *mdsc = ceph_sb_to_client(sb)->mdsc; | 160 | struct ceph_mds_client *mdsc = ceph_sb_to_client(sb)->mdsc; |
158 | struct inode *inode; | 161 | struct inode *inode; |
@@ -160,6 +163,9 @@ static struct dentry *__cfh_to_dentry(struct super_block *sb, | |||
160 | struct ceph_vino vino; | 163 | struct ceph_vino vino; |
161 | int err; | 164 | int err; |
162 | 165 | ||
166 | if (fh_len < sizeof(*cfh) / 4) | ||
167 | return ERR_PTR(-ESTALE); | ||
168 | |||
163 | dout("__cfh_to_dentry %llx (%llx/%x)\n", | 169 | dout("__cfh_to_dentry %llx (%llx/%x)\n", |
164 | cfh->ino, cfh->parent_ino, cfh->parent_name_hash); | 170 | cfh->ino, cfh->parent_ino, cfh->parent_name_hash); |
165 | 171 | ||
@@ -209,9 +215,11 @@ static struct dentry *ceph_fh_to_dentry(struct super_block *sb, struct fid *fid, | |||
209 | int fh_len, int fh_type) | 215 | int fh_len, int fh_type) |
210 | { | 216 | { |
211 | if (fh_type == 1) | 217 | if (fh_type == 1) |
212 | return __fh_to_dentry(sb, (struct ceph_nfs_fh *)fid->raw); | 218 | return __fh_to_dentry(sb, (struct ceph_nfs_fh *)fid->raw, |
219 | fh_len); | ||
213 | else | 220 | else |
214 | return __cfh_to_dentry(sb, (struct ceph_nfs_confh *)fid->raw); | 221 | return __cfh_to_dentry(sb, (struct ceph_nfs_confh *)fid->raw, |
222 | fh_len); | ||
215 | } | 223 | } |
216 | 224 | ||
217 | /* | 225 | /* |
@@ -232,6 +240,8 @@ static struct dentry *ceph_fh_to_parent(struct super_block *sb, | |||
232 | 240 | ||
233 | if (fh_type == 1) | 241 | if (fh_type == 1) |
234 | return ERR_PTR(-ESTALE); | 242 | return ERR_PTR(-ESTALE); |
243 | if (fh_len < sizeof(*cfh) / 4) | ||
244 | return ERR_PTR(-ESTALE); | ||
235 | 245 | ||
236 | pr_debug("fh_to_parent %llx/%d\n", cfh->parent_ino, | 246 | pr_debug("fh_to_parent %llx/%d\n", cfh->parent_ino, |
237 | cfh->parent_name_hash); | 247 | cfh->parent_name_hash); |