diff options
author | Ian Abbott <abbotti@mev.co.uk> | 2017-04-20 19:05:14 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-04-25 20:43:42 +0200 |
commit | 255364f7b8a0fee3fb642b3e1521e943dd67bfb3 (patch) | |
tree | 9b67464441cc98d69eece7d42852637ee3dd89ca /drivers/staging/comedi/comedi_fops.c | |
parent | staging/android: Update Ion TODO list (diff) | |
download | wireguard-linux-255364f7b8a0fee3fb642b3e1521e943dd67bfb3.tar.xz wireguard-linux-255364f7b8a0fee3fb642b3e1521e943dd67bfb3.zip |
staging: comedi: support vm_access_process for mmap'd buffer
If a process that has mmap'd a COMEDI buffer is being run under a
debugger such as GDB, the buffer contents are inaccessible from the
debugger. Support the `access()` VM operation to allow the buffer
contents to be accessed by another process.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/comedi/comedi_fops.c')
-rw-r--r-- | drivers/staging/comedi/comedi_fops.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 92d864fc08ac..f191c2a75732 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -2165,9 +2165,24 @@ static void comedi_vm_close(struct vm_area_struct *area) comedi_buf_map_put(bm); } +static int comedi_vm_access(struct vm_area_struct *vma, unsigned long addr, + void *buf, int len, int write) +{ + struct comedi_buf_map *bm = vma->vm_private_data; + unsigned long offset = + addr - vma->vm_start + (vma->vm_pgoff << PAGE_SHIFT); + + if (len < 0) + return -EINVAL; + if (len > vma->vm_end - addr) + len = vma->vm_end - addr; + return comedi_buf_map_access(bm, offset, buf, len, write); +} + static const struct vm_operations_struct comedi_vm_ops = { .open = comedi_vm_open, .close = comedi_vm_close, + .access = comedi_vm_access, }; static int comedi_mmap(struct file *file, struct vm_area_struct *vma) |