From patchwork Fri Mar 22 06:41:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 10865025 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CFF8315AC for ; Fri, 22 Mar 2019 06:41:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5DCA2A4E8 for ; Fri, 22 Mar 2019 06:41:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA3022A4EC; Fri, 22 Mar 2019 06:41:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 638962A4E8 for ; Fri, 22 Mar 2019 06:41:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2E9E86E252; Fri, 22 Mar 2019 06:41:53 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) by gabe.freedesktop.org (Postfix) with ESMTPS id 045A66E252 for ; Fri, 22 Mar 2019 06:41:51 +0000 (UTC) Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x2M6dN1E141367; Fri, 22 Mar 2019 06:41:39 GMT Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2120.oracle.com with ESMTP id 2r8ssrv3uk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Mar 2019 06:41:39 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x2M6fcIT029630 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Mar 2019 06:41:38 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x2M6fYL7005932; Fri, 22 Mar 2019 06:41:35 GMT Received: from kadam (/41.202.241.45) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 21 Mar 2019 23:41:33 -0700 Date: Fri, 22 Mar 2019 09:41:25 +0300 From: Dan Carpenter To: Maarten Lankhorst , Noralf =?iso-8859-1?q?Tr=F8nnes?= Subject: [PATCH] drm: shmem: Off by one in drm_gem_shmem_fault() Message-ID: <20190322064125.GA12551@kadam> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9202 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=848 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903220051 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2018-07-02; bh=r0SH2XQkaMnppGiwnreuow0JbMWDHZBX19YO5XY89Oc=; b=IlEzmrbhMUMC95CIrgrTsmvYUyG3Oa6aPHUEmuL5Z/EzBv3gAAe/Dcfo0x7tcDdovLRm tiFmqfkxEc3dhotKmNF3q3BEWbFonqoBDvkdDLBCN59Jn0aI74fUT22NUsetq2z0/GC9 e0GytgQgFDnA/6PiWaD7aCFlDepYC1/fvF5MEf6LLsdMZ8nD4vzhAb5hDluhIpLWTLcj gWbwJk+lOzr9+utK1s6ZhYKEfJbu6xrHwyvII0QA6GDEDIZkLD/jZE6RiHbRuDzPmtip lecIuHPtTMuyGijc3Shakbj4tLu1QBlth6p8PPyNXW4STiG6T1o9oQnxEvK07MEUp2eh tQ== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , kernel-janitors@vger.kernel.org, dri-devel@lists.freedesktop.org, David Airlie , Sean Paul Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP The shmem->pages[] array has "num_pages" elements so the > should be >= to prevent reading beyond the end of the array. The shmem->pages[] array is allocated in drm_gem_shmem_prime_import_sg_table(). Fixes: 2194a63a818d ("drm: Add library for shmem backed GEM objects") Signed-off-by: Dan Carpenter --- drivers/gpu/drm/drm_gem_shmem_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c index 3750a982aaf6..1ee208c2c85e 100644 --- a/drivers/gpu/drm/drm_gem_shmem_helper.c +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c @@ -408,7 +408,7 @@ static vm_fault_t drm_gem_shmem_fault(struct vm_fault *vmf) loff_t num_pages = obj->size >> PAGE_SHIFT; struct page *page; - if (vmf->pgoff > num_pages || WARN_ON_ONCE(!shmem->pages)) + if (vmf->pgoff >= num_pages || WARN_ON_ONCE(!shmem->pages)) return VM_FAULT_SIGBUS; page = shmem->pages[vmf->pgoff];