Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp778240imd; Thu, 1 Nov 2018 05:34:14 -0700 (PDT) X-Google-Smtp-Source: AJdET5cJE8gQppucnhMySz3LFisk7avXpreL7v1v+IKOicBSD+2FeP1gIQFI/48lVIO1Nj3QoIRV X-Received: by 2002:a63:ae4d:: with SMTP id e13-v6mr7075586pgp.315.1541075654680; Thu, 01 Nov 2018 05:34:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541075654; cv=none; d=google.com; s=arc-20160816; b=lC/bGx6Lzt5+gA4ap5CGUjetCJBb/X3Pwe132Oq7ff8BTsyq9wVrvvw+3LmOcWfYc3 9UsHWPVGJplt6LRDBf+BtWOXilCIrBLZqc3aCWRXtn2ZyN2KRMF4qm2YivQoFfFfA6He H0iGFbLauuSS5NUDN5T9zoCmDzKuFYjVrC4F3GfvXmHRSzunirsFf2Guc0z+GQLV81vh +71h7vWPF33gPzhVV9lSg97FurkOPryb7VQvuow5fFLhsqWFtFaq6OwJYlGU3CyYQLtZ /oTEYQMz1lX30456dzgkGk3Shhuzjm7vK3eRn7HBvrV1MOSXEnsfakqR8hIkRqwKXkEK YLSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=joFCDasXUGA3DfqEamd0bkr36jgPeCssjanBR+o6Enw=; b=VfcgrUVcCNufiftngF6iUGgYMtGJ+K+zFK9NWSsRqoqevd3LGZ9q/F4UUz2frbBV7B tjIJoVweBQnNgcersooqMF5+DMTp//eJCkNpw7u7G+yvVnRibN5uLwLQt1hSUu6LMHum wAivVT1gKZrEERn9wf1AArX9W/jBV30t7vDsb11i90/Oneeastf8X/MWsldcREESPw++ Gf9qMlyFddsn9CyKN2gRTCxwm9ZaPa1t+9//tJwvbTgU034MnC5MQ3Z9TJO3Np+ohWfq EvZ7UYKHMckhQziC/4AxN6u+8j0wMuadLzE2fxEzEg7QE4GMJTe2qe98lN5Yk0Ih2Imm xY1A== ARC-Authentication-Results: i=1; mx.google.com; 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 r22-v6si29528975pls.185.2018.11.01.05.33.54; Thu, 01 Nov 2018 05:34:14 -0700 (PDT) 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; 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 S1728536AbeKAVgB (ORCPT + 99 others); Thu, 1 Nov 2018 17:36:01 -0400 Received: from mx2.suse.de ([195.135.220.15]:49860 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728326AbeKAVgA (ORCPT ); Thu, 1 Nov 2018 17:36:00 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 3CB6CAC11; Thu, 1 Nov 2018 12:33:13 +0000 (UTC) From: Juergen Gross To: linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org Cc: boris.ostrovsky@oracle.com, sstabellini@kernel.org, Juergen Gross , stable@vger.kernel.org Subject: [PATCH] xen: remove size limit of privcmd-buf mapping interface Date: Thu, 1 Nov 2018 13:33:07 +0100 Message-Id: <20181101123307.8424-1-jgross@suse.com> X-Mailer: git-send-email 2.16.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/xen/privcmd-buf.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/drivers/xen/privcmd-buf.c b/drivers/xen/privcmd-buf.c index df1ed37c3269..de01a6d0059d 100644 --- 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(struct privcmd_buf_vma_private *vma_priv) { 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 *file, struct vm_area_struct *vma) 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 *file, struct vm_area_struct *vma) 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; -- 2.16.4