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=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, 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 91F1AC10F14 for ; Thu, 3 Oct 2019 10:07:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 666752086A for ; Thu, 3 Oct 2019 10:07:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570097233; bh=IGi3PTcyZPRM9OFYkzF0tcaQVyhOCfOFfZLypSRrrVM=; h=Subject:To:Cc:From:Date:List-ID:From; b=pKIfKLwJnzxmW0ucwqRN4gnvb5z3v5Krmr0ccNc6qcw1Bq5WrajLRe91bvp3RotzJ YoxGIlxkR8+xTxSXcIom4NfocgYFqsb6qu/s1OIW1XpnxvQCDFg7Di17tPHY9Jl92f 17heLDqwcqOaGwIy/ivxr3tcbDL7mW8AusKOETSA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726472AbfJCKHM (ORCPT ); Thu, 3 Oct 2019 06:07:12 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:45071 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725892AbfJCKHM (ORCPT ); Thu, 3 Oct 2019 06:07:12 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id E961521B6A; Thu, 3 Oct 2019 06:07:11 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 03 Oct 2019 06:07:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=Ob5XsY DXQEf4yERqQyX3eu6NG5p6Eom0FQ0zOs+XZGI=; b=lyuXm2lziqZBPfTsrnskWR wFoLC1CsBSivsP7CUm2Q34sfBTyD/WNU5n/ZqQIcKnMXelHX7Pz9hxd99z4+XmYB uz/JYjLSptWw2j2O8COoIg1spjYk0Z4vMnhcGwj+vxHhK7ws8f/65EvoNwhlUMeK z0zC+KlOjIeBa8iNdFr+rKjvmYRIAwSuTVc5J7gNSq35SCSufVBx8KHnBwxX7OZu fPutC3EuMZop4JyoXh3mJtSBmc2eY0Vki+EC09wHMoaQ9GweVadJ9mADgD3JNCal sdtDNs6oHIf/zEyxhnxOGavju/SS+qz27ClOGve9thP2cVFTupPCFVOI9zGuK7Xg == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrgeekgddvfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepuffvhfffkfggtgfgsehtkeertddttd flnecuhfhrohhmpeeoghhrvghgkhhhsehlihhnuhigfhhouhhnuggrthhiohhnrdhorhhg qeenucffohhmrghinhepkhgvrhhnvghlrdhorhhgnecukfhppeekfedrkeeirdekledrud dtjeenucfrrghrrghmpehmrghilhhfrhhomhepghhrvghgsehkrhhorghhrdgtohhmnecu vehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) by mail.messagingengine.com (Postfix) with ESMTPA id CC7888005A; Thu, 3 Oct 2019 06:07:10 -0400 (EDT) Subject: FAILED: patch "[PATCH] staging: erofs: fix an error handling in erofs_readdir()" failed to apply to 5.2-stable tree To: gaoxiang25@huawei.com, gregkh@linuxfoundation.org, richard@nod.at, stable@vger.kernel.org, yuchao0@huawei.com Cc: From: Date: Thu, 03 Oct 2019 12:07:07 +0200 Message-ID: <157009722768242@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 The patch below does not apply to the 5.2-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From acb383f1dcb4f1e79b66d4be3a0b6f519a957b0d Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Sun, 18 Aug 2019 20:54:57 +0800 Subject: [PATCH] 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 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);