Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2089669ybp; Thu, 10 Oct 2019 02:01:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqx3/sJYTB+toXhQeTDQP6jfbENeUgym+/9ZNxSLYTZ9rohy2sI/D28OU5kopgH8DD7sgAcv X-Received: by 2002:a05:6402:7cc:: with SMTP id u12mr7050467edy.63.1570698070861; Thu, 10 Oct 2019 02:01:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570698070; cv=none; d=google.com; s=arc-20160816; b=XnKB95aLdRhrVb1Src23kju1vnLrYohzlnK2gZj82xnMi6LLXMJGb2CgXayAkyWOT3 JjINlXyLViyQriQaJEEK9xvRELN5jc2LzGgIpP0fXOvdQjsOeKa679KclmKwbjNp9DkT Pf/sv30/5SJRML/ruGJE0KAR+JiB5yrOXmqD54uKj8cW/1LXLmZbFujYLh6GHa1aw0xg viGjq6wjoiv7VCtdzgpMYqlvnTB/lheftMNb6p7vVZ8WrCr2lNLWXoTZ/zWPVLpU9aOn Ujl90jbO3Z8TSeFP88OCVp+k6AxsLFZKasarB1OYMMFOHGmlwtI+2omIUWElal/fTUIn Ai9g== 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=82HrkgCJZ9Dme5HlTeX0P5/m/Dp5zg/QBvfKuLxPqvg=; b=m/vcgza/TCM4foGd9QOrsGM+CF6uk+QwXV2/RLmwI4KChBnc8/maB6yCgyc32vcX1K gHK9t10jI/2O2Y9erB8Rw1t+IobShusE1m4IrCLIqv/pEHXEeYJ8A9c1qWjFjGMXgorz B81dXPCuR3hUt1K5lAxOC3AyBCjMdimtaWb67tVRllSxU58N8/pmzAaaipIUNywO64hJ VqhKhnyjF2SeZ/dIw8boCqlmElbk9WWkB91gQ++ZWY0DmG687Kez/eyt2KKBO54sJ+2v WzdViQR2t8RcCONb6dkpJkEVSamMBlt4DVR9q4aU2M3biQaokGHP1Q1sMi5Cb61sX5F1 qKrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=v4nv8B7E; 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 ga6si2761568ejb.309.2019.10.10.02.00.47; Thu, 10 Oct 2019 02:01:10 -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=v4nv8B7E; 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 S2388869AbfJJIoI (ORCPT + 99 others); Thu, 10 Oct 2019 04:44:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:49148 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388863AbfJJIoG (ORCPT ); Thu, 10 Oct 2019 04:44:06 -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 2B58621D6C; Thu, 10 Oct 2019 08:44:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570697045; bh=SK+ymYoHt8VuP9JTcyD+lBr6qJGjIaD88NCxiqurxLs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v4nv8B7E2XiL5vgoUTWZ+17jiaCzAAzCndvUR0nez28ssr+63AYF4apqIRw8qaMeh bZsUmfRc/iBYeEfqJzyw9ITmW5DDWaZ+ucykRzjAVc33hcykjeSSiQiOslnCTsrOiH 0ND7it/ncXxXJUKkwRHRsfcNjc/imNNDMogWW0mM= 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 147/148] staging: erofs: detect potential multiref due to corrupted images Date: Thu, 10 Oct 2019 10:36:48 +0200 Message-Id: <20191010083621.175170071@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 e12a0ce2fa69798194f3a8628baf6edfbd5c548f upstream. As reported by erofs-utils fuzzer, currently, multiref (ondisk deduplication) hasn't been supported for now, we should forbid it properly. Fixes: 3883a79abd02 ("staging: erofs: introduce VLE decompression support") Cc: # 4.19+ Signed-off-by: Gao Xiang Reviewed-by: Chao Yu Link: https://lore.kernel.org/r/20190821140152.229648-1-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/unzip_vle.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -943,6 +943,7 @@ repeat: for (i = 0; i < nr_pages; ++i) pages[i] = NULL; + err = 0; z_erofs_pagevec_ctor_init(&ctor, Z_EROFS_NR_INLINE_PAGEVECS, work->pagevec, 0); @@ -964,8 +965,17 @@ repeat: pagenr = z_erofs_onlinepage_index(page); DBG_BUGON(pagenr >= nr_pages); - DBG_BUGON(pages[pagenr]); + /* + * currently EROFS doesn't support multiref(dedup), + * so here erroring out one multiref page. + */ + if (pages[pagenr]) { + DBG_BUGON(1); + SetPageError(pages[pagenr]); + z_erofs_onlinepage_endio(pages[pagenr]); + err = -EIO; + } pages[pagenr] = page; } sparsemem_pages = i; @@ -975,7 +985,6 @@ repeat: overlapped = false; compressed_pages = grp->compressed_pages; - err = 0; for (i = 0; i < clusterpages; ++i) { unsigned int pagenr; @@ -999,7 +1008,12 @@ repeat: pagenr = z_erofs_onlinepage_index(page); DBG_BUGON(pagenr >= nr_pages); - DBG_BUGON(pages[pagenr]); + if (pages[pagenr]) { + DBG_BUGON(1); + SetPageError(pages[pagenr]); + z_erofs_onlinepage_endio(pages[pagenr]); + err = -EIO; + } ++sparsemem_pages; pages[pagenr] = page;