Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp414010imu; Thu, 8 Nov 2018 23:03:57 -0800 (PST) X-Google-Smtp-Source: AJdET5eyqloEfeJlkzMl4Sitl7JLTmfIIW+St0qx90lUGRL70fYLioL3TLMBWz6k1zPQ8cjT42+8 X-Received: by 2002:a63:dd58:: with SMTP id g24-v6mr6356598pgj.86.1541747037399; Thu, 08 Nov 2018 23:03:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541747037; cv=none; d=google.com; s=arc-20160816; b=ip3T7Uk81TR5ZqiPwFN3J9PgeEgHqUdIhg6/DK+tM5iZ8NgVmlpYI2YCWGT3mHqLVF AMBguPwQ3DFPYt3h9P542mopqJSpLpmFxANF1hdJgOnXMGyvfoPQlq1CHSrfSa5w0cMz fFc6a2bIcT/H2Crbfq7BnOi5FTbOKphmmSoglyICzZNpEdZx5210zhG42Foz2i9UcnsF yuBz26jmzPe+lI8GckL3SplQL2X0Z0/VZ5mIYRk77bbT/iVHAVdHAI8/SQwu0HXmeTLq kP+nAe7Vp4tbvz///YdnbIojLeeK1pmPdPzCCTus5HzDiECVxU1bkwR5cgUxZr80im/z ih/Q== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject; bh=tCaUMGNQQT3nhCvhCWdtAtNJXiTbKA+SNlFsy0QCyuw=; b=bqjQjkJMR/KHgHhcVxqpqy6AR2kJAXWnMeZAoX01Cu1Ly2WhQ7WN4SybF+AsrPSe5H wQv/ZBoPOy005nThORgWEg/04sbfYOjXdc1ssi9HIL3e2yJPJqfBLHmlWQLsVkCTnaIk xIyLdMuZDmUbiGMfiWavVDuWICAvN99nJuX3AO17W8ulBoSkPRQb0/hBe1P+5F0aoaoi ovGhJSd6CjmmP7Rig53gyAJaEYJYcNshwrFXZOOhWVINqTctAif45CtSERSBrhjfDBq5 tiXqYRQNLnoWq0WCl8c9n8hha7E1v8GQUPX9mr9iNBWfYwO72b9TWhu/sK11f6KSX8T2 mlHg== 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 b137-v6si6814708pfb.144.2018.11.08.23.03.40; Thu, 08 Nov 2018 23:03:57 -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; 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 S1727962AbeKIQmc (ORCPT + 99 others); Fri, 9 Nov 2018 11:42:32 -0500 Received: from mx2.suse.de ([195.135.220.15]:33120 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727485AbeKIQmb (ORCPT ); Fri, 9 Nov 2018 11:42:31 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id BB3B4B003; Fri, 9 Nov 2018 07:03:17 +0000 (UTC) Subject: Re: [PATCH] xen: remove size limit of privcmd-buf mapping interface To: linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org Cc: boris.ostrovsky@oracle.com, sstabellini@kernel.org, stable@vger.kernel.org References: <20181101123307.8424-1-jgross@suse.com> From: Juergen Gross Openpgp: preference=signencrypt Autocrypt: addr=jgross@suse.com; prefer-encrypt=mutual; keydata= xsBNBFOMcBYBCACgGjqjoGvbEouQZw/ToiBg9W98AlM2QHV+iNHsEs7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 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20181101123307.8424-1-jgross@suse.com> Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ping? Jan's remark regarding de-privileged qemu is no issue as the hypercall node is being closed by the de-privilege library function. Juergen On 01/11/2018 13:33, Juergen Gross wrote: > 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; > >