]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
lib/mpi: Fix buffer overrun when SG is too long
authorHerbert Xu <herbert@gondor.apana.org.au>
Tue, 27 Dec 2022 14:27:39 +0000 (15:27 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 11 Mar 2023 15:26:36 +0000 (16:26 +0100)
commite8e03c84b151ec12f292e1e4cfc44fbcc7c37132
tree96b453274aab9ae7f2cb6411e797b7fa265312f1
parent5fc9633916314884c20436c179dcc9c4d06d1199
lib/mpi: Fix buffer overrun when SG is too long

[ Upstream commit 7361d1bc307b926cbca214ab67b641123c2d6357 ]

The helper mpi_read_raw_from_sgl sets the number of entries in
the SG list according to nbytes.  However, if the last entry
in the SG list contains more data than nbytes, then it may overrun
the buffer because it only allocates enough memory for nbytes.

Fixes: 2d4d1eea540b ("lib/mpi: Add mpi sgl helpers")
Reported-by: Roberto Sassu <roberto.sassu@huaweicloud.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
lib/mpi/mpicoder.c