From: Chris Down <chris@chrisdown.name>
To: Ian Abbott <abbotti@mev.co.uk>,
H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: linux-kernel@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: [PATCH 0/2] comedi: honour VMA protections in comedi_mmap()
Date: Sun, 29 Nov 2026 11:33:39 -0800 [thread overview]
Message-ID: <cover.1795963468.git.chris@chrisdown.name> (raw)
comedi_mmap() maps buffers that weren't allocated for DMA with
PAGE_SHARED, so the pages are writable no matter how they were mapped.
That means anyone who can open a comedi device read-only can map its
buffer with PROT_READ and overwrite the samples in it.
Patch 1 fixes that by passing vma->vm_page_prot to remap_pfn_range(),
as the DMA path already does through dma_mmap_coherent().
Patch 2 rejects MAP_PRIVATE mappings, which comedi_mmap() can't set up
properly anyway: a mapping of more than one page already fails with
-EINVAL, and a single page one ends up with a vm_pgoff that
comedi_vm_access() can't use.
Chris Down (2):
comedi: Prevent writes to the buffer through read-only mappings
comedi: Reject MAP_PRIVATE mappings of the buffer
drivers/comedi/comedi_fops.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
base-commit: 89f33682b2c34b12b3a7a549ba94a808f0c7c98d
--
2.56.1
next reply other threads:[~2026-11-29 19:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 19:33 Chris Down [this message]
2026-11-29 19:33 ` [PATCH 1/2] comedi: Prevent writes to the buffer through read-only mappings Chris Down
2026-11-29 19:33 ` [PATCH 2/2] comedi: Reject MAP_PRIVATE mappings of the buffer Chris Down
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cover.1795963468.git.chris@chrisdown.name \
--to=chris@chrisdown.name \
--cc=abbotti@mev.co.uk \
--cc=gregkh@linuxfoundation.org \
--cc=hsweeten@visionengravers.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®