Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1451163ybl; Sun, 18 Aug 2019 03:54:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqz8OSVfwWKKwXlXI/zxxpr+ZqolNPkteOI+Sbn+HIWaZrhdK27gHDSBto2B+4teGo55HACe X-Received: by 2002:a63:58c:: with SMTP id 134mr16019592pgf.106.1566125657357; Sun, 18 Aug 2019 03:54:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566125657; cv=none; d=google.com; s=arc-20160816; b=Z3FXAtnpbLBDO52W1Dq5IRnFqmfBesrQxV1mfaqQBc6JjTZOjPtYCdF1Wdq0/8vXA6 hR88SHDoMbibtBxfq+3JKeJ2t1o0fkR3pKfQf+9WEOTta7m/odVIOAiPx0nRL8Pb3OpU ZYwGOWXkyi4MXPybv8AX7bwaQRMrVbsPens6tb9m2wXRzqvy/RW+wRKsQP+uhLabtJZ7 zvifiNLh7iFc1Y1ePvBzYVyKEpgqHvoR2NKckEWOOhEz/zpIKq/xr8xFpy1xo1QajND1 8UdgzD9erce0Jm2Pq6S4i/GaUFnGRjdZ0dLN9DeJtvsuEcUaX2tfLWiwjvIyDlBAEgJr +NBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Al7Y79Y4t+qPG08oQ3rkqS3r0H46fW3GAyLkFntSPXo=; b=u8fbsFYUmfu/zWAGVY08zd78NJtTL9pKyWlaqgPRicSt78Xlfs41qdKMNVUrSvTy2R joKak+WFDS8elu5CNn8nWoDp877TNRXKa+IyovBtbQWUG/Mq9AeBT1EFwgGVaPhKNoUk B+Qw3NFxAq9B7BL35kmAweXDonBBD935gl7TOO+fmkbh08hQGlE5n+y2ig4bm5fdsCcr pU9Wf2v2XLxGAOcV1zOtMcErTEPwm/OooXWbNmykzQ6Raa6XyL0MJ8aQObcOHJn4vFOO Xm5GFHz+PDRfS0aEYzum5XdnO9EbqL1yFEOufQA4MirbSOxxjQDAKVolSESagAa+59YS 25vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aol.com header.s=a2048 header.b=M2McAfxR; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=aol.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s16si6584468pjp.1.2019.08.18.03.54.02; Sun, 18 Aug 2019 03:54:17 -0700 (PDT) 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; dkim=pass header.i=@aol.com header.s=a2048 header.b=M2McAfxR; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=aol.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726595AbfHRKxN (ORCPT + 99 others); Sun, 18 Aug 2019 06:53:13 -0400 Received: from sonic305-19.consmr.mail.ir2.yahoo.com ([77.238.177.81]:44907 "EHLO sonic305-19.consmr.mail.ir2.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726089AbfHRKxN (ORCPT ); Sun, 18 Aug 2019 06:53:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1566125590; bh=Al7Y79Y4t+qPG08oQ3rkqS3r0H46fW3GAyLkFntSPXo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From:Subject; b=M2McAfxRbhGiA/0b4+xywWlJrewVv/IwjTYML1lhULiYenunwVh9Ahgd90lsK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7jwMMwpf6K21BjCwuiULcWHCqNTEWNvnEDElvshHSgYC.2h T.XDZ4Bzv9mSuiIVgTGIrScSLrCD4DLEVKHrRBVwQBzXikD1PsFPa7Ey3QIpyqR3Sh8ttdY2eG3F KWM4A7VYJbkYAIJYzXbD8ldIzh8THl7qL6mJaaskWarIJl6UCnmEv4_CarQU6lAHHBFiVKtdPU7b 3PWtVEIru0jjngFXpU936UtTyDU8anPV8FS7wGcXLpa4aCZGZC_obL06TIqmeO3E87SenFCIz0LI BaEiN6kMAcSXNpRMxBnET8N9r1QeolsbsX2t5Guv9yHXD3Qfbk0C965qSbRnMdUwieuG9DeatByj DAcgU0xT4ii3pDPyOpbXjB7QkI6iiZJh2n7fk02ZTWOfeOnpmsx8shsSS4kw8tnTui38JLVWAATS ISt4uorjWXYws6K3TcbGA.l2xOjSninezGeO_tjP_6owXpATuZLSvyFZpgS9hQF_2ADCFriz00Nq 55h05WsQ1Oi9rAuob8hfcBew3L95XQX8c54hUjqP8 Received: from sonic.gate.mail.ne1.yahoo.com by sonic305.consmr.mail.ir2.yahoo.com with HTTP; Sun, 18 Aug 2019 10:53:10 +0000 Received: by smtp411.mail.ir2.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID c4c1659c966ff50bb0667c28376a62d2; Sun, 18 Aug 2019 10:53:08 +0000 (UTC) Date: Sun, 18 Aug 2019 18:52:58 +0800 From: Gao Xiang To: Chao Yu Cc: Matthew Wilcox , Chao Yu , Richard Weinberger , Greg Kroah-Hartman , devel@driverdev.osuosl.org, linux-fsdevel@vger.kernel.org, LKML , linux-erofs@lists.ozlabs.org, Miao Xie , Fang Wei , Gao Xiang , stable@vger.kernel.org Subject: Re: [PATCH v2] staging: erofs: fix an error handling in erofs_readdir() Message-ID: <20190818105255.GA22640@hsiangkao-HP-ZHAN-66-Pro-G1> References: <20190818014835.5874-1-hsiangkao@aol.com> <20190818015631.6982-1-hsiangkao@aol.com> <20190818022055.GA14592@bombadil.infradead.org> <20190818023240.GA7739@hsiangkao-HP-ZHAN-66-Pro-G1> <20190818025339.GB14592@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Chao, On Sun, Aug 18, 2019 at 06:39:52PM +0800, Chao Yu wrote: > On 2019-8-18 10:53, Matthew Wilcox wrote: > > On Sun, Aug 18, 2019 at 10:32:45AM +0800, Gao Xiang wrote: > >> On Sat, Aug 17, 2019 at 07:20:55PM -0700, Matthew Wilcox wrote: > >>> On Sun, Aug 18, 2019 at 09:56:31AM +0800, Gao Xiang wrote: > >>>> @@ -82,8 +82,12 @@ static int erofs_readdir(struct file *f, struct dir_context *ctx) > >>>> unsigned int nameoff, maxsize; > >>>> > >>>> dentry_page = read_mapping_page(mapping, i, NULL); > >>>> - if (IS_ERR(dentry_page)) > >>>> - continue; > >>>> + if (IS_ERR(dentry_page)) { > >>>> + errln("fail to readdir of logical block %u of nid %llu", > >>>> + i, EROFS_V(dir)->nid); > >>>> + err = PTR_ERR(dentry_page); > >>>> + break; > >>> > >>> I don't think you want to use the errno that came back from > >>> read_mapping_page() (which is, I think, always going to be -EIO). > >>> Rather you want -EFSCORRUPTED, at least if I understand the recent > >>> patches to ext2/ext4/f2fs/xfs/... > >> > >> Thanks for your reply and noticing this. :) > >> > >> Yes, as I talked with you about read_mapping_page() in a xfs related > >> topic earlier, I think I fully understand what returns here. > >> > >> I actually had some concern about that before sending out this patch. > >> You know the status is > >> PG_uptodate is not set and PG_error is set here. > >> > >> But we cannot know it is actually a disk read error or due to > >> corrupted images (due to lack of page flags or some status, and > >> I think it could be a waste of page structure space for such > >> corrupted image or disk error)... > >> > >> And some people also like propagate errors from insiders... > >> (and they could argue about err = -EFSCORRUPTED as well..) > >> > >> I'd like hear your suggestion about this after my words above? > >> still return -EFSCORRUPTED? > > > > I don't think it matters whether it's due to a disk error or a corrupted > > image. We can't read the directory entry, so we should probably return > > -EFSCORRUPTED. Thinking about it some more, read_mapping_page() can > > also return -ENOMEM, so it should probably look something like this: > > > > err = 0; > > if (dentry_page == ERR_PTR(-ENOMEM)) > > err = -ENOMEM; > > else if (IS_ERR(dentry_page)) { > > errln("fail to readdir of logical block %u of nid %llu", > > i, EROFS_V(dir)->nid); > > err = -EFSCORRUPTED; > > Well, if there is real IO error happen under filesystem, we should return -EIO > instead of EFSCORRUPTED? > > The right fix may be that doing sanity check on on-disk blkaddr, and return > -EFSCORRUPTED if the blkaddr is invalid and propagate the error to its caller > erofs_readdir(), IIUC below error info. In my thought, I actually don't care what is actually returned (In other words, I have no tendency about EFSCORRUPTED / EIO) as long as it behaves normal for corrupted image. A little concern is that I have no idea whether all user problems can handle EUCLEAN properly. I don't want to limit blkaddr as what ->blocks recorded in erofs_super_block since it's already used for our hotpatching approach and that field is only used for statfs() for users to know its visible size, and block layer will block such invalid block access. All in all, that is minor. I think we can fix as what Matthew said. Thanks, Gao Xiang > > > [36297.354090] attempt to access beyond end of device > > [36297.354098] loop17: rw=0, want=29887428984, limit=1953128 > > [36297.354107] attempt to access beyond end of device > > [36297.354109] loop17: rw=0, want=29887428480, limit=1953128 > > [36301.827234] attempt to access beyond end of device > > [36301.827243] loop17: rw=0, want=29887428480, limit=1953128 > > Thanks, > > > } > > > > if (err) > > break; > >