Skip to content

Commit dca922e

Browse files
committed
Merge tag 'xsa48x-7.1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip
Pull xen fixes from Juergen Gross: "XSA-485 and XSA-487 security patches" * tag 'xsa48x-7.1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip: xen/privcmd: fix double free via VMA splitting Buffer overflow in drivers/xen/sys-hypervisor.c
2 parents 3b3bea6 + 24daca4 commit dca922e

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

drivers/xen/privcmd.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,6 +1620,12 @@ static void privcmd_close(struct vm_area_struct *vma)
16201620
kvfree(pages);
16211621
}
16221622

1623+
static int privcmd_may_split(struct vm_area_struct *area, unsigned long addr)
1624+
{
1625+
/* Forbid splitting, avoids double free via privcmd_close(). */
1626+
return -EINVAL;
1627+
}
1628+
16231629
static vm_fault_t privcmd_fault(struct vm_fault *vmf)
16241630
{
16251631
printk(KERN_DEBUG "privcmd_fault: vma=%p %lx-%lx, pgoff=%lx, uv=%p\n",
@@ -1631,6 +1637,7 @@ static vm_fault_t privcmd_fault(struct vm_fault *vmf)
16311637

16321638
static const struct vm_operations_struct privcmd_vm_ops = {
16331639
.close = privcmd_close,
1640+
.may_split = privcmd_may_split,
16341641
.fault = privcmd_fault
16351642
};
16361643

drivers/xen/sys-hypervisor.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,15 +366,19 @@ static ssize_t buildid_show(struct hyp_sysfs_attr *attr, char *buffer)
366366
ret = sprintf(buffer, "<denied>");
367367
return ret;
368368
}
369+
if (ret > PAGE_SIZE)
370+
return -ENOSPC;
369371

370372
buildid = kmalloc(sizeof(*buildid) + ret, GFP_KERNEL);
371373
if (!buildid)
372374
return -ENOMEM;
373375

374376
buildid->len = ret;
375377
ret = HYPERVISOR_xen_version(XENVER_build_id, buildid);
376-
if (ret > 0)
377-
ret = sprintf(buffer, "%s", buildid->buf);
378+
if (ret > 0) {
379+
/* Build id is binary, not a string. */
380+
memcpy(buffer, buildid->buf, ret);
381+
}
378382
kfree(buildid);
379383

380384
return ret;

0 commit comments

Comments
 (0)