]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
rman: fix overflow in rman_reserve_resource_bound()
authorElliott Mitchell <ehem+freebsd@m5p.com>
Mon, 27 Sep 2021 17:13:19 +0000 (14:13 -0300)
committerMitchell Horne <mhorne@FreeBSD.org>
Mon, 4 Oct 2021 14:15:19 +0000 (11:15 -0300)
commita3acb379bdea033ce08b4800cbb5a9c46a673ce1
tree2c1b7ae809110edfa0758ee9ca6756f4f147ae9d
parent50c20d90f97f7fe417ac111aebebe99aa8c943a6
rman: fix overflow in rman_reserve_resource_bound()

If the default range of [0, ~0] is given, then (~0 - 0) + 1 == 0. This
in turn will cause any allocation of non-zero size to fail. Zero-sized
allocations are prohibited, so add a KASSERT to this effect.

History indicates it is part of the original rman code.  This bug may in
fact be older than some contributors.

Reviewed by: mhorne
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D30280

(cherry picked from commit bcddaadbef5850ed9f040836d3f25ff57138ae28)
sys/kern/subr_rman.c