diff options
author | Pali Rohár <pali@kernel.org> | 2020-07-27 15:38:34 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-10-29 09:05:42 +0100 |
commit | 669c9582680cfcd5939b02898247234f0b75601e (patch) | |
tree | 44aa98ee94bd083bd95e3785c68959b7b10b6dae | |
parent | 3b899e92444008df7ddfebac25193e11f9fef4e0 (diff) | |
download | linux-stable-669c9582680cfcd5939b02898247234f0b75601e.tar.gz linux-stable-669c9582680cfcd5939b02898247234f0b75601e.tar.bz2 linux-stable-669c9582680cfcd5939b02898247234f0b75601e.zip |
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 <pali@kernel.org>
Link: https://lore.kernel.org/r/20200727133837.19086-2-pali@kernel.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | drivers/mmc/core/sdio_cis.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/mmc/core/sdio_cis.c b/drivers/mmc/core/sdio_cis.c index dcb3dee59fa5..934c4816d78b 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; |