Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752388AbbKOLGE (ORCPT ); Sun, 15 Nov 2015 06:06:04 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:51810 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751113AbbKOLGA (ORCPT ); Sun, 15 Nov 2015 06:06:00 -0500 Subject: Re: Endless getdents() in vfat filesystem To: OGAWA Hirofumi , Andrew Morton References: <56468C1E.2060401@oracle.com> <56472C2F.5090207@oracle.com> <87r3js3baj.fsf@mail.parknet.co.jp> <56474DDB.7020904@nod.at> <87egfs30l8.fsf@mail.parknet.co.jp> Cc: Richard Weinberger , LKML From: Vegard Nossum Message-ID: <56486709.7000004@oracle.com> Date: Sun, 15 Nov 2015 12:05:45 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <87egfs30l8.fsf@mail.parknet.co.jp> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Source-IP: aserv0021.oracle.com [141.146.126.233] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1359 Lines: 46 On 11/14/2015 07:19 PM, OGAWA Hirofumi wrote: > Richard Weinberger writes: > >>>> Yes, it does fixes the problem here, but I can't really comment on the >>>> correctness of the patch. >>>> >>>> Thanks for the quick reponse, >>> >>> I made cleanup and made sure fake_offset is corrected. >>> >>> Richard, Signed-off-by was missed in your patch, so I added. Can you >>> agree to Signed-off-by? >> >> Sure! > > Attached updated patch made smaller changes, and with missed Cc: stable. > > Andrew, please queue this up. > > Thanks. > It would be nice to have a proper patch description too. How about this? """ For the root directory, . and .. are faked (using dir_emit_dots()) and ctx->pos is reset from 2 to 0. A corrupted root directory could cause fat_get_entry() to fail, but ->iterate() (fat_readdir()) reports progress to the VFS (with ctx->pos rewound to 0), so any following calls to ->iterate() continue to return the same entries again and again. The result is that userspace will never see the end of the directory, causing e.g. 'ls' to hang in a getdents() loop. """ Thanks, Vegard -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/