Date: Thu, 31 Mar 2022 20:11:28 GMT From: Ed Maste <emaste@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: e06ce938ddc0 - stable/13 - fstyp: detect Raspberry Pi Pico boot filesystem as FAT Message-ID: <202203312011.22VKBSTt032940@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=e06ce938ddc0222c6ed10a70108f71685923bd45 commit e06ce938ddc0222c6ed10a70108f71685923bd45 Author: Ed Maste <emaste@FreeBSD.org> AuthorDate: 2022-03-28 21:03:10 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2022-03-31 20:11:05 +0000 fstyp: detect Raspberry Pi Pico boot filesystem as FAT fstyp looks for a 0x55 0xAA signature at offset 510, but this is not required by specifications and is not proivded by the Raspberry Pi Pico bootloader. We should really remove the signature check and implement a more comprehensive BPB validation instead, but it will require more investigation and testing. For now just add a special case for the Raspberry Pi Pico bootloader, to avoid introducing regressions or new false positives. PR: 262896 Reviewed by: delphij MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D34699 (cherry picked from commit 868c1b8431f297ade8deba5baf903f73cf5e11c6) (cherry picked from commit 27c2f016b86744aa5d4c6031b4ef2fc16bbf6546) --- usr.sbin/fstyp/msdosfs.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/usr.sbin/fstyp/msdosfs.c b/usr.sbin/fstyp/msdosfs.c index 3d86802f6a2e..2e74f769ca97 100644 --- a/usr.sbin/fstyp/msdosfs.c +++ b/usr.sbin/fstyp/msdosfs.c @@ -41,6 +41,24 @@ __FBSDID("$FreeBSD$"); #define LABEL_NO_NAME "NO NAME " +/* + * XXX the signature 0x55 0xAA as the last two bytes of 512 is not required + * by specifications, but was historically required by fstyp. This check + * should be removed, with a more comprehensive BPB validation instead. + */ +static bool +check_signature(uint8_t sector0[512]) +{ + /* Check for the FAT boot sector signature. */ + if (sector0[510] == 0x55 && sector0[511] == 0xaa) + return (true); + /* Special case for Raspberry Pi Pico bootloader. */ + if (sector0[510] == 0 && sector0[511] == 0 && + sector0[0] == 0xeb && sector0[1] == 0x3c && sector0[2] == 0x90) + return (true); + return (false); +} + int fstyp_msdosfs(FILE *fp, char *label, size_t size) { @@ -57,8 +75,7 @@ fstyp_msdosfs(FILE *fp, char *label, size_t size) if (sector0 == NULL) return (1); - /* Check for the FAT boot sector signature. */ - if (sector0[510] != 0x55 || sector0[511] != 0xaa) { + if (!check_signature(sector0)) { goto error; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202203312011.22VKBSTt032940>