Module Name:    src
Committed By:   riastradh
Date:           Mon May 20 11:35:11 UTC 2024

Modified Files:
        src/sys/external/bsd/drm2/linux: linux_dma_buf.c

Log Message:
drm: Fix missing bounds checks in dma buf mmap.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/external/bsd/drm2/linux/linux_dma_buf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/linux/linux_dma_buf.c
diff -u src/sys/external/bsd/drm2/linux/linux_dma_buf.c:1.16 src/sys/external/bsd/drm2/linux/linux_dma_buf.c:1.17
--- src/sys/external/bsd/drm2/linux/linux_dma_buf.c:1.16	Tue Feb 21 11:40:13 2023
+++ src/sys/external/bsd/drm2/linux/linux_dma_buf.c	Mon May 20 11:35:10 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_dma_buf.c,v 1.16 2023/02/21 11:40:13 riastradh Exp $	*/
+/*	$NetBSD: linux_dma_buf.c,v 1.17 2024/05/20 11:35:10 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_dma_buf.c,v 1.16 2023/02/21 11:40:13 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_dma_buf.c,v 1.17 2024/05/20 11:35:10 riastradh Exp $");
 
 #include <sys/types.h>
 #include <sys/atomic.h>
@@ -285,7 +285,7 @@ dmabuf_fop_mmap(struct file *file, off_t
 {
 	struct dma_buf *dmabuf = file->f_data;
 
-	if (size > dmabuf->size)
+	if (size > dmabuf->size || *offp < 0 || *offp > dmabuf->size - size)
 		return EINVAL;
 
 	return dmabuf->ops->mmap(dmabuf, offp, size, prot, flagsp, advicep,

Reply via email to