Skip to content

Commit 3941552

Browse files
committed
xen: remove size limit of privcmd-buf mapping interface
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: c51b3c6 ("xen: add new hypercall buffer mapping device") Cc: <stable@vger.kernel.org> #4.18 Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com> Signed-off-by: Juergen Gross <jgross@suse.com>
1 parent d3132b3 commit 3941552

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

drivers/xen/privcmd-buf.c

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,9 @@
2121

2222
MODULE_LICENSE("GPL");
2323

24-
static unsigned int limit = 64;
25-
module_param(limit, uint, 0644);
26-
MODULE_PARM_DESC(limit, "Maximum number of pages that may be allocated by "
27-
"the privcmd-buf device per open file");
28-
2924
struct privcmd_buf_private {
3025
struct mutex lock;
3126
struct list_head list;
32-
unsigned int allocated;
3327
};
3428

3529
struct privcmd_buf_vma_private {
@@ -60,13 +54,10 @@ static void privcmd_buf_vmapriv_free(struct privcmd_buf_vma_private *vma_priv)
6054
{
6155
unsigned int i;
6256

63-
vma_priv->file_priv->allocated -= vma_priv->n_pages;
64-
6557
list_del(&vma_priv->list);
6658

6759
for (i = 0; i < vma_priv->n_pages; i++)
68-
if (vma_priv->pages[i])
69-
__free_page(vma_priv->pages[i]);
60+
__free_page(vma_priv->pages[i]);
7061

7162
kfree(vma_priv);
7263
}
@@ -146,28 +137,23 @@ static int privcmd_buf_mmap(struct file *file, struct vm_area_struct *vma)
146137
unsigned int i;
147138
int ret = 0;
148139

149-
if (!(vma->vm_flags & VM_SHARED) || count > limit ||
150-
file_priv->allocated + count > limit)
140+
if (!(vma->vm_flags & VM_SHARED))
151141
return -EINVAL;
152142

153143
vma_priv = kzalloc(sizeof(*vma_priv) + count * sizeof(void *),
154144
GFP_KERNEL);
155145
if (!vma_priv)
156146
return -ENOMEM;
157147

158-
vma_priv->n_pages = count;
159-
count = 0;
160-
for (i = 0; i < vma_priv->n_pages; i++) {
148+
for (i = 0; i < count; i++) {
161149
vma_priv->pages[i] = alloc_page(GFP_KERNEL | __GFP_ZERO);
162150
if (!vma_priv->pages[i])
163151
break;
164-
count++;
152+
vma_priv->n_pages++;
165153
}
166154

167155
mutex_lock(&file_priv->lock);
168156

169-
file_priv->allocated += count;
170-
171157
vma_priv->file_priv = file_priv;
172158
vma_priv->users = 1;
173159

0 commit comments

Comments
 (0)