Skip to content

Commit

Permalink
mmc: sdio: Check for CISTPL_VERS_1 buffer size
Browse files Browse the repository at this point in the history
[ Upstream commit 8ebe260 ]

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>
  • Loading branch information
pali authored and gregkh committed Oct 29, 2020
1 parent 60e8d95 commit c0f64a9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/mmc/core/sdio_cis.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,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;
Expand Down

0 comments on commit c0f64a9

Please sign in to comment.