Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1075246pxy; Thu, 22 Apr 2021 22:41:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDiY3HhDfjxRpn66y2nhFHq1hsW84ZPYBt3H+2ejbd2FhAgF2P4+FuKnucYSbyPV4Lru9C X-Received: by 2002:a62:2a14:0:b029:263:20c5:6d8c with SMTP id q20-20020a622a140000b029026320c56d8cmr2429908pfq.23.1619156516628; Thu, 22 Apr 2021 22:41:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619156516; cv=none; d=google.com; s=arc-20160816; b=BAVUqEKUWBAvlRXNb8DYKrI9qxlTJeee/iw1kDZaXzdoX8v48WbFf4manrNc0FlKn5 LRULzaAgj6OXr2ZV6BknFbII+/giOmCx1a8bGHilxaeiPNacqAQtsvoi+IUcyykFACKa 7q9C7CpH/nP5UroNYo2kxGaFOxZtjf1OXPvGuE+PKJTIEeUacw5lrUIkTqnukvu3Je8I JRPgBrTsLqq/XInkrXOix159PdYgu9LPCPc48N/cthH2qEbN4cOVgP2xoL22QNQmEYIK BF90ipH4TYFtgomns4EX9YQm0wV1jokI35WBJdSwK7VilyEasWxjei6T83YrV8c2+a04 NMNQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=NZgPMke49PfmASyT+K1h7cCq8emc+deK1BAEsqWaEPw=; b=Ujmrt5fVYTCnWTHGLvHAbKiZolWvmFzKCDN1DyE2hMg04p1KWC1LtvC+B6BHExRrNT iIYsyFel8sx2EgSmZ8h+Ju5Se3Pkdg5lROQBGfRRN33KQ1v5S6mVF7I9LEspGy4Wu0/a KEKeKSC9UyK1WAAYyRGVjn631eNSag1QM5FTnMOccKBB4zTg6nNJcQ9Y4OElWU8gnXkg x+U0J6xNJfcl8CTmhUn38IS+SHwe7ESerq0BfU1rs4DzzqBvNtUXj2Z35Gzt7UFtki4R ZNmR84JBHrlWKPOJ7m2I2e8e+4s/XDR6qXCWBbVyFo2yC5Wr7w5cGcY2XLwhk4mQa/V1 c30A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=nTAr2IN5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jc24si5553688pjb.95.2021.04.22.22.41.44; Thu, 22 Apr 2021 22:41:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=nTAr2IN5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235684AbhDWFlS (ORCPT + 99 others); Fri, 23 Apr 2021 01:41:18 -0400 Received: from mx2.suse.de ([195.135.220.15]:47056 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229456AbhDWFlR (ORCPT ); Fri, 23 Apr 2021 01:41:17 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1619156440; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=NZgPMke49PfmASyT+K1h7cCq8emc+deK1BAEsqWaEPw=; b=nTAr2IN5DBYPkCFqqq+eLwiXMbbGmun0odKrA+jJl9NkITBehpkoRHRYzfVNtvBzmoeuIx uYmVjrOyOHPTYfbyo4bnoAYOUgajPgFeLwqQQW5KmbeogJnwctPoA7R3s8xLQFI1UgkAWo bsa7Mo+q2jzxdBaftOmifhikTfSdt7I= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 900A8AEFF; Fri, 23 Apr 2021 05:40:40 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Boris Ostrovsky , Stefano Stabellini , stable@vger.kernel.org, =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Subject: [PATCH] xen/gntdev: fix gntdev_mmap() error exit path Date: Fri, 23 Apr 2021 07:40:38 +0200 Message-Id: <20210423054038.26696-1-jgross@suse.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit d3eeb1d77c5d0af ("xen/gntdev: use mmu_interval_notifier_insert") introduced an error in gntdev_mmap(): in case the call of mmu_interval_notifier_insert_locked() fails the exit path should not call mmu_interval_notifier_remove(), as this might result in NULL dereferences. One reason for failure is e.g. a signal pending for the running process. Fixes: d3eeb1d77c5d0af ("xen/gntdev: use mmu_interval_notifier_insert") Cc: stable@vger.kernel.org Reported-by: Marek Marczykowski-Górecki Tested-by: Marek Marczykowski-Górecki Signed-off-by: Juergen Gross --- drivers/xen/gntdev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c index f01d58c7a042..a3e7be96527d 100644 --- a/drivers/xen/gntdev.c +++ b/drivers/xen/gntdev.c @@ -1017,8 +1017,10 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma) err = mmu_interval_notifier_insert_locked( &map->notifier, vma->vm_mm, vma->vm_start, vma->vm_end - vma->vm_start, &gntdev_mmu_ops); - if (err) + if (err) { + map->vma = NULL; goto out_unlock_put; + } } mutex_unlock(&priv->lock); -- 2.26.2