aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorVaibhav Hiremath <hvaibhav@ti.com>2011-04-14 12:42:34 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-07-01 14:47:53 -0400
commit383e4f69879d11c86ebdd38b3356f6d0690fb4cc (patch)
tree31790a31565229c3719b963d1be26f001eeb59b8 /drivers/media
parent8f3a307b9afd8c2ebde46ef317df4df3813301a7 (diff)
[media] omap_vout: Added check in reqbuf & mmap for buf_size allocation
The usecase where, user allocates small size of buffer through bootargs (video1_bufsize/video2_bufsize) and later from application tries to set the format which requires larger buffer size, driver doesn't check for insufficient buffer size and allows application to map extra buffer. This leads to kernel crash, when user application tries to access memory beyond the allocation size. Added check in both mmap and reqbuf call back function, and return error if the size of the buffer allocated by user through bootargs is less than the S_FMT size. Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/omap/omap_vout.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/media/video/omap/omap_vout.c b/drivers/media/video/omap/omap_vout.c
index eb16607358d0..4d07c5844402 100644
--- a/drivers/media/video/omap/omap_vout.c
+++ b/drivers/media/video/omap/omap_vout.c
@@ -982,6 +982,14 @@ static int omap_vout_buffer_setup(struct videobuf_queue *q, unsigned int *count,
982 startindex = (vout->vid == OMAP_VIDEO1) ? 982 startindex = (vout->vid == OMAP_VIDEO1) ?
983 video1_numbuffers : video2_numbuffers; 983 video1_numbuffers : video2_numbuffers;
984 984
985 /* Check the size of the buffer */
986 if (*size > vout->buffer_size) {
987 v4l2_err(&vout->vid_dev->v4l2_dev,
988 "buffer allocation mismatch [%u] [%u]\n",
989 *size, vout->buffer_size);
990 return -ENOMEM;
991 }
992
985 for (i = startindex; i < *count; i++) { 993 for (i = startindex; i < *count; i++) {
986 vout->buffer_size = *size; 994 vout->buffer_size = *size;
987 995
@@ -1228,6 +1236,14 @@ static int omap_vout_mmap(struct file *file, struct vm_area_struct *vma)
1228 (vma->vm_pgoff << PAGE_SHIFT)); 1236 (vma->vm_pgoff << PAGE_SHIFT));
1229 return -EINVAL; 1237 return -EINVAL;
1230 } 1238 }
1239 /* Check the size of the buffer */
1240 if (size > vout->buffer_size) {
1241 v4l2_err(&vout->vid_dev->v4l2_dev,
1242 "insufficient memory [%lu] [%u]\n",
1243 size, vout->buffer_size);
1244 return -ENOMEM;
1245 }
1246
1231 q->bufs[i]->baddr = vma->vm_start; 1247 q->bufs[i]->baddr = vma->vm_start;
1232 1248
1233 vma->vm_flags |= VM_RESERVED; 1249 vma->vm_flags |= VM_RESERVED;