Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp648552pxj; Tue, 18 May 2021 11:00:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygxOh/ix1pwuTTjYEwFRJDLer0G8U3qSva4CwkLJhzl0OYiJu2bu3aDlrt7UuE+0daMqyo X-Received: by 2002:a92:c7a6:: with SMTP id f6mr5433631ilk.17.1621360832853; Tue, 18 May 2021 11:00:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621360832; cv=none; d=google.com; s=arc-20160816; b=izx52qXQJr8AIjZPzBHo6Tvz0FVkSt65oRgQ3zI8KJ3tgS8OjMT4PoljWjzS8qsptJ vpPJ7s2a5pEUgKUn4bLU7mC5j0Uuk0jyW+XluXSE4onynGifmXUfgjiRS28AC5yNOhx6 8GknFNHL3JB62dDhbSVUEOT7Ti5Gi/EKuJWwOjyjBSxp8dmv9YQru/pWu4dNmtB4SkGQ f0jTW01V4GfdcQch8tAXamZ9+PPiQIDY0o1Zgl0mU4d4kKUKnUMH92w59XdT/pGqjOmx SxZyN+ZwsnZ/WMvf3ob5J/ePc+gZLrxsV27tXZA93EyriBwqzR799aaQGVkVdbiLAhKC FEUw== 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=aR7pdcX+V6RWQezEItA5d6j31oGjpM9mvkkHlWWcb8I=; b=ZlsrpmvJiZkPkfSKTY9wtlV4o513dR0ldIWZLH7/HCaMnKYRdH/pBUlSzGfa1IaN2Q Fjgh46ABvJmKv8DHBftURZLW7x+we6agDk/G6CgPHKZf/jZkskx6DRCPqdAEzEsGs8NE ULsBVJCHdERVk+iCuHhz/uQvs+JoYUFOMy7/G7kKZNXvTmlYp99G4I8Vcwka68PJoXtQ Hkm/+49h+Rh4dqKpVZal7mqR+2ynkn0MNFA3vAFYwuUAj6lEsHznTYErUfIZMsne2s82 c/OcVpnRVj3ZPTYiSa8+GYBgEvUR+SPsVYVWBw30eLxd3jMWvx5sgqnmxAAJ+AjiQZZB +hVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EACZDyIa; 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 j10si10517417ilk.31.2021.05.18.11.00.19; Tue, 18 May 2021 11:00:32 -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=EACZDyIa; 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 S1346946AbhEQQKk (ORCPT + 99 others); Mon, 17 May 2021 12:10:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:36438 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245560AbhEQPqf (ORCPT ); Mon, 17 May 2021 11:46:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 08C5461D36; Mon, 17 May 2021 14:44:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621262672; bh=LFIUclFMsfiLUsrfN44xqGsqkeryLjlmO8+A8VFMcnc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EACZDyIauegCLL1ydZqAvY8yU0L64WfYr46vrmz6M3AhJflBxotl01iDFCs21tlAz 6qAZL3SGtiQMFIkY9d3zQEhCZqknx/I877f7aEItuRvXWLp8vzDiwjT264UiLAB9as T78uxNQi1nuQGQqvabP9C5R5D/yKTohrXjHWFRBU= 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.10 255/289] xen/gntdev: fix gntdev_mmap() error exit path Date: Mon, 17 May 2021 16:03:00 +0200 Message-Id: <20210517140313.732166062@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@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 @@ -1005,8 +1005,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);