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=-11.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 D68BAC3A589 for ; Wed, 21 Aug 2019 02:17:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A1DF02339E for ; Wed, 21 Aug 2019 02:17:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566353836; bh=SPb61anBmNNrO31lV0Ha7gQ0VGA0tHYwutH3LXcNcDE=; h=Subject:To:From:Date:List-ID:From; b=RYFhwAxDTHYrsz4OPRml1DgFuTqRPlf5CnPhToqR1FAR00gwt4jLxmKGS0fa+5m99 /KUTY8Rb6+gzaXJUzcOHgtfd9nF04QZYKbiBRYuNElfqCkgmEGgAOaRUrQM060q5eD Bko3vlga/5S8GpdnuUrpM9uEUOzajA5q2U/r96Es= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726601AbfHUCRQ (ORCPT ); Tue, 20 Aug 2019 22:17:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:53126 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726512AbfHUCRQ (ORCPT ); Tue, 20 Aug 2019 22:17:16 -0400 Received: from localhost (li1825-44.members.linode.com [172.104.248.44]) (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 0CD3522DA7; Wed, 21 Aug 2019 02:17:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566353835; bh=SPb61anBmNNrO31lV0Ha7gQ0VGA0tHYwutH3LXcNcDE=; h=Subject:To:From:Date:From; b=lMckvq/JgBRbXZzdGE5fdd1NA5kpf8h+KMjsG/pdXgfD69p3N457iU1kTZzfQveyo EByS9TjfgiYWSm5mvZCdZh0FMZcGkqiofBzEzaygibO74kWQNG3j/y3NRHty2rBwn2 YCkdEqZ7D14DOfZ1Y4cyUbfnZ5XJCy6o3mNgOm84= Subject: patch "staging: erofs: fix an error handling in erofs_readdir()" added to staging-testing To: gaoxiang25@huawei.com, gregkh@linuxfoundation.org, richard@nod.at, stable@vger.kernel.org, yuchao0@huawei.com From: Date: Tue, 20 Aug 2019 19:17:02 -0700 Message-ID: <15663538225648@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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 my staging git tree which can be found at git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git in the staging-testing branch. The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.) The patch will be merged to the staging-next branch sometime soon, after it passes testing, and the merge window is open. If you have any questions about this process, please let me know. >From acb383f1dcb4f1e79b66d4be3a0b6f519a957b0d Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Sun, 18 Aug 2019 20:54:57 +0800 Subject: staging: erofs: fix an error handling in erofs_readdir() 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 Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/dir.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/staging/erofs/dir.c b/drivers/staging/erofs/dir.c index 5f38382637e6..77ef856df9f3 100644 --- a/drivers/staging/erofs/dir.c +++ b/drivers/staging/erofs/dir.c @@ -82,8 +82,15 @@ 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 (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 = -EFSCORRUPTED; + break; + } de = (struct erofs_dirent *)kmap(dentry_page); -- 2.23.0