ceph: validate snapdirname option length when mounting
Ilya Dryomov
maintainerPATCH 1/1 ceph: validate snapdirname option length when mounting
It becomes a path component, so it shouldn't exceed NAME_MAX characters. This was hardened in commit c152737be22b ("ceph: Use strscpy() instead of strcpy() in __get_snap_name()"), but no actual check was put in place.
--- fs/ceph/super.c | 2 ++ 1 file changed, 2 insertions(+)
fs/ceph/super.c +2 -0
@@ -431,6 +431,8 @@ static int ceph_parse_mount_param(struct fs_context *fc,switch (token) {case Opt_snapdirname: +if (strlen (param->string) >NAME_MAX ) +return invalfc (fc,"snapdirname too long" );kfree (fsopt->snapdir_name); fsopt->snapdir_name = param->string; param->string =NULL ;
Signature · 1 line
2.46.1
Quoted 20 lines · Ilya Dryomov
It becomes a path component, so it shouldn't exceed
NAME_MAXcharacters. This was hardened in commitc152737be22b("ceph: Usestrscpy()instead ofstrcpy()in__get_snap_name()"), but no actual check was put in place.Signed-off-by Ilya Dryomov <[email protected]>---
fs/ceph/super.c | 2 ++1 file changed, 2 insertions(+)fs/ceph/super.c +0
-0@@ -431,6 +431,8 @@ static int ceph_parse_mount_param(struct fs_context *fc,
switch (token) {
caseOpt_snapdirname:
fs/ceph/super.c static int ceph_parse_mount_param(struct fs_context *fc, · line 435
Quoted 2 lines
fs/ceph/super.c +2
-0+if (strlen (param->string) >NAME_MAX ) +return invalfc (fc,"snapdirname too long" );
This check makes sense to me. :) Looks really good!
Thanks,
Slava.
Quoted 3 lines
kfree(fsopt->snapdir_name);fsopt->snapdir_name=param->string;param->string= NULL;