summaryrefslogtreecommitdiffstats
path: root/fs/ceph/super.c
diff options
context:
space:
mode:
authorYan, Zheng <zyan@redhat.com>2017-07-11 18:49:44 +0800
committerIlya Dryomov <idryomov@gmail.com>2017-09-06 19:56:42 +0200
commit4214fb158cc423ac31b841000e219855be055388 (patch)
tree716d8d92d1969d31cbda430b5ccc60299d3751cb /fs/ceph/super.c
parent95cca2b44e54b00a3ed6ed7dc869717cd6807e81 (diff)
downloadlinux-4214fb158cc423ac31b841000e219855be055388.tar.bz2
ceph: validate correctness of some mount options
Signed-off-by: "Yan, Zheng" <zyan@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'fs/ceph/super.c')
-rw-r--r--fs/ceph/super.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/fs/ceph/super.c b/fs/ceph/super.c
index caf9801712ca..1deb8810d7c7 100644
--- a/fs/ceph/super.c
+++ b/fs/ceph/super.c
@@ -243,21 +243,33 @@ static int parse_fsopt_token(char *c, void *private)
fsopt->rsize = ALIGN(intval, PAGE_SIZE);
break;
case Opt_rasize:
- fsopt->rasize = intval;
+ if (intval < 0)
+ return -EINVAL;
+ fsopt->rasize = ALIGN(intval + PAGE_SIZE - 1, PAGE_SIZE);
break;
case Opt_caps_wanted_delay_min:
+ if (intval < 1)
+ return -EINVAL;
fsopt->caps_wanted_delay_min = intval;
break;
case Opt_caps_wanted_delay_max:
+ if (intval < 1)
+ return -EINVAL;
fsopt->caps_wanted_delay_max = intval;
break;
case Opt_readdir_max_entries:
+ if (intval < 1)
+ return -EINVAL;
fsopt->max_readdir = intval;
break;
case Opt_readdir_max_bytes:
+ if (intval < PAGE_SIZE && intval != 0)
+ return -EINVAL;
fsopt->max_readdir_bytes = intval;
break;
case Opt_congestion_kb:
+ if (intval < 1024) /* at least 1M */
+ return -EINVAL;
fsopt->congestion_kb = intval;
break;
case Opt_dirstat:
@@ -946,12 +958,7 @@ static int ceph_setup_bdi(struct super_block *sb, struct ceph_fs_client *fsc)
return err;
/* set ra_pages based on rasize mount option? */
- if (fsc->mount_options->rasize >= PAGE_SIZE)
- sb->s_bdi->ra_pages =
- (fsc->mount_options->rasize + PAGE_SIZE - 1)
- >> PAGE_SHIFT;
- else
- sb->s_bdi->ra_pages = VM_MAX_READAHEAD * 1024 / PAGE_SIZE;
+ sb->s_bdi->ra_pages = fsc->mount_options->rasize >> PAGE_SHIFT;
/* set io_pages based on max osd read size */
sb->s_bdi->io_pages = fsc->mount_options->rsize >> PAGE_SHIFT;