From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AECE1C47404 for ; Wed, 9 Oct 2019 13:37:06 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5DA4A20B7C for ; Wed, 9 Oct 2019 13:37:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="hE07pOZW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5DA4A20B7C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-erofs-bounces+linux-erofs=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46pFcw03VRzDqKr for ; Thu, 10 Oct 2019 00:37:04 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=linuxfoundation.org (client-ip=198.145.29.99; helo=mail.kernel.org; envelope-from=gregkh@linuxfoundation.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="hE07pOZW"; dkim-atps=neutral Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46pFcc13BTzDqPv for ; Thu, 10 Oct 2019 00:36:47 +1100 (AEDT) Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4B933218DE; Wed, 9 Oct 2019 13:36:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570628205; bh=xOdjCKE8Z8gKHRU4BTtrEy2NZL8Zx8AERLWZBNmgw0I=; h=Subject:To:Cc:From:Date:In-Reply-To:From; b=hE07pOZWFN4YsrFRPi8tG3VLTik3R2vtag6JBqSzpvvaiKkalRgC1kE0TQgbn1PgO NLqpFfhldo9b7heEltSzyuI+XAp455Q1YVazr3ekUpbvavO9Pu6Gx0/oEfBGS7n1T+ Qmb1ifuDco2+m4kXcu0xH0KhUyWZvWTKndUw81PA= Subject: Patch "staging: erofs: fix an error handling in erofs_readdir()" has been added to the 4.19-stable tree To: 1163995781.68824.1566084358245.JavaMail.zimbra@nod.at, 20190818125457.25906-1-hsiangkao@aol.com, gaoxiang25@huawei.com, gregkh@linuxfoundation.org, linux-erofs@lists.ozlabs.org, miaoxie@huawei.com, richard@nod.at, yuchao0@huawei.com From: Date: Wed, 09 Oct 2019 15:36:23 +0200 In-Reply-To: <20191009101239.195587-1-gaoxiang25@huawei.com> Message-ID: <157062818315284@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit X-stable: commit X-Patchwork-Hint: ignore X-BeenThere: linux-erofs@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development of Linux EROFS file system List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stable-commits@vger.kernel.org Errors-To: linux-erofs-bounces+linux-erofs=archiver.kernel.org@lists.ozlabs.org Sender: "Linux-erofs" This is a note to let you know that I've just added the patch titled staging: erofs: fix an error handling in erofs_readdir() to the 4.19-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: staging-erofs-fix-an-error-handling-in-erofs_readdir.patch and it can be found in the queue-4.19 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >From foo@baz Wed 09 Oct 2019 03:26:06 PM CEST From: Gao Xiang Date: Wed, 9 Oct 2019 18:12:36 +0800 Subject: staging: erofs: fix an error handling in erofs_readdir() To: Greg Kroah-Hartman , , Chao Yu Cc: , Miao Xie , Gao Xiang Message-ID: <20191009101239.195587-1-gaoxiang25@huawei.com> From: Gao Xiang commit acb383f1dcb4f1e79b66d4be3a0b6f519a957b0d upstream. 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+ Reviewed-by: Chao Yu Signed-off-by: Gao Xiang Link: https://lore.kernel.org/r/20190818125457.25906-1-hsiangkao@aol.com [ Gao Xiang: Since earlier kernels don't define EFSCORRUPTED, let's use original error code instead. ] Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/dir.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) --- a/drivers/staging/erofs/dir.c +++ b/drivers/staging/erofs/dir.c @@ -100,8 +100,15 @@ static int erofs_readdir(struct file *f, unsigned nameoff, maxsize; dentry_page = read_mapping_page(mapping, i, NULL); - if (IS_ERR(dentry_page)) - continue; + if (dentry_page == ERR_PTR(-ENOMEM)) { + err = -ENOMEM; + break; + } else 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; + } lock_page(dentry_page); de = (struct erofs_dirent *)kmap(dentry_page); Patches currently in stable-queue which might be from gaoxiang25@huawei.com are queue-4.19/staging-erofs-fix-an-error-handling-in-erofs_readdir.patch queue-4.19/staging-erofs-detect-potential-multiref-due-to-corrupted-images.patch queue-4.19/staging-erofs-some-compressed-cluster-should-be-submitted-for-corrupted-images.patch queue-4.19/staging-erofs-add-two-missing-erofs_workgroup_put-for-corrupted-images.patch