Skip to content

Commit 4214fb1

Browse files
ukernelidryomov
authored andcommitted
ceph: validate correctness of some mount options
Signed-off-by: "Yan, Zheng" <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent 95cca2b commit 4214fb1

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

fs/ceph/super.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -243,21 +243,33 @@ static int parse_fsopt_token(char *c, void *private)
243243
fsopt->rsize = ALIGN(intval, PAGE_SIZE);
244244
break;
245245
case Opt_rasize:
246-
fsopt->rasize = intval;
246+
if (intval < 0)
247+
return -EINVAL;
248+
fsopt->rasize = ALIGN(intval + PAGE_SIZE - 1, PAGE_SIZE);
247249
break;
248250
case Opt_caps_wanted_delay_min:
251+
if (intval < 1)
252+
return -EINVAL;
249253
fsopt->caps_wanted_delay_min = intval;
250254
break;
251255
case Opt_caps_wanted_delay_max:
256+
if (intval < 1)
257+
return -EINVAL;
252258
fsopt->caps_wanted_delay_max = intval;
253259
break;
254260
case Opt_readdir_max_entries:
261+
if (intval < 1)
262+
return -EINVAL;
255263
fsopt->max_readdir = intval;
256264
break;
257265
case Opt_readdir_max_bytes:
266+
if (intval < PAGE_SIZE && intval != 0)
267+
return -EINVAL;
258268
fsopt->max_readdir_bytes = intval;
259269
break;
260270
case Opt_congestion_kb:
271+
if (intval < 1024) /* at least 1M */
272+
return -EINVAL;
261273
fsopt->congestion_kb = intval;
262274
break;
263275
case Opt_dirstat:
@@ -946,12 +958,7 @@ static int ceph_setup_bdi(struct super_block *sb, struct ceph_fs_client *fsc)
946958
return err;
947959

948960
/* set ra_pages based on rasize mount option? */
949-
if (fsc->mount_options->rasize >= PAGE_SIZE)
950-
sb->s_bdi->ra_pages =
951-
(fsc->mount_options->rasize + PAGE_SIZE - 1)
952-
>> PAGE_SHIFT;
953-
else
954-
sb->s_bdi->ra_pages = VM_MAX_READAHEAD * 1024 / PAGE_SIZE;
961+
sb->s_bdi->ra_pages = fsc->mount_options->rasize >> PAGE_SHIFT;
955962

956963
/* set io_pages based on max osd read size */
957964
sb->s_bdi->io_pages = fsc->mount_options->rsize >> PAGE_SHIFT;

fs/ceph/super.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@
5656
#define CEPH_MAX_READDIR_BYTES_DEFAULT (512*1024)
5757
#define CEPH_SNAPDIRNAME_DEFAULT ".snap"
5858

59+
/*
60+
* Delay telling the MDS we no longer want caps, in case we reopen
61+
* the file. Delay a minimum amount of time, even if we send a cap
62+
* message for some other reason. Otherwise, take the oppotunity to
63+
* update the mds to avoid sending another message later.
64+
*/
65+
#define CEPH_CAPS_WANTED_DELAY_MIN_DEFAULT 5 /* cap release delay */
66+
#define CEPH_CAPS_WANTED_DELAY_MAX_DEFAULT 60 /* cap release delay */
67+
5968
struct ceph_mount_options {
6069
int flags;
6170
int sb_flags;

include/linux/ceph/libceph.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,6 @@ struct ceph_options {
8484

8585
#define CEPH_AUTH_NAME_DEFAULT "guest"
8686

87-
/*
88-
* Delay telling the MDS we no longer want caps, in case we reopen
89-
* the file. Delay a minimum amount of time, even if we send a cap
90-
* message for some other reason. Otherwise, take the oppotunity to
91-
* update the mds to avoid sending another message later.
92-
*/
93-
#define CEPH_CAPS_WANTED_DELAY_MIN_DEFAULT 5 /* cap release delay */
94-
#define CEPH_CAPS_WANTED_DELAY_MAX_DEFAULT 60 /* cap release delay */
95-
96-
9787
/* mount state */
9888
enum {
9989
CEPH_MOUNT_MOUNTING,

0 commit comments

Comments
 (0)