]> git.proxmox.com Git - mirror_ubuntu-impish-kernel.git/commit
orangefs: Fix the size of a memory allocation in orangefs_bufmap_alloc()
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Mon, 27 Dec 2021 18:09:18 +0000 (19:09 +0100)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Mon, 7 Mar 2022 17:39:11 +0000 (18:39 +0100)
commitbfeb12c74ddba6d28f3782c73e918ca96992d760
tree6b4de293d2658439a128290dfafe5af6c62c9eab
parente7fddb9331fc8f230dfb9d67069ed7463383c795
orangefs: Fix the size of a memory allocation in orangefs_bufmap_alloc()

BugLink: https://bugs.launchpad.net/bugs/1960861
commit 40a74870b2d1d3d44e13b3b73c6571dd34f5614d upstream.

'buffer_index_array' really looks like a bitmap. So it should be allocated
as such.
When kzalloc is called, a number of bytes is expected, but a number of
longs is passed instead.

In get(), if not enough memory is allocated, un-allocated memory may be
read or written.

So use bitmap_zalloc() to safely allocate the correct memory size and
avoid un-expected behavior.

While at it, change the corresponding kfree() into bitmap_free() to keep
the semantic.

Fixes: ea2c9c9f6574 ("orangefs: bufmap rewrite")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Mike Marshall <hubcap@omnibond.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
fs/orangefs/orangefs-bufmap.c