summaryrefslogtreecommitdiff
path: root/Documentation/tty/git@git.tavy.me:linux.git
diff options
context:
space:
mode:
authorMaoyi Xie <maoyixie.tju@gmail.com>2026-07-02 16:27:45 +0800
committerUlf Hansson <ulfh@kernel.org>2026-07-06 17:09:30 +0200
commit718178f524b98bc920d74bc771aed823c8b81425 (patch)
tree259817b2b2eac853174d485185b62fd546f25ca2 /Documentation/tty/git@git.tavy.me:linux.git
parentc505d54c1a9e99d36d322ced6c9c71a1157424b0 (diff)
memstick: ms_block: reject a card that reports too many blocks
msb_ftl_initialize() computes the zone count from the card block count with no bound: msb->zone_count = msb->block_count / MS_BLOCKS_IN_ZONE; ... for (i = 0; i < msb->zone_count; i++) msb->free_block_count[i] = MS_BLOCKS_IN_ZONE; msb->block_count is a card value. msb_read_boot_blocks() reads number_of_blocks from the card boot page and byte swaps it. free_block_count is a fixed int[MS_MAX_ZONES]. MS_MAX_ZONES is 16, so the valid indices are 0 to 15. The init loop above indexes it by zone_count. msb_mark_block_used() and msb_mark_block_unused() index it by pba / MS_BLOCKS_IN_ZONE, for pba up to block_count - 1. A card may report up to 65535 blocks. A block_count above 8192 (MS_MAX_ZONES * MS_BLOCKS_IN_ZONE) lets the pba index reach 16. That writes past free_block_count[] and corrupts struct msb_data. A larger count runs the init loop past the end too. A real Memory Stick has at most 16 zones. So it has at most 8192 blocks. msb_ftl_initialize() now rejects a card that reports more than MS_MAX_ZONES * MS_BLOCKS_IN_ZONE blocks. Fixes: 0ab30494bc4f ("memstick: add support for legacy memorysticks") Cc: stable@vger.kernel.org Signed-off-by: Maoyi Xie <maoyixie.tju@gmail.com> Signed-off-by: Ulf Hansson <ulfh@kernel.org>
Diffstat (limited to 'Documentation/tty/git@git.tavy.me:linux.git')
0 files changed, 0 insertions, 0 deletions