Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2473397pxj; Mon, 10 May 2021 03:59:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNa4OPXlxsh4x20TSZAJzvHqYFsjO0YSxwBPQgdk7XNJ7vF+MmgqdFBwbKa89ETWUYi+Vh X-Received: by 2002:a05:6638:138e:: with SMTP id w14mr2762015jad.33.1620644259558; Mon, 10 May 2021 03:57:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620644259; cv=none; d=google.com; s=arc-20160816; b=ialJicu+XRP86QFrvWqWYxoYCk3+AYaUganMvP0UPPxy/Sjw3oxjq5HsAXWS0I31Q+ 5Sp0YIpUXZuxA6iFp2wzkHpNCNWktJXr6R3/YRhVd2OIHJf7EiAac9+yaMeCIBuv43vS bTFBmTA7vsmOZFX80BBYIYVG5zDmHUICEZ3ydYMXqT9lBO1lNu1JvimyQ/yEcpGmj3s8 hOUOXwzvkjfF/KH26ZJEfN4m4+Ba+LL7Jn0VgN6TC1oDyk7cDFGklPyfv9DWVhNuJ9EL cHGX3ZM823U1E6FDGjO/T6VfV95bYzMB3VfYwKtg5O6g2ohkq7nbziiRpoRZDV0NHn3T GvFQ== 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=rw41ekcpQDxv7p+cfB2yjDNh4aPcyAOX/OhBl9vhvRk=; b=Ht6Z2zaKDD82KQ4F5Ig2KAXIvnGoA3pGQOJmW3YwcEpiGM+1j+yhmMouV7J7bTUG5F SUiGgz0tb5rLAvRcJ9YfvIi8dQbRnxI8os98YZ1//4w12NexsXcSJrxSatAGuy9rUqnM KCS2Cl1odtDUk9wBSInKcNV02gALv33GYQ7LBC7papBvhoKkY0E09X115pl0vHYBV07h WP3YPtvSYPr1vHz9sohjXyHd1ZpP5OfK61oKBN8omLz8+Fkq5BdZ2IUPOrH9gGie+spK AAbOV2nCpGKVmhLup58XWV5qhCIJUwW013mN7mbcL1pkEGrIbmMBQ+JFIWXv5NkENCWf TjuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2s4oHRXn; 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 o8si15170136ilu.133.2021.05.10.03.57.27; Mon, 10 May 2021 03:57:39 -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=2s4oHRXn; 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 S231902AbhEJKxH (ORCPT + 99 others); Mon, 10 May 2021 06:53:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:48982 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232288AbhEJKmW (ORCPT ); Mon, 10 May 2021 06:42:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D2E806197C; Mon, 10 May 2021 10:32:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620642749; bh=TbOoaBNl6TT1mxUu9K5JxcdmPXH/Jfwogsx/lXYDgzg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2s4oHRXnr+7XwstC2t3kTleYOI5NNkr52s61SWiTzwTzWwPugqFzFa+GibuC4FLJ6 GfT3r1vJcXKYKaSuCbBZm/hRXqgXYqcrj8B05kCSJRw9DFAdLvPCsB9L5vD5kkDXe8 fa29xh9cinmpWfQx10YTVtynjaDV4yp7Adckr2Sg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jason Wang , "Michael S. Tsirkin" Subject: [PATCH 5.10 008/299] vhost-vdpa: fix vm_flags for virtqueue doorbell mapping Date: Mon, 10 May 2021 12:16:45 +0200 Message-Id: <20210510102005.108590635@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@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: Jason Wang commit 3a3e0fad16d40a2aa68ddf7eea4acdf48b22dd44 upstream. The virtqueue doorbell is usually implemented via registeres but we don't provide the necessary vma->flags like VM_PFNMAP. This may cause several issues e.g when userspace tries to map the doorbell via vhost IOTLB, kernel may panic due to the page is not backed by page structure. This patch fixes this by setting the necessary vm_flags. With this patch, try to map doorbell via IOTLB will fail with bad address. Cc: stable@vger.kernel.org Fixes: ddd89d0a059d ("vhost_vdpa: support doorbell mapping via mmap") Signed-off-by: Jason Wang Link: https://lore.kernel.org/r/20210413091557.29008-1-jasowang@redhat.com Signed-off-by: Michael S. Tsirkin Signed-off-by: Greg Kroah-Hartman --- drivers/vhost/vdpa.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -997,6 +997,7 @@ static int vhost_vdpa_mmap(struct file * if (vma->vm_end - vma->vm_start != notify.size) return -ENOTSUPP; + vma->vm_flags |= VM_IO | VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP; vma->vm_ops = &vhost_vdpa_vm_ops; return 0; }