From: Pali Rohár Date: Mon, 27 Jul 2020 13:38:34 +0000 (+0200) Subject: mmc: sdio: Check for CISTPL_VERS_1 buffer size X-Git-Tag: v4.14.203~43 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=4d880c0cba3fb6dcd74cceb28c00ecf8b20f2a18;p=users%2Fdwmw2%2Flinux.git mmc: sdio: Check for CISTPL_VERS_1 buffer size [ Upstream commit 8ebe2607965d3e2dc02029e8c7dd35fbe508ffd0 ] Before parsing CISTPL_VERS_1 structure check that its size is at least two bytes to prevent buffer overflow. Signed-off-by: Pali Rohár Link: https://lore.kernel.org/r/20200727133837.19086-2-pali@kernel.org Signed-off-by: Ulf Hansson Signed-off-by: Sasha Levin --- diff --git a/drivers/mmc/core/sdio_cis.c b/drivers/mmc/core/sdio_cis.c index f8c372839d244..2ca5cd79018b4 100644 --- a/drivers/mmc/core/sdio_cis.c +++ b/drivers/mmc/core/sdio_cis.c @@ -30,6 +30,9 @@ static int cistpl_vers_1(struct mmc_card *card, struct sdio_func *func, unsigned i, nr_strings; char **buffer, *string; + if (size < 2) + return 0; + /* Find all null-terminated (including zero length) strings in the TPLLV1_INFO field. Trailing garbage is ignored. */ buf += 2;