Re: [PATCH 5.10] overflow.h: use new generic division helpers to avoid / operator
From: Kees Cook <hidden>
Date: 2021-09-14 18:48:02
Also in:
stable
From: Kees Cook <hidden>
Date: 2021-09-14 18:48:02
Also in:
stable
On Tue, Sep 14, 2021 at 11:30:03AM -0700, Linus Torvalds wrote:
case NBD_SET_SIZE_BLOCKS: - if (check_mul_overflow((loff_t)arg, config->blksize, &bytesize)) + bytesize = arg << config->blksize_bits; + if (bytesize >> config->blksize_bits != arg) return -EINVAL;
FWIW, it's probably better to avoid open-coding the check. There are helpers for shift-left too. :) + if (check_shl_overflow(arg, config->blksize_bits, &bytesize)) -- Kees Cook