Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1102497ybl; Sat, 17 Aug 2019 18:58:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqzowVSR7TYC2VaE/7elOKVi/kckzWr6BEwCrTMLnbekzpQFmgl23dBMYerVSjaYcv2prkjk X-Received: by 2002:a63:1a01:: with SMTP id a1mr5711661pga.101.1566093486274; Sat, 17 Aug 2019 18:58:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566093486; cv=none; d=google.com; s=arc-20160816; b=f05O+vOG1E6jtZtWjidhqgkNOcsBy2k/cXoJbkRVR6kJDZtPgUNGnnRlZDtcO/i2D7 yJtzVc79r5v92m45V+jX4zuBkOf/4BiwaoA9PS/M85kNDZmkRaIGsYk6oVG8IxqPZCZ5 fGYpGCjfm7CAWhLcGHdtyUvy8BuOqcJ3dzypPkI40g8TMu+CyWkN1wgMbjL142msmx7N Ix02L3Zx0LOTnK9GKciz303/LaubibStoIb6rXsmKeUSGJ3MMesQ2f2BKdzNSWQKTJeC p5mn2laJkfIBkATuS141m2lMFmKCy857oEmrF2khHAcT6c4E7msnS9N4hXdr1qapD9KG nL8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=7wiUkSJ86VOkepGAHwVEnii71cs817iuqxjlV0yqVSI=; b=c22c/LaCrBrvapldkzVu0sBOe6c6YBwnTBctzIRoCPvYKBaalQjK9JCCS+vzQRSNk6 vAoA5ykC7jCudnIIzilfvs2PnyldvUqXlBDTV2XBXJC2FPqf/m6j6ZyPOsAAenz+pFqm 0rrrXVyzNTqbedJNpVEfMez32Nwq6SuTEP4kmW83MOetlCKmU47RztseYaOph4boAnBD rw3WloH/biG+XSVHUPsLfA0vOowQ3XpuTG8ioNS79ZDcVxr98wrNRp/d/5dHhbw9OeYT 50Tstn0Hg3aKbPC2ImIWDPyqMMZ50z+8egZ245qEG2PDF20kIiJcvvlarA7kuOCUjjVZ 9poA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aol.com header.s=a2048 header.b=FDBsDJtF; 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 83si6903968pgc.207.2019.08.17.18.57.50; Sat, 17 Aug 2019 18:58:06 -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=FDBsDJtF; 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 S1726437AbfHRB4u (ORCPT + 99 others); Sat, 17 Aug 2019 21:56:50 -0400 Received: from sonic304-25.consmr.mail.gq1.yahoo.com ([98.137.68.206]:38481 "EHLO sonic304-25.consmr.mail.gq1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726384AbfHRB4u (ORCPT ); Sat, 17 Aug 2019 21:56:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1566093409; bh=7wiUkSJ86VOkepGAHwVEnii71cs817iuqxjlV0yqVSI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject; b=FDBsDJtFmpH6IxQ95s6Y2j7LEJfa7aYx/EMpcGvZF9zphoQws5ULRsVy4QkPwrIusdR5nXgYEGOpiNh5N5cHWbJNE7G3iuDHQc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OK.2gh3J3lj8ID 37PQ3JR4OUpHX9G7gaHQl3AlvorBOucrh7EGLC0ZAIXDxIIvKQ8ZqG5NI2_x22eH.iHmxI2UDQ2J OjtaVK_xXKt0aHtssYJf9tPef.qi6kWA3SG996s17I9.L5146dBl4alPX1HpNv6xZllK1ZyKsjGq UAelQSKTpVwbcbRP5oQpLoFhUQDRRoOorfmzrzsQ2lTLsyRpowvGbsHz_4uXUCNyW_cdNKZ1mtzc fLyv6bhXbwLojuwFoGJ5pMrH9FbVI91iKck5_CfT_Ybv0dpWvRjwyW6EAH4Y50vRYckvRZezbFOc JqncKTaufWjwEJscFJ2fdmg1qra_vMD7zK8Ryl_eF6dmmfUTp3M8ME80ye13VBtP55bvZpgdF0ba OmaNrQSRJjnqrQ9bpkgAbP8rFismYDtVPajt1ju8oKUyUJRCJh6J1WwGVBV27ECLACqJi7dn0m15 M5nclAMo0jmUWAd.TSKOpQTRO357B35sVEw-- Received: from sonic.gate.mail.ne1.yahoo.com by sonic304.consmr.mail.gq1.yahoo.com with HTTP; Sun, 18 Aug 2019 01:56:49 +0000 Received: by smtp409.mail.gq1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID ede1d329074793b6a6ac0c38eeffc50c; Sun, 18 Aug 2019 01:56:47 +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 v2] staging: erofs: fix an error handling in erofs_readdir() Date: Sun, 18 Aug 2019 09:56:31 +0800 Message-Id: <20190818015631.6982-1-hsiangkao@aol.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190818014835.5874-1-hsiangkao@aol.com> References: <20190818014835.5874-1-hsiangkao@aol.com> 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/1163995781.68824.1566084358245.JavaMail.zimbra@nod.at/ Reported-by: Richard Weinberger Fixes: 3aa8ec716e52 ("staging: erofs: add directory operations") Cc: # 4.19+ Signed-off-by: Gao Xiang --- changelog from v1: - fix the incorrect external link in commit message. This patch 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