git: e1ac02ff7adf - stable/13 - geom label msdosfs: sanity check BPB before using it for io request
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 15 Jan 2022 00:51:35 UTC
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=e1ac02ff7adf7a9749ca2a57d6da25e6a295a68f commit e1ac02ff7adf7a9749ca2a57d6da25e6a295a68f Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2021-12-30 13:17:59 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2022-01-14 18:11:01 +0000 geom label msdosfs: sanity check BPB before using it for io request (cherry picked from commit 9f4073d44628bc70dbe67df5163266cbfbe37167) --- sys/geom/label/g_label_msdosfs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sys/geom/label/g_label_msdosfs.c b/sys/geom/label/g_label_msdosfs.c index d6ccb8b334ee..67ac879d62c2 100644 --- a/sys/geom/label/g_label_msdosfs.c +++ b/sys/geom/label/g_label_msdosfs.c @@ -152,6 +152,12 @@ g_label_msdosfs_taste(struct g_consumer *cp, char *label, size_t size) G_LABEL_DEBUG(2, "MSDOSFS: FAT_FirstDataSector=0x%x, FAT_BytesPerSector=%d", fat_FirstDataSector, fat_BytesPerSector); + if (fat_BytesPerSector == 0 || + fat_BytesPerSector % pp->sectorsize != 0) { + G_LABEL_DEBUG(1, "MSDOSFS: %s: corrupted BPB", + pp->name); + goto error; + } for (offset = fat_BytesPerSector * fat_FirstDataSector;; offset += fat_BytesPerSector) {