From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: arnd@arndb.de, Josef Bacik <josef@toxicpanda.com>,
stable <stable@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: [PATCH] uv_mmtimer: keep the mapping of the RTC read-only
Date: Tue, 27 Oct 2026 18:02:53 +0100 [thread overview]
Message-ID: <2026102752-extrovert-undaunted-d6cb@gregkh> (raw)
From: Josef Bacik <josef@toxicpanda.com>
uv_mmtimer_mmap() refuses a writable mapping of the page with the real time
clock, which is a page of registers of the UV hub. It leaves VM_MAYWRITE
set, though. Who has opened the device for reading and writing can map the
page shared and read-only and then make the mapping writable with
mprotect(), which gives him the access to the hub registers that the check
is there to prevent.
Clear VM_MAYWRITE. mprotect(PROT_WRITE) now fails with -EACCES on such a
mapping, on a private one too.
Fixes: fbd8ae106850 ("drivers/char/uv_mmtimer.c: add memory mapped RTC driver for UV")
Cc: stable <stable@kernel.org>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/char/uv_mmtimer.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/char/uv_mmtimer.c b/drivers/char/uv_mmtimer.c
index 956ebe2080a5..1cced9ef745b 100644
--- a/drivers/char/uv_mmtimer.c
+++ b/drivers/char/uv_mmtimer.c
@@ -157,6 +157,9 @@ static int uv_mmtimer_mmap(struct file *file, struct vm_area_struct *vma)
if (PAGE_SIZE > (1 << 16))
return -ENOSYS;
+ /* Don't let mprotect() add the permission afterwards. */
+ vm_flags_clear(vma, VM_MAYWRITE);
+
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
uv_mmtimer_addr = UV_LOCAL_MMR_BASE | UVH_RTC;
--
2.56.0
reply other threads:[~2026-10-27 17:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=2026102752-extrovert-undaunted-d6cb@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=arnd@arndb.de \
--cc=josef@toxicpanda.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@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®