From: Al Viro Date: Tue, 19 May 2020 21:48:52 +0000 (-0400) Subject: fix multiplication overflow in copy_fdtable() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2a738364667b485709c28942be9c0b1681b28199;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git fix multiplication overflow in copy_fdtable() [ Upstream commit 4e89b7210403fa4a8acafe7c602b6212b7af6c3b ] cpy and set really should be size_t; we won't get an overflow on that, since sysctl_nr_open can't be set above ~(size_t)0 / sizeof(void *), so nr that would've managed to overflow size_t on that multiplication won't get anywhere near copy_fdtable() - we'll fail with EMFILE before that. Cc: stable@kernel.org # v2.6.25+ Fixes: 9cfe015aa424 (get rid of NR_OPEN and introduce a sysctl_nr_open) Reported-by: Thiago Macieira Signed-off-by: Al Viro Signed-off-by: Sasha Levin --- diff --git a/fs/file.c b/fs/file.c index 0c25b980affe..97c6f0df39da 100644 --- a/fs/file.c +++ b/fs/file.c @@ -75,7 +75,7 @@ static void copy_fd_bitmaps(struct fdtable *nfdt, struct fdtable *ofdt, */ static void copy_fdtable(struct fdtable *nfdt, struct fdtable *ofdt) { - unsigned int cpy, set; + size_t cpy, set; BUG_ON(nfdt->max_fds < ofdt->max_fds);