Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3548900imu; Mon, 24 Dec 2018 04:15:59 -0800 (PST) X-Google-Smtp-Source: AFSGD/UFBOgcoVqkfZpPUyx+bSfo/vt3Bfo2GvWmzuJfIMlo5FW3gNvju3BYLk5N94aO0MqTOvkr X-Received: by 2002:a62:9f01:: with SMTP id g1mr12861510pfe.223.1545653759070; Mon, 24 Dec 2018 04:15:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545653759; cv=none; d=google.com; s=arc-20160816; b=Kx2hNnWzCb1U4X1qA1lbaLmi0lxs+Nqz2bafebb3QRXp9w4PC/qxeNgOfmEDQSLyBn AkTpCxu4N7BI24we4eX3GMx6MFzOZtn84wK3smJ5lC9CyOCpnIa+skqzsE7RuxEZZAOi AsDtx6ZRw7qOrlfmBEFxeXltqUg0H9cBl9ZxSdDpR3pDq+WZyE5cB7ohhF1Jy+C8h003 v1D/2vzhuOvT38RO+SAA0IKK6rqPYJHFBz44zpWgMFK7VzRhtM1NOoEr9L2/Bx7NzFy4 X6WxsBp3JVB5gNdkYAuUZKSqhu1eJ/ocSQAecajbwMdoZE27hr95Y6UKQHRcmMFbt7yL 6vMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from; bh=mw90nPVECAaLpu7FesCn32rJTkqIA+AxTyOezqq9GZQ=; b=bflVjWHAe13v+azhFJjWcJTKaDjLMxHkfQGqPCbr2q6ICv5Kwke32FUi76bD3CZc1O p8U7RITLwtvvISwGlsy3exNI/fyImMc2ir24cFrDCX0u91W+a2oE/O46toOB2mzZzeBf HDseO0pGm2lDmHrqy39nZ2IZI33B8eLV5wqu6PnALX+peG5xP5zvhtNSRRro8SJPupoG h3wtcm6kFFPbacZm9I1emOm5PRC3lFDpan/Oe6bRMyhhlEsFh2375E/e8WjDZg2l7wrc S/t9KORamxsXiJEDj392nv6JpBVgGRZehWIGFBw8RM0hgYTr+ztr7HnU4HZoNIA+ldIl XiJQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o11si3587498pgd.234.2018.12.24.04.15.43; Mon, 24 Dec 2018 04:15:59 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725871AbeLXMOx (ORCPT + 99 others); Mon, 24 Dec 2018 07:14:53 -0500 Received: from mail.parknet.co.jp ([210.171.160.6]:59388 "EHLO mail.parknet.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725298AbeLXMOx (ORCPT ); Mon, 24 Dec 2018 07:14:53 -0500 Received: from ibmpc.myhome.or.jp (server.parknet.ne.jp [210.171.168.39]) by mail.parknet.co.jp (Postfix) with ESMTPSA id 6588F12B609; Mon, 24 Dec 2018 21:14:51 +0900 (JST) Received: from devron.myhome.or.jp (foobar@devron.myhome.or.jp [192.168.0.3]) by ibmpc.myhome.or.jp (8.15.2/8.15.2/Debian-12) with ESMTPS id wBOCEofE009655 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 24 Dec 2018 21:14:51 +0900 Received: from devron.myhome.or.jp (foobar@localhost [127.0.0.1]) by devron.myhome.or.jp (8.15.2/8.15.2/Debian-12) with ESMTPS id wBOCEne6029174 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 24 Dec 2018 21:14:50 +0900 Received: (from hirofumi@localhost) by devron.myhome.or.jp (8.15.2/8.15.2/Submit) id wBOCEn7w029173; Mon, 24 Dec 2018 21:14:49 +0900 From: OGAWA Hirofumi To: Matteo Croce Cc: Timothy Redaelli , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v2] vfat: don't read garbage after last dirent References: <20181216231510.26854-1-mcroce@redhat.com> Date: Mon, 24 Dec 2018 21:14:49 +0900 In-Reply-To: <20181216231510.26854-1-mcroce@redhat.com> (Matteo Croce's message of "Mon, 17 Dec 2018 00:15:10 +0100") Message-ID: <87zhsvi0jq.fsf@mail.parknet.co.jp> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. (while adding new entry, if we found zeroed entry, we would be better to warn about fsck.) Thanks. -- OGAWA Hirofumi