Skip to content

Commit 3b04689

Browse files
committed
Merge tag 'for-linus-5.1b-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip
Pull xen fixes from Juergen Gross: "One minor fix and a small cleanup for the xen privcmd driver" * tag 'for-linus-5.1b-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip: xen: Prevent buffer overflow in privcmd ioctl xen: use struct_size() helper in kzalloc()
2 parents 82331a7 + 42d8644 commit 3b04689

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

arch/x86/include/asm/xen/hypercall.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ xen_single_call(unsigned int call,
206206
__HYPERCALL_DECLS;
207207
__HYPERCALL_5ARG(a1, a2, a3, a4, a5);
208208

209+
if (call >= PAGE_SIZE / sizeof(hypercall_page[0]))
210+
return -EINVAL;
211+
209212
asm volatile(CALL_NOSPEC
210213
: __HYPERCALL_5PARAM
211214
: [thunk_target] "a" (&hypercall_page[call])

drivers/xen/privcmd-buf.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,7 @@ static int privcmd_buf_mmap(struct file *file, struct vm_area_struct *vma)
140140
if (!(vma->vm_flags & VM_SHARED))
141141
return -EINVAL;
142142

143-
vma_priv = kzalloc(sizeof(*vma_priv) + count * sizeof(void *),
144-
GFP_KERNEL);
143+
vma_priv = kzalloc(struct_size(vma_priv, pages, count), GFP_KERNEL);
145144
if (!vma_priv)
146145
return -ENOMEM;
147146

0 commit comments

Comments
 (0)