diff options
author | Hans de Goede <hdegoede@redhat.com> | 2022-08-21 20:29:06 +0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@kernel.org> | 2022-09-24 09:46:03 +0200 |
commit | 6e6c4ae0f0ba295dbf6cbd48d93bec169d6ce431 (patch) | |
tree | c37e84df743295257e6208becea3399d209581c4 /drivers | |
parent | media: atomisp: hmm_bo: Drop PFN code path from alloc_user_pages() (diff) | |
download | linux-6e6c4ae0f0ba295dbf6cbd48d93bec169d6ce431.tar.xz linux-6e6c4ae0f0ba295dbf6cbd48d93bec169d6ce431.zip |
media: atomisp: Ensure that USERPTR pointers are page aligned
The atomisp code needs USERPTR pointers to be page aligned,
otherwise bad things (scribbling over other parts of the
process' RAM) happen.
Add a check to ensure this and exit VIDIOC_QBUF calls with
unaligned pointers with -EINVAL.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c index 7ecee39ef5a4..d0b5dacbb20a 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c +++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c @@ -1345,6 +1345,12 @@ static int atomisp_qbuf(struct file *file, void *fh, struct v4l2_buffer *buf) * address and reprograme out page table properly */ if (buf->memory == V4L2_MEMORY_USERPTR) { + if (offset_in_page(buf->m.userptr)) { + dev_err(isp->dev, "Error userptr is not page aligned.\n"); + ret = -EINVAL; + goto error; + } + vb = pipe->capq.bufs[buf->index]; vm_mem = vb->priv; if (!vm_mem) { |