Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1098772ybl; Sat, 17 Aug 2019 18:51:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqxl24kd6J/TfQR9lfFtd1PFQvjokAvBSdDUsv4r5v4qp+4mRKAq0J2SynVOGFK1AkM8Zaqj X-Received: by 2002:a17:90a:c08f:: with SMTP id o15mr14605544pjs.31.1566093085501; Sat, 17 Aug 2019 18:51:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566093085; cv=none; d=google.com; s=arc-20160816; b=l5B++KcaCPNvYH0Bpw5jd7JInA++OXV6W+yvprV6NJPAqX6jYucPBW7kgM8EkVjwH3 ZQRk8zEOJwtRvqcoyBgZLSRYRoDskZbAgWE++cA1IAp+xvRACsw77U02OZgHfMwNUk7S ewjxyiz2R1K10XUrbSeRe2c3ByMNiOmqbR0IGtXCcyfy5lqkQsIPnVGEH+rG6DR+c2+0 sl+hQ8lyH2ft2qGErWIok4WeHCSjOGaAGAmY3Dg/aLmCdYwhBszj9BipzDvewn399bc9 4HtORM8OvtQj7l5u5eJGAummDt1s8OjsqeOyHxj9czV86bXnpYWaLNW5RZAWCUUvhFhA Xj2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=3z4YsL7cITdwo3WfgBzjdtBKxHfbzIYd54Y/QXXxpig=; b=vqu46lXkEdPeBMxqv/aPMR/7L+CNVFruALOMSyBFU2DnTQdNQDUYb1eZYSCbyhQzyY ao3H0OaHNK5xSYZtIf7GouVRhDsKegGFeJ5BtUO7tmmHBQcl5a/sXZaIY/ASsmCInluM U+HQ3uoE6IJooN0kBL29ZtCpBRwqVBmjD+xxYqby0lIhkU0Qyc9UrNg1h0jHX2Tw8QBF qsRwnknspdphhC0dykR2w59oTvMlSDFcyoOjobVhMoRYC73UXeTZqiBIIuRpkdh/wAWK WwVH4E7zQSAgv0JuvBJodfSueJ8uVRiMBb+z7IX3Jji+zb2gTgtcN9XN4IbKR91qvp73 WQYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aol.com header.s=a2048 header.b=igjsmRk2; 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 t13si7015340plo.287.2019.08.17.18.51.10; Sat, 17 Aug 2019 18:51:25 -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=igjsmRk2; 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 S1726565AbfHRBsv (ORCPT + 99 others); Sat, 17 Aug 2019 21:48:51 -0400 Received: from sonic316-55.consmr.mail.gq1.yahoo.com ([98.137.69.31]:33865 "EHLO sonic316-55.consmr.mail.gq1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726386AbfHRBsu (ORCPT ); Sat, 17 Aug 2019 21:48:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1566092929; bh=3z4YsL7cITdwo3WfgBzjdtBKxHfbzIYd54Y/QXXxpig=; h=From:To:Cc:Subject:Date:From:Subject; b=igjsmRk2B/VVMaIiwk6KZFJ2xs+vdkB0aTsEmbInOb3+X4jBeC3xc5GWN/bnYJeQ/3ugotsaMLuXLDNSVDW+RsZ2xQgJ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VQVkCeYTNfj1KZGNpnX5RmlfEoFlR9c7Jrbx6pXc2JJ7RErzQl2xsksY0K2tYk4BVQAi91H58kB rqWHIU7t.HGxJ_N.pEl0WioD4aL8DBXT.FbVCgwshCkp6pq4x8ImtDz1dbjfK_YyzmSq7SIceAID rZV..yrIopk0c4z9QIcARAA.ZGj22.MtATeg9iPC_2yZrqKjxjFe_AmWpFgelDKBXi17BIS81zQw PeZKoDaI9SN4GuyvVJ1Ekr9jNxBI26HwJd8MhuWLcVMqTixd.dIgLodiZL3qJVFz0K10HOyK_ZEd 1ohHBW4Vp9giHb3d5q1MZz.vXv_.nB9pUtSEwjGH9F_wVZqArmt2TRjo28N6hvCHtfKhl98bQioN JdIpEhf4lkn3XK.LbY0C.083i3brSpG3uyhB13CP6rEgBw0NUkyu5eoKmvy7VSMnWKrJvMc2liSv czKCr_7IpTwBhZUpzVapYwwMr00Y06wwZqzc- Received: from sonic.gate.mail.ne1.yahoo.com by sonic316.consmr.mail.gq1.yahoo.com with HTTP; Sun, 18 Aug 2019 01:48:49 +0000 Received: by smtp411.mail.gq1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID be81c6d863eaec55ce60d29fea3fc0a8; Sun, 18 Aug 2019 01:48:44 +0000 (UTC) From: Gao Xiang To: Chao Yu , Richard Weinberger , Greg Kroah-Hartman , devel@driverdev.osuosl.org, linux-fsdevel@vger.kernel.org Cc: LKML , linux-erofs@lists.ozlabs.org, Chao Yu , Miao Xie , Fang Wei , Gao Xiang , stable@vger.kernel.org Subject: [PATCH] staging: erofs: fix an error handling in erofs_readdir() Date: Sun, 18 Aug 2019 09:48:35 +0800 Message-Id: <20190818014835.5874-1-hsiangkao@aol.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gao Xiang Richard observed a forever loop of erofs_read_raw_page() [1] which can be generated by forcely setting ->u.i_blkaddr to 0xdeadbeef (as my understanding block layer can handle access beyond end of device correctly). After digging into that, it seems the problem is highly related with directories and then I found the root cause is an improper error handling in erofs_readdir(). Let's fix it now. [1] https://lore.kernel.org/r/1746679415.68815.1566076790942.JavaMail.zimbra@nod.at/ Reported-by: Richard Weinberger Fixes: 3aa8ec716e52 ("staging: erofs: add directory operations") Cc: # 4.19+ Signed-off-by: Gao Xiang --- Which is based on the following patch as well https://lore.kernel.org/r/20190816071142.8633-1-gaoxiang25@huawei.com/ and https://lore.kernel.org/r/20190817082313.21040-1-hsiangkao@aol.com/ can still be properly applied after this patch. drivers/staging/erofs/dir.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/staging/erofs/dir.c b/drivers/staging/erofs/dir.c index 5f38382637e6..f2d7539589e4 100644 --- a/drivers/staging/erofs/dir.c +++ b/drivers/staging/erofs/dir.c @@ -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; + } de = (struct erofs_dirent *)kmap(dentry_page); -- 2.17.1