Skip to content

Commit f09079b

Browse files
committed
Merge tag 'powerpc-6.16-2' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
Pull powerpc fixes from Madhavan Srinivasan: - a couple of fixes for out of bounds issues in memtrace and vas Thanks to Ritesh Harjani (IBM), Haren Myneni, and Jonathan Greental * tag 'powerpc-6.16-2' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: powerpc/vas: Return -EINVAL if the offset is non-zero in mmap() powerpc/powernv/memtrace: Fix out of bounds issue in memtrace mmap
2 parents 19272b3 + 0d67f0d commit f09079b

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

arch/powerpc/platforms/book3s/vas-api.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,15 @@ static int coproc_mmap(struct file *fp, struct vm_area_struct *vma)
521521
return -EINVAL;
522522
}
523523

524+
/*
525+
* Map complete page to the paste address. So the user
526+
* space should pass 0ULL to the offset parameter.
527+
*/
528+
if (vma->vm_pgoff) {
529+
pr_debug("Page offset unsupported to map paste address\n");
530+
return -EINVAL;
531+
}
532+
524533
/* Ensure instance has an open send window */
525534
if (!txwin) {
526535
pr_err("No send window open?\n");

arch/powerpc/platforms/powernv/memtrace.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,15 @@ static ssize_t memtrace_read(struct file *filp, char __user *ubuf,
4848
static int memtrace_mmap(struct file *filp, struct vm_area_struct *vma)
4949
{
5050
struct memtrace_entry *ent = filp->private_data;
51+
unsigned long ent_nrpages = ent->size >> PAGE_SHIFT;
52+
unsigned long vma_nrpages = vma_pages(vma);
5153

52-
if (ent->size < vma->vm_end - vma->vm_start)
54+
/* The requested page offset should be within object's page count */
55+
if (vma->vm_pgoff >= ent_nrpages)
5356
return -EINVAL;
5457

55-
if (vma->vm_pgoff << PAGE_SHIFT >= ent->size)
58+
/* The requested mapping range should remain within the bounds */
59+
if (vma_nrpages > ent_nrpages - vma->vm_pgoff)
5660
return -EINVAL;
5761

5862
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);

0 commit comments

Comments
 (0)