Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2904086iog; Mon, 27 Jun 2022 05:27:56 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sFha6DoNCHozDCDBMbxdo8fCl5dlRqiq2zwoZD00eakjoU1ljuEiKk4AxXJ9Vw0H+nULpb X-Received: by 2002:a63:709:0:b0:40d:beed:cae1 with SMTP id 9-20020a630709000000b0040dbeedcae1mr9809266pgh.389.1656332876043; Mon, 27 Jun 2022 05:27:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656332876; cv=none; d=google.com; s=arc-20160816; b=0TYllOiSPk8akdIH6tZLGi8I44KWk4snxkrwTqZQrrEE432D4T0r+SG3h1GEbC2kHT v5Qbp3tmV4QIz3enMC44clrpQ6YdpO2dibFvHGDj3Mmrz7RaeGbijGr6K7Fs8BekO+qB ZcgzmWaW0KhdXfDaH5O1zbVdCgFnAxsSiAkGSsXDkR2DFnOw43IRnwmF0g3jRt0F9lMb ZiwWOh7FqdYRPGOyMnXpg4J2zKKBfxEx4cX8rNO7KXbJnp/nGIurZAZgdIEfvu6CNXaK 19/gZH4UGe9GSJXByW+hSTXISNVEq93omh3YhdjdpBND4rm3HndqFTb1EjpfNqZGvPiz e7Ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rUP7liHhNVc20Y1o/dvZ7o8x+JrBekHAh0uruaJoX7w=; b=umy/8TrziLCtlfdxrd2UNQAbzBKOioq8ps7Wp7+xb/Jr6Tt8vRGtPh6wc5feEJXZJj AD70blbj/a1Nu9g+TGDL0GmSHg3nm+lMJPR6pHiKqdT67TorUQIkpn9T+rtSdETdebKl 5QVyOGivuR5n/pacAgtfrZeFzf0iE+ShZ61yDokKj+LUJCV5Cwg5eWqBl5EWWF5+ev+D lvviEvYJLD06lMhfRkxSLvgT3eUAqNV70Gf7kKlVCPRrGf09MOV0/NkoBV7xan6wfbCz 6DWnZHO+auRRO6Hh9HrJGTI7tovQXE0eRqt60PgYE3gCSQ/94TscOh6/Sj7/4suQBJXe Fj0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pIV2Jxwi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h4-20020a056a001a4400b0051b51d8211fsi15215647pfv.91.2022.06.27.05.27.44; Mon, 27 Jun 2022 05:27:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pIV2Jxwi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235241AbiF0Lb4 (ORCPT + 99 others); Mon, 27 Jun 2022 07:31:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235396AbiF0LbX (ORCPT ); Mon, 27 Jun 2022 07:31:23 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04E76DDF; Mon, 27 Jun 2022 04:28:56 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 858F8B81120; Mon, 27 Jun 2022 11:28:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC595C3411D; Mon, 27 Jun 2022 11:28:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656329334; bh=Ijmwv+syevkvdt93fWVqN1GeiV0joTO4w7doeUlDHqw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pIV2JxwihspDQNFvVGR89JhLpEd2tW8Z74Bo+uQRudYJ9QZH5l94/qU+1RX+xeagr T06b3FuHSanXkExAzQcnatQJRPyPe/k/M13UBvcMSYFy7NBpow0BpnFGwUqS8yGwJ+ JubN0gBKqSogqAAt/vDxjuSfD8mfXJZL97s1YHS4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, zdi-disclosures@trendmicro.com, Linus Torvalds , Gerd Hoffmann , Linus Torvalds , Sasha Levin Subject: [PATCH 5.4 24/60] udmabuf: add back sanity check Date: Mon, 27 Jun 2022 13:21:35 +0200 Message-Id: <20220627111928.376754235@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627111927.641837068@linuxfoundation.org> References: <20220627111927.641837068@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gerd Hoffmann [ Upstream commit 05b252cccb2e5c3f56119d25de684b4f810ba40a ] Check vm_fault->pgoff before using it. When we removed the warning, we also removed the check. Fixes: 7b26e4e2119d ("udmabuf: drop WARN_ON() check.") Reported-by: zdi-disclosures@trendmicro.com Suggested-by: Linus Torvalds Signed-off-by: Gerd Hoffmann Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- drivers/dma-buf/udmabuf.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c index e553c6a937f6..c6e9b7bd7618 100644 --- a/drivers/dma-buf/udmabuf.c +++ b/drivers/dma-buf/udmabuf.c @@ -24,8 +24,11 @@ static vm_fault_t udmabuf_vm_fault(struct vm_fault *vmf) { struct vm_area_struct *vma = vmf->vma; struct udmabuf *ubuf = vma->vm_private_data; + pgoff_t pgoff = vmf->pgoff; - vmf->page = ubuf->pages[vmf->pgoff]; + if (pgoff >= ubuf->pagecount) + return VM_FAULT_SIGBUS; + vmf->page = ubuf->pages[pgoff]; get_page(vmf->page); return 0; } -- 2.35.1