From patchwork Sun Sep 2 13:19:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 10585163 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3A93C175A for ; Sun, 2 Sep 2018 13:20:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F6B4299C0 for ; Sun, 2 Sep 2018 13:20:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F3B0B299C6; Sun, 2 Sep 2018 13:20:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8FE85299C0 for ; Sun, 2 Sep 2018 13:20:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730313AbeIBRfu (ORCPT ); Sun, 2 Sep 2018 13:35:50 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:55551 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729339AbeIBRfu (ORCPT ); Sun, 2 Sep 2018 13:35:50 -0400 Received: by mail-wm0-f66.google.com with SMTP id f21-v6so9048851wmc.5; Sun, 02 Sep 2018 06:19:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=xNIW/GOTSFNOeCG0nYfmSyxZnU8H/fKbyMd7AKsZW/0=; b=SRFhLzvjVt2gEpgi+ik5UFKw/SYOqY74qeqzn064DLBE6e1ZDTxdvHeS0dg/znvve4 nVlPcFW8MUleT/Q9iOdcTy9hswx4Ywns5EbYh26CwkM/ck7q8QL5+DHgnmpZh0c2yoXa VDJ9INus1X+tNNWjd46wliU7gPSw5D6xt0vlBgAz5OlZotVKKWk6YwdVm0CwuER+XKb9 giz3/avGuc6qpi0EXoJZP2e/UCp24GWfmU7lnQ70cxPA0MJXBoS00hCGIeiHxo4nIFwf pSRXOgS48ZfTbumbPeJpv0tMEQcet8zn5cYs/chHzUq1rqZcuCvFh7q4mbFGPxKzknlh HTEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=xNIW/GOTSFNOeCG0nYfmSyxZnU8H/fKbyMd7AKsZW/0=; b=UXKUmqy38tLGghLQ1aqMm21L80Sy3jEE6o1+pzXLoFZqipW4WRMw1347eQfFd8P3lB QVuKb+7mIFGCFwYtamDOM0rYxhJRikYMOh6UXpi28/lMwW/MWy3w3iKKclndo66qIIp8 iQIcNVpKcbNI6P17HF8sMV85wjqh717vMufSNSVqEnGWJh2Rtq02HoXpjIHt79S+OrGo CIK5CGjA288O6hpjgjrbykQdKY9FLNfQmw6t1OczaqybIxAlsJgc/mXcEskZSSz2/3aT 621aWCavMuGCfcPCd5ZVM9iZLjjuzJg6wvsUTlm0Rieoa1OoyqkVfP7e0mJTjUKwVAIL qApQ== X-Gm-Message-State: APzg51B/8qwH6LhnyNhv82yBFWWWa/dYMj6LuZ4aLojof+YD22VMWVi0 59/2ISHp01ydQnnyZMv+QU96kyij X-Google-Smtp-Source: ANB0Vdb1DyR08xibj2qBJ0AwHy9kldTUH/HCmQTJmeUvSfgsrIkrfzDUAL2YkU/B0sJ1N8tj+gtIgw== X-Received: by 2002:a1c:9290:: with SMTP id u138-v6mr2903439wmd.52.1535894394877; Sun, 02 Sep 2018 06:19:54 -0700 (PDT) Received: from Pali-Latitude.lan ([2001:718:1e03:a01::1ca]) by smtp.gmail.com with ESMTPSA id p89-v6sm25354802wrc.97.2018.09.02.06.19.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Sep 2018 06:19:53 -0700 (PDT) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: OGAWA Hirofumi Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH] fat: Relax checks for sector size and media type Date: Sun, 2 Sep 2018 15:19:32 +0200 Message-Id: <20180902131932.11558-1-pali.rohar@gmail.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Pali Rohár --- Source code of Windows 10 Anniversary Update fastfat.sys driver is now available on github. Check for valid media types in fastfat.sys is there: https://github.com/Microsoft/Windows-driver-samples/blob/96eb96dfb613e4c745db6bd1f53a92fe7e2290fc/filesys/fastfat/fsctrl.c#L2601-L2611 And check for valid sector size is there: https://github.com/Microsoft/Windows-driver-samples/blob/96eb96dfb613e4c745db6bd1f53a92fe7e2290fc/filesys/fastfat/fsctrl.c#L2542-L2547 --- fs/fat/inode.c | 4 +--- include/linux/msdos_fs.h | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/fat/inode.c b/fs/fat/inode.c index d6b81e31..f2556f71 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c @@ -1506,9 +1506,7 @@ static int fat_read_bpb(struct super_block *sb, struct fat_boot_sector *b, goto out; } - 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)) { if (!silent) fat_msg(sb, KERN_ERR, "bogus logical sector size %u", (unsigned)bpb->fat_sector_size); diff --git a/include/linux/msdos_fs.h b/include/linux/msdos_fs.h index b7a5d4c7..e5b3f613 100644 --- a/include/linux/msdos_fs.h +++ b/include/linux/msdos_fs.h @@ -7,6 +7,6 @@ /* media of boot sector */ 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 */