From: Ilya Dryomov Date: Wed, 20 Nov 2024 15:43:51 +0000 (+0100) Subject: ceph: validate snapdirname option length when mounting X-Git-Tag: v6.13-rc4~15^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=12eb22a5a609421b380c3c6ca887474fb2089b2c;p=thirdparty%2Fkernel%2Flinux.git 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. Cc: stable@vger.kernel.org Signed-off-by: Ilya Dryomov Reviewed-by: Alex Markuze --- diff --git a/fs/ceph/super.c b/fs/ceph/super.c index de03cd6eb86ee..4344e1f118069 100644 --- a/fs/ceph/super.c +++ b/fs/ceph/super.c @@ -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;