From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f66.google.com ([74.125.82.66]:53426 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725794AbeICL7D (ORCPT ); Mon, 3 Sep 2018 07:59:03 -0400 Date: Mon, 3 Sep 2018 09:40:05 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: OGAWA Hirofumi Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH] fat: Relax checks for sector size and media type Message-ID: <20180903074005.7e3guj24ksq2l44c@pali> References: <20180902131932.11558-1-pali.rohar@gmail.com> <87bm9ft5h5.fsf@mail.parknet.co.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87bm9ft5h5.fsf@mail.parknet.co.jp> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Monday 03 September 2018 16:17:26 OGAWA Hirofumi wrote: > Pali Rohár writes: > > > Windows fastfat.sys driver accepts also media types 0x00 and 0x01 and > > sector sizes 128 and 256 bytes. Linux mkfs.fat can format disk also to > > larger FAT sector sizes then 4096 bytes, therefore relax also upper limit > > restriction. > > > - if (!is_power_of_2(bpb->fat_sector_size) > > - || (bpb->fat_sector_size < 512) > > - || (bpb->fat_sector_size > 4096)) { > > + if (!is_power_of_2(bpb->fat_sector_size)) { > > Just relaxing validation doesn't work. The block layer doesn't support > smaller than 512, and lager than PAGE_SIZE. (And in specification, fat > doesn't support lager than 4096.) Hi! I just sent this patch for discussion, with links to (now open source) Windows implementation. I guess that Windows driver implementation is more "authoritative" then Microsoft's own specification. It is known that Windows implementation does not match Microsoft specification. I know at least 3 FAT specifications (MS EFI FAT, MS/SD card FAT, ECMA-107) and you are right that Microsoft's one does not allow sector sizes larger then 4096. If there is limitation by block layer, then: 1) Why we do not check for PAGE_SIZE? 2) Is check in fat driver really needed (if block layer checks it)? > > static inline int fat_valid_media(u8 media) > > { > > - return 0xf8 <= media || media == 0xf0; > > + return 0xf8 <= media || media == 0xf0 || media == 0x00 || media == 0x01; > > } > > #endif /* !_LINUX_MSDOS_FS_H */ > > This is ok though, this would be for ancient floppy media. Ok. -- Pali Rohár pali.rohar@gmail.com