]> git.baikalelectronics.ru Git - kernel.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>
Fri, 10 Mar 2023 08:32:52 +0000 (09:32 +0100)
commitd650bfc5cb35442cd47378c7dcb8eba8915fe564
tree82b8331b329b8f0849df2cab2957df05d8c22e88
parent8257204d0293b8b97f6531dbbfe915e79934d5f9
lib/mpi: Fix buffer overrun when SG is too long

[ Upstream commit b29eaa3a12091c711801a8fd46e1687cc19e6456 ]

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: ebd84f3efad6 ("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