]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
cifs: Fix integer overflow while processing acdirmax mount option
authorMurad Masimov <m.masimov@mt-integration.ru>
Tue, 11 Mar 2025 14:22:04 +0000 (17:22 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 22 Mar 2025 19:54:27 +0000 (12:54 -0700)
[ Upstream commit 5b29891f91dfb8758baf1e2217bef4b16b2b165b ]

User-provided mount parameter acdirmax of type u32 is intended to have
an upper limit, but before it is validated, the value is converted from
seconds to jiffies which can lead to an integer overflow.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 4c9f948142a5 ("cifs: Add new mount parameter "acdirmax" to allow caching directory metadata")
Signed-off-by: Murad Masimov <m.masimov@mt-integration.ru>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/smb/client/fs_context.c

index e03946dc1d965c01b584ce28d29691e3b99ffed4..1b54287593298b30237a4cd2ecc281430f155a08 100644 (file)
@@ -1261,11 +1261,11 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,
                ctx->acregmax = HZ * result.uint_32;
                break;
        case Opt_acdirmax:
-               ctx->acdirmax = HZ * result.uint_32;
-               if (ctx->acdirmax > CIFS_MAX_ACTIMEO) {
+               if (result.uint_32 > CIFS_MAX_ACTIMEO / HZ) {
                        cifs_errorf(fc, "acdirmax too large\n");
                        goto cifs_parse_mount_err;
                }
+               ctx->acdirmax = HZ * result.uint_32;
                break;
        case Opt_actimeo:
                if (HZ * result.uint_32 > CIFS_MAX_ACTIMEO) {