linux/drivers/crypto/ccp
Tom Lendacky fb43f69401 crypto: ccp - Protect against poorly marked end of sg list
Scatter gather lists can be created with more available entries than are
actually used (e.g. using sg_init_table() to reserve a specific number
of sg entries, but in actuality using something less than that based on
the data length).  The caller sometimes fails to mark the last entry
with sg_mark_end().  In these cases, sg_nents() will return the original
size of the sg list as opposed to the actual number of sg entries that
contain valid data.

On arm64, if the sg_nents() value is used in a call to dma_map_sg() in
this situation, then it causes a BUG_ON in lib/swiotlb.c because an
"empty" sg list entry results in dma_capable() returning false and
swiotlb trying to create a bounce buffer of size 0. This occurred in
the userspace crypto interface before being fixed by

0f477b655a ("crypto: algif - Mark sgl end at the end of data")

Protect against this by using the new sg_nents_for_len() function which
returns only the number of sg entries required to meet the desired
length and supplying that value to dma_map_sg().

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2015-06-03 10:51:28 +08:00
..
ccp-crypto-aes-cmac.c crypto: ccp - Updates for checkpatch warnings/errors 2015-02-27 22:48:47 +13:00
ccp-crypto-aes-xts.c crypto: ccp - Updates for checkpatch warnings/errors 2015-02-27 22:48:47 +13:00
ccp-crypto-aes.c crypto: ccp - Updates for checkpatch warnings/errors 2015-02-27 22:48:47 +13:00
ccp-crypto-main.c crypto: ccp - Updates for checkpatch warnings/errors 2015-02-27 22:48:47 +13:00
ccp-crypto-sha.c crypto: ccp - Updates for checkpatch warnings/errors 2015-02-27 22:48:47 +13:00
ccp-crypto.h crypto: ccp - Updates for checkpatch warnings/errors 2015-02-27 22:48:47 +13:00
ccp-dev.c crypto: ccp - Convert calls to their devm_ counterparts 2015-02-27 22:48:48 +13:00
ccp-dev.h crypto: ccp - Updates for checkpatch warnings/errors 2015-02-27 22:48:47 +13:00
ccp-ops.c crypto: ccp - Protect against poorly marked end of sg list 2015-06-03 10:51:28 +08:00
ccp-pci.c crypto: ccp - Convert calls to their devm_ counterparts 2015-02-27 22:48:48 +13:00
ccp-platform.c crypto: ccp - Remove manual check and set of dma_mask pointer 2015-05-27 17:51:54 +08:00
Kconfig crypto: ccp - Remove "select OF" from Kconfig 2014-07-24 16:52:12 +08:00
Makefile crypto: ccp - Update CCP build support 2015-02-27 22:48:48 +13:00