Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp173637pxj; Tue, 18 May 2021 00:17:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvteE0H82JevCSj4xMvhKio9UWaF61Y1rFEzUfd533TiD/vvJ3zMis+R5enUooG8DwZkxS X-Received: by 2002:a92:c90c:: with SMTP id t12mr2888354ilp.289.1621322238075; Tue, 18 May 2021 00:17:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621322238; cv=none; d=google.com; s=arc-20160816; b=BFIQTeIGbKbjJrKM8REKZ09a/hi08qToZbT7yGQ61vLjC/Oos6gT9Oohpn5jkAr99A 2u3mVBc/qMRMG6uAPW4JUZn1Jqof7B4g8N7/4IbeH8QNfYc8EaomvS0oneKeoKveMfWZ jZcCXy0DWWIsgS8IezuZRQrbTsQLI2uFTIVLARDwXe3R7/SWKuiyA4xfxXRMrWeVPsUH pkE/eekX0NPONSBSISRuRJQM4pRJ/KzV+y5rM92Zz/NlMQ0qfTa9E/5We10fmEMIBon9 DIxNv+3IGUO2YVzPnCBzhL/oOS1xcokvznj9RETBOHawAci0lZZHFXIOThC3ep18XUFe E8Mw== 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=ZjThzdKgZLExXRVCNZAo0zJDd3ZOCL+haH0iNx7/YSk=; b=wOrTsttQA+6eztDX87JIMbLjidxPtRdTG2zDnIT94K330luYzzxQRojiwUf6eS8nkG rF5haEx1mka6B6dIOB0OS+VhGAZWx80OPUMIJHK3UivAOhUiFkaCpyLgIT45tU/nb4u8 wikWvyeT2wM6aLbicEnziWENwVRW7LQ+1upA2FBAujtYRwUJcG7yWqUHm+2TtY5HQMq3 d5iRaNr0Ztne7jvpAv5qifirCJl4+b1i7iNf1P8uucVhYPoqT6WdC3IgulgaLA2Ml42K 9aeODanMkv9u3Jp1iLCvRwXzndhDwSE7WxX2L3C/HHBNaZ5JFogH3Zpe3kIiSudxlKl0 5RKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PrgZp24x; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o1si22466882jat.48.2021.05.18.00.17.05; Tue, 18 May 2021 00:17:18 -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=@linuxfoundation.org header.s=korg header.b=PrgZp24x; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241806AbhEQOx7 (ORCPT + 99 others); Mon, 17 May 2021 10:53:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:55126 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241647AbhEQOp3 (ORCPT ); Mon, 17 May 2021 10:45:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1BFD561440; Mon, 17 May 2021 14:21:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621261273; bh=Is8OxNsjNOkEUi+gUor6UWCFo2QHKvWzWvcSdbrn2VY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PrgZp24x5MHrA6fspinmlQ1kd59mRyEi93JPvG25tDMU6YvKVDFIIsJu76kjjrCId Kuwxt1zuXGOy3EKn+CIhKYQCqGIOYx48gbqEtFZnG4q9+2jOzCazDpNSatqHc6ZsoT GJN/W9Ba1gaN30KvPE2OzuRRBXnsN1EW1Yxe8xxo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Juergen Gross , Luca Fancellu Subject: [PATCH 5.12 328/363] xen/gntdev: fix gntdev_mmap() error exit path Date: Mon, 17 May 2021 16:03:14 +0200 Message-Id: <20210517140313.699956963@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Juergen Gross commit 970655aa9b42461f8394e4457307005bdeee14d9 upstream. 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 Reviewed-by: Luca Fancellu Link: https://lore.kernel.org/r/20210423054038.26696-1-jgross@suse.com Signed-off-by: Juergen Gross Signed-off-by: Greg Kroah-Hartman --- drivers/xen/gntdev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/xen/gntdev.c +++ b/drivers/xen/gntdev.c @@ -1017,8 +1017,10 @@ static int gntdev_mmap(struct file *flip 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);