Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2077931ybp; Thu, 10 Oct 2019 01:47:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqzny7CFTEjB05wbpMsiWglRohTnKZ/tooMUrrKKIrLNoAwLRXiTZewkdxCU5etIftii1w/Z X-Received: by 2002:a50:c949:: with SMTP id p9mr6874041edh.25.1570697252169; Thu, 10 Oct 2019 01:47:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570697252; cv=none; d=google.com; s=arc-20160816; b=Aid5Mp1CpTM7AoY4kc7kDLCbT+PGJr8diOaYRGgnJiUJpE8nVzJ0UJWeA+CCi7fRnW e5lvDNrYk4RH7st6JZLIThdQeUyvRw/utib9jliaoFN9lmeqK4gQ/RTqRoGH428PfWTY uEjpc+PyM8l/avw4jPhvUJvvHeY7WcCZGpe/b/7L5VXlx2bYiqsKgxRvJKpMSXI1yRkl 4VKEajFL3qNi0thipnNNf5jftjAyov6yKUbqWCTPiaj/PbjXJaLnLfd/wDhlPbj1gKb0 U8n2GwIL0GaUCeUTBsoBSoWmUc1MIfeWJN7vfqbOiU/+itjKnNQ9KcLsQ8/HYnvglfUN 3dHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ml6Plp9Ul85IQqjfIa0IpjAnYFSWh3BZ4WbqunlzP1Q=; b=AQnj3lU4+hEV93LkHkiF7kjgqNCWcybINRC3wiB0M/UOKIjStkMmADW8uOKVVT4JQ3 WvEJQRv3XfomoqzCCnv2+VyvO1MUL+FkK3HnFfqBW+ghKl+fTjTa45/9D4ijcC64qdlQ wcIJYsJslV4ETK/+VFpv/2mgeYctrZBYNLdHFAxXXGZLAhaOyY4pK0sMdMCGw76Pe5f/ yMAV3z8HF/X/wsPI0JBr7emYAp5t5MvUrknRqs2nEsaftaxx7yKEtHYmDyWvFifQMkZb vYsbGilsraScPecBwVrO0dAZSWnxNbLdmD4Lydy99NczfR9xTBE36MM4sKnBP9BmJ3xt VUuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FL+YkWk3; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o32si3012376edc.306.2019.10.10.01.47.08; Thu, 10 Oct 2019 01:47:32 -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=@kernel.org header.s=default header.b=FL+YkWk3; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388860AbfJJIoF (ORCPT + 99 others); Thu, 10 Oct 2019 04:44:05 -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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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;