]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
percpu: do not search past bitmap when allocating an area
authorDennis Zhou <dennis@kernel.org>
Thu, 21 Feb 2019 23:54:11 +0000 (15:54 -0800)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
commit8dac7c01f325adadc3d6ad1b3f1cdc4952cf12ad
tree7c0f73819d7ca7d34ee05136d1d972946e5c4d2b
parenteedb2bac3bfa1ae92972a7f540d65ac8d031c3ef
percpu: do not search past bitmap when allocating an area

BugLink: https://bugs.launchpad.net/bugs/1838824
[ Upstream commit 8c43004af01635cc9fbb11031d070e5e0d327ef2 ]

pcpu_find_block_fit() guarantees that a fit is found within
PCPU_BITMAP_BLOCK_BITS. Iteration is used to determine the first fit as
it compares against the block's contig_hint. This can lead to
incorrectly scanning past the end of the bitmap. The behavior was okay
given the check after for bit_off >= end and the correctness of the
hints from pcpu_find_block_fit().

This patch fixes this by bounding the end offset by the number of bits
in a chunk.

Signed-off-by: Dennis Zhou <dennis@kernel.org>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
mm/percpu.c