Skip to content

Commit 91542d1

Browse files
idryomovgregkh
authored andcommitted
ceph: validate snapdirname option length when mounting
commit 12eb22a5a609421b380c3c6ca887474fb2089b2c upstream. 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. Cc: [email protected] Signed-off-by: Ilya Dryomov <[email protected]> Reviewed-by: Alex Markuze <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 28ca6f1 commit 91542d1

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/ceph/super.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,8 @@ static int ceph_parse_mount_param(struct fs_context *fc,
420420

421421
switch (token) {
422422
case Opt_snapdirname:
423+
if (strlen(param->string) > NAME_MAX)
424+
return invalfc(fc, "snapdirname too long");
423425
kfree(fsopt->snapdir_name);
424426
fsopt->snapdir_name = param->string;
425427
param->string = NULL;

0 commit comments

Comments
 (0)