Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2898047iog; Mon, 27 Jun 2022 05:20:06 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uNiKJgFjpRiBvwVmGwT1DHqjO20y6hBCodFWuo+uGpu/MBVNGd0CILxb+9GzmAz3/5Z6Y7 X-Received: by 2002:a05:6402:94e:b0:437:8d58:4ece with SMTP id h14-20020a056402094e00b004378d584ecemr7481975edz.396.1656332406179; Mon, 27 Jun 2022 05:20:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656332406; cv=none; d=google.com; s=arc-20160816; b=t6T9B+YM+zFDFI4Gv9xxcuvwO84UOnxYCuxa/H6d0ZYwlYivYaWmwq2w9I2DNwdF45 s61Vc2tRT7dFP/SFMwoTTkpcPHEtZESopAHFjHbrh78jkDAsuB2GryGOwtGi16ETzbnh wi7p66yGe3PE8oyTlH9JN9FP5Wa6V1pmYrmLTGxMo80+J1Gdzw8DkEIdovWhpnrad5DN W04MTFJ+72ez1NTxqUAVITq+inh1fVEkFIWtkylQozOm0/kY7GhfRwU5oOCfCyy+JmWc Db4zjmwFtRZ4AXIUcTwZ30GrJ7wJzYlAE2+53SLiZZ3EKhsPJ5xGmAY9AmFCE4NuUuYU 2Rlw== 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=MQuvo+ZxbUqcZTi4Q+mrSHucB5QDGoeRbpdWNUDeKtI=; b=Bw3SeX6/UP+avNtAyY8CdG5kG6l2r3bmEV0i36uc4meI+rfHjrUh7hJKbDeevZGZSR 3xWFSinimoEQtFQ7gXjbWiXj0HOvSrvUKuHqDMcMj7AJoZSQuJbmga82es/uU8zyuFLW aTqbBGDppwCBYOKaLD7PUnGYQIHGQ5zTOfb7Du62Y8mYbaiG4rN8SAEa7CcMcIjc9+zZ opv+Y8/a2pQ2EniUJ9CDNiqSsB4gQ1LzC5nL6x+cq8scU1bVSJdSLdhrbL4vEnyVhw/N zaWoovumkTFQnlpOYcj9ZRhwAB9GYnPkk1e/hXXL6wOrM5m4b0DDjyOekfx6TJkmGURr NqRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=f0wfOTJH; 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 v4-20020a170906380400b00722e5217355si8902200ejc.607.2022.06.27.05.19.41; Mon, 27 Jun 2022 05:20:06 -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=f0wfOTJH; 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 S235304AbiF0L1s (ORCPT + 99 others); Mon, 27 Jun 2022 07:27:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235113AbiF0L0o (ORCPT ); Mon, 27 Jun 2022 07:26:44 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52EC365A6; Mon, 27 Jun 2022 04:26:36 -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 0FC42B81123; Mon, 27 Jun 2022 11:26:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71989C3411D; Mon, 27 Jun 2022 11:26:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656329193; bh=bCFOpgJzUkZpXOO9fqbn2w3haU0B478AXyhf/kDzs8s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f0wfOTJH+E+crnlvf514azPqTZTzD/Or25vZXcsV5LxIaXvSZS2eSPZpkXenRJTER izC1uV+8P/GzPoI9Hy4m5vvmSnsDXusvAXgpJ9efWAUKQMcZOWGKGecjuVtHmgGEKd BaazXsAFnTiRBxayrezPdmxHRTHFa4j5hNf/szJ4= 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.10 044/102] udmabuf: add back sanity check Date: Mon, 27 Jun 2022 13:20:55 +0200 Message-Id: <20220627111934.779829362@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627111933.455024953@linuxfoundation.org> References: <20220627111933.455024953@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 cfbf10128aae..2e3b76519b49 100644 --- a/drivers/dma-buf/udmabuf.c +++ b/drivers/dma-buf/udmabuf.c @@ -26,8 +26,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