From 4030b278368d89bba99a31e87766968cbf7909d2 Mon Sep 17 00:00:00 2001 From: Namjae Jeon Date: Sun, 4 Apr 2021 17:52:58 +0900 Subject: [PATCH] cifsd: prevent a integer overflow in wm_alloc() 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 Signed-off-by: Steve French --- fs/cifsd/buffer_pool.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/cifsd/buffer_pool.c b/fs/cifsd/buffer_pool.c index caf22c1..1ee1fee 100644 --- a/fs/cifsd/buffer_pool.c +++ b/fs/cifsd/buffer_pool.c @@ -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; -- 2.7.4