cifsd: prevent a integer overflow in wm_alloc()
authorNamjae Jeon <namjae.jeon@samsung.com>
Sun, 4 Apr 2021 08:52:58 +0000 (17:52 +0900)
committerSteve French <stfrench@microsoft.com>
Tue, 11 May 2021 00:15:37 +0000 (19:15 -0500)
Dan Carpenter pointed out that there there is a possibility of
integer overflow. This patch prevent a integer overflow in wm_alloc().

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifsd/buffer_pool.c

index caf22c1..1ee1fee 100644 (file)
@@ -42,6 +42,9 @@ static struct wm *wm_alloc(size_t sz, gfp_t flags)
        struct wm *wm;
        size_t alloc_sz = sz + sizeof(struct wm);
 
+       if (sz > SIZE_MAX - sizeof(struct wm))
+               return NULL;
+
        wm = kvmalloc(alloc_sz, flags);
        if (!wm)
                return NULL;