Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3471040imu; Sun, 11 Nov 2018 15:52:06 -0800 (PST) X-Google-Smtp-Source: AJdET5cRr2gpRIKxUmjoTi2DvF7SI1JZIcG/VXF3VdBtvXKiFGuSlaS5KoYyKB3xhGusWoST+ldv X-Received: by 2002:a63:4c6:: with SMTP id 189mr15659414pge.391.1541980326264; Sun, 11 Nov 2018 15:52:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541980326; cv=none; d=google.com; s=arc-20160816; b=mSnV/q/yXNM2i6OIgcNBG6cZrCCNDB3Kq47fofiRA5jVsHvJdJhXCrLdj1DMtCm0me PaJ3psRz0MRvLW8gS2ewI45FI7aHxFDdxEbqGfmC33xgfenhAC4W+MLY8APVNngBJBJ+ KXdzkwuLMpVHuWADe1PT3Be8fBgx+ResROZsl1VT0++eBUR5+4pJQll19sbg42307Pxc pcKGR9mQEx/8IQ3e87mjIoWw6Fj30+RGIWWS+8n17T+iuEoJPAYF+uZfr31i1TvWXah4 JeihXRzdO+/IWH2B9+qSxSbeM1m/6JWT/BK7eVis8FBk4gy5HyMopQIExNFHBekRUieW o0CQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Yvbd/WYtshc0jMBLz6w2cCoaAntmAVYpDh8qgwCCv+o=; b=m330HzaRM9gdgeM2jUKLgRMBVjvi/sduuJuSBZHz7EkGMTEqJhK++SbYz4Us53vdHT zOoMeFOIEYvZQ1eBU8VYxsL3Vv53xs/b8xxw/PM3N4kR67SapzGEIwK7hsr05Nk0pZic V2e6GKK9qqk0awbvmbznM0oG4MWxfyLsR+MQ+lmSEqg2Gv2GUIwo5wo1iUy8V3ph9GLi CF1NJIjFKaahyhJdEkH+S6W3VEq3otqx4rp5h1hKb9tXHCVtViEFmSwyaxTwPHAAp/x0 GMlsEE86Uy4lsiKwyIeY4b8liTCnCis2S/n+Y/MK6rSQ8JxjwYjLpZtn/eVl6tMxhFrz qgEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fX1uxdRZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q5si9078614pgk.46.2018.11.11.15.51.51; Sun, 11 Nov 2018 15:52:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fX1uxdRZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732884AbeKLISc (ORCPT + 99 others); Mon, 12 Nov 2018 03:18:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:37238 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732843AbeKLISa (ORCPT ); Mon, 12 Nov 2018 03:18:30 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4E5A82154B; Sun, 11 Nov 2018 22:28:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975314; bh=wSNryVa/beN+aE7zJ4zRTED0OjDw/qD5YJAgLic6CF8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fX1uxdRZP8CKiRyWkJJPBiNYGAi7BlNI8RxbUBbh/Z68+ZC1wR2FgHzYtgtZE8439 AWciJ/VWjyxyL8g5y/fWXCZdS1VhRXZ/JL6Orjzj00DQDxwP8vQMFcN63SHE182pxD DFxg3OZzTKhDLp2+ualFuXKmVzqgLCIb81dCuk5I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Juergen Gross , Boris Ostrovsky Subject: [PATCH 4.19 300/361] xen: remove size limit of privcmd-buf mapping interface Date: Sun, 11 Nov 2018 14:20:47 -0800 Message-Id: <20181111221657.421811314@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Juergen Gross commit 3941552aec1e04d63999988a057ae09a1c56ebeb upstream. Currently the size of hypercall buffers allocated via /dev/xen/hypercall is limited to a default of 64 memory pages. For live migration of guests this might be too small as the page dirty bitmask needs to be sized according to the size of the guest. This means migrating a 8GB sized guest is already exhausting the default buffer size for the dirty bitmap. There is no sensible way to set a sane limit, so just remove it completely. The device node's usage is limited to root anyway, so there is no additional DOS scenario added by allowing unlimited buffers. While at it make the error path for the -ENOMEM case a little bit cleaner by setting n_pages to the number of successfully allocated pages instead of the target size. Fixes: c51b3c639e01f2 ("xen: add new hypercall buffer mapping device") Cc: #4.18 Signed-off-by: Juergen Gross Reviewed-by: Boris Ostrovsky Signed-off-by: Juergen Gross Signed-off-by: Greg Kroah-Hartman --- drivers/xen/privcmd-buf.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) --- a/drivers/xen/privcmd-buf.c +++ b/drivers/xen/privcmd-buf.c @@ -21,15 +21,9 @@ MODULE_LICENSE("GPL"); -static unsigned int limit = 64; -module_param(limit, uint, 0644); -MODULE_PARM_DESC(limit, "Maximum number of pages that may be allocated by " - "the privcmd-buf device per open file"); - struct privcmd_buf_private { struct mutex lock; struct list_head list; - unsigned int allocated; }; struct privcmd_buf_vma_private { @@ -60,13 +54,10 @@ static void privcmd_buf_vmapriv_free(str { unsigned int i; - vma_priv->file_priv->allocated -= vma_priv->n_pages; - list_del(&vma_priv->list); for (i = 0; i < vma_priv->n_pages; i++) - if (vma_priv->pages[i]) - __free_page(vma_priv->pages[i]); + __free_page(vma_priv->pages[i]); kfree(vma_priv); } @@ -146,8 +137,7 @@ static int privcmd_buf_mmap(struct file unsigned int i; int ret = 0; - if (!(vma->vm_flags & VM_SHARED) || count > limit || - file_priv->allocated + count > limit) + if (!(vma->vm_flags & VM_SHARED)) return -EINVAL; vma_priv = kzalloc(sizeof(*vma_priv) + count * sizeof(void *), @@ -155,19 +145,15 @@ static int privcmd_buf_mmap(struct file if (!vma_priv) return -ENOMEM; - vma_priv->n_pages = count; - count = 0; - for (i = 0; i < vma_priv->n_pages; i++) { + for (i = 0; i < count; i++) { vma_priv->pages[i] = alloc_page(GFP_KERNEL | __GFP_ZERO); if (!vma_priv->pages[i]) break; - count++; + vma_priv->n_pages++; } mutex_lock(&file_priv->lock); - file_priv->allocated += count; - vma_priv->file_priv = file_priv; vma_priv->users = 1;