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,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 D2DC4C10F14 for ; Thu, 10 Oct 2019 08:59:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A24AF2190F for ; Thu, 10 Oct 2019 08:59:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570697983; bh=hJa2HHgBksaGk4R8Gj8nbpe3jM7W1po2HhE+oN2/xuY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=GbdDmX4nnB1JqY2JKsb54harj49aTWKc4ESqUkpT9lfQtwRIDs4QH5iZ4EQxpjX7u f2F0vUtSRafS+DK9MiDEOHOLmreVY434KN7eZNTDwIou9PuQ/PHJqyWwDqjl0dKEUi 3E6Rht3nO5joZzXGedrB+AzJN3qfsgJp9QE2vXzo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388855AbfJJIoE (ORCPT ); Thu, 10 Oct 2019 04:44:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:49072 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388851AbfJJIoD (ORCPT ); Thu, 10 Oct 2019 04:44:03 -0400 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 4897221D56; Thu, 10 Oct 2019 08:44:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570697042; bh=hJa2HHgBksaGk4R8Gj8nbpe3jM7W1po2HhE+oN2/xuY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FL+YkWk3CDBFCOn/AFMGB/W8r3G9dtqsB9kICO+x3FwNCx09rkaJ98wEiWJypRxTA Lj/Q95mGk6v0Oa+OXmU0DmihVmB+ljAFt3puumVYLBGI27+pt6VhkCynao/P5UGPOx gzWNKE21aApi0ANSBjXWnMGp9DXGZd5DTJTyIyvA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gao Xiang , Chao Yu Subject: [PATCH 5.3 146/148] staging: erofs: avoid endless loop of invalid lookback distance 0 Date: Thu, 10 Oct 2019 10:36:47 +0200 Message-Id: <20191010083621.122456973@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191010083609.660878383@linuxfoundation.org> References: <20191010083609.660878383@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Gao Xiang commit 598bb8913d015150b7734b55443c0e53e7189fc7 upstream. As reported by erofs-utils fuzzer, Lookback distance should be a positive number, so it should be actually looked back rather than spinning. Fixes: 02827e1796b3 ("staging: erofs: add erofs_map_blocks_iter") Cc: # 4.19+ Signed-off-by: Gao Xiang Reviewed-by: Chao Yu Link: https://lore.kernel.org/r/20190819103426.87579-7-gaoxiang25@huawei.com [ Gao Xiang: Since earlier kernels don't define EFSCORRUPTED, let's use EIO instead. ] Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/zmap.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/drivers/staging/erofs/zmap.c +++ b/drivers/staging/erofs/zmap.c @@ -350,6 +350,12 @@ static int vle_extent_lookback(struct z_ switch (m->type) { case Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD: + if (!m->delta[0]) { + errln("invalid lookback distance 0 at nid %llu", + vi->nid); + DBG_BUGON(1); + return -EIO; + } return vle_extent_lookback(m, m->delta[0]); case Z_EROFS_VLE_CLUSTER_TYPE_PLAIN: map->m_flags &= ~EROFS_MAP_ZIPPED;