Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6008627imu; Wed, 26 Dec 2018 13:06:41 -0800 (PST) X-Google-Smtp-Source: ALg8bN7uQGl2435/YqcXuZ+Kya0uJSMYMRLG7PKTYyqlRuh0pURtmvGeuxDfnItwGuOLywtEsJka X-Received: by 2002:a17:902:145:: with SMTP id 63mr21157942plb.256.1545858401344; Wed, 26 Dec 2018 13:06:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545858401; cv=none; d=google.com; s=arc-20160816; b=BcqHO94B3CyC0X5nROu1IRTpGL1BxEfYau80Ti6MsWgfdtQVOyxeRVRZ4FB/dvg6He VfKpeO4e1o/ke22d8zt33OO9RGkK4UK09jaAgEoFRfY23xZ+KlumGJL2MsIxKa8nrfMd FNXCte+HYWVJQxjXB948x0lwP9usrIgnxOofmZybXw3OKVzFr1gE4xUoMd+qU5P6e9RY AXCsFqWBgskWl64CvmcvEZtViZUfemRDIn2YpMvgyLWsI4OxSkWc3hskL0NmLERZ+J+J k6cr/Ka9vyryq0Fard2XhaS/lPO6YzsPFogclEqKlBPTEyoP6zSVfSo1xD3ssy36Y5TS NQ7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=dwEJGMRqNGMT3lccYYP8q+ZfpQWlm3LN07XfR8UgqwI=; b=d7IP8waQiRRb8y0gDJtj7LYxIo/1m58LU+5dpCPTRrGmnjk4BkCB5TF8lVlfc/qRvt JCFVow2gibbRWMO291eNUADoH/p9KKodcTUeETkkJ6Q+f9lVzB+P/Ev0jfkxmk7Q3Pkx 0rN7C1rANENNcItQGIq9CFlEOp6U9c+cy9A4+ekAJTYWgSlg+FzzsCAlYyTeDLwBS1cp A9ANeDkGNsY/IzSMAB72lYa56+L1FpAhxOH9499IB2Dv+mf2PR9d2AcSDv5itx/EBMsp UcP5rfjqpWxCpKiSxXhpAgYCDLCziqAGz5ToOKnk8Fm2C/Crsnm9066pbAohivFzORCZ Au9g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h67si35122850pfb.146.2018.12.26.13.06.25; Wed, 26 Dec 2018 13:06:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728147AbeLZUqD (ORCPT + 99 others); Wed, 26 Dec 2018 15:46:03 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:42190 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728135AbeLZUqC (ORCPT ); Wed, 26 Dec 2018 15:46:02 -0500 Received: by mail-lj1-f196.google.com with SMTP id l15-v6so14668089lja.9 for ; Wed, 26 Dec 2018 12:46:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dwEJGMRqNGMT3lccYYP8q+ZfpQWlm3LN07XfR8UgqwI=; b=A5RW3UKuXO1ChkVDGd9qx/gTo/I7LkBORF61WvFmVZX64qhpVH3vBo//XbCXGDzrGk AX4/cPRzNzBZ89HaXHm/Q83IWesSFEf/6tT12z0YaBupFaMhq3rHk8kZ6yLqub9AmAWV NcNJ9WpTQq9/kFNl8BCir5JoREbSBS0zpmgyejabBK03y9J1PgIoCD9rXNCIJ7Qpee3A K4cyUX53oGBCIUXxT/2a02FJLMG+KP9MYPBSscS57U0uXiM3IRnKlCvldWMSFKL6V2JX 3F4gl1FNtToAso1rlbDIqXjvmPnBf0q6uoTCghUsRRJMf08wSl9w5YpjPQ/FanrNfJ7T ZBzA== X-Gm-Message-State: AJcUukdb3V/Jz874Rqd1zsp8cdEwDrXC+jo6C6lPcGXXKGcFm9xZqPGR VE9QegtbJPpzOYaxyquZy6qDMU5V7CamG2k2mWAxJYbTvLg= X-Received: by 2002:a2e:2246:: with SMTP id i67-v6mr10342311lji.154.1545857160707; Wed, 26 Dec 2018 12:46:00 -0800 (PST) MIME-Version: 1.0 References: <20181216231510.26854-1-mcroce@redhat.com> <87zhsvi0jq.fsf@mail.parknet.co.jp> In-Reply-To: <87zhsvi0jq.fsf@mail.parknet.co.jp> From: Matteo Croce Date: Wed, 26 Dec 2018 21:45:24 +0100 Message-ID: Subject: Re: [PATCH v2] vfat: don't read garbage after last dirent To: OGAWA Hirofumi Cc: Timothy Redaelli , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 24, 2018 at 1:14 PM OGAWA Hirofumi wrote: > > Matteo Croce writes: > > > The FAT32 File System Specification[1] states that: > > > > If DIR_Name[0] == 0x00, then the directory entry is free, and there > > are no allocated directory entries after this one. > > > > The special 0 value, indicates to FAT file system driver code that > > the rest of the entries in this directory do not need to be examined > > because they are all free. > > > > This is not enforced by Linux, and is possible to read garbage if not > > all dirents after the last one are filled with zeroes. > > > > [1] http://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/fatgen103.doc > > > > Reported-by: Timothy Redaelli > > Signed-off-by: Matteo Croce > > We have to handle all paths that is using fat_get_entry(), to make > consistent behavior. > > With quick check, there are still several issues remaining. Please check > more. For example, looks like fat_parse_long()/fat_search_long() path is > missing, and fat_get_dotdot_entry(), fat_subdirs() too. > If I put the check in fat_get_short_entry(), then fat_get_dotdot_entry() and fat_subdirs() are covered too. Is there any drawback in doing this? > (while adding new entry, if we found zeroed entry, we would be better to > warn about fsck.) > Ok > Thanks. > -- > OGAWA Hirofumi Thanks, -- Matteo Croce per aspera ad upstream