From: Liang Wang <wangliang101@huawei.com>
To: <palmerdabbelt@google.com>, <mcgrof@kernel.org>,
<linux-kernel@vger.kernel.org>, <gregkh@linuxfoundation.org>,
<linux@armlinux.org.uk>
Cc: <stable@vger.kernel.org>, <wangliang101@huawei.com>,
<wangle6@huawei.com>, <kepler.chenxin@huawei.com>,
<nixiaoming@huawei.com>
Subject: [PATCH] arm:mmap: fix physical address overflow when CONFIG_ARM_LPAE=y
Date: Thu, 15 Jul 2021 20:30:12 +0800 [thread overview]
Message-ID: <20210715123012.61215-1-wangliang101@huawei.com> (raw)
When the CONFIG_ARM_LPAE is enabled on arm32, the physical address may
exceed 32 bits. In the devmem_is_allowed function, the physical address
is obtained through displacement of the physical page number.Without
explicit translation, the physical address may overflow and be truncated.
Use the PFN_PHYS macro to fix this bug.
This bug was initially introduced in v2.6.37 with commit:087aaffcdf9c91.
In v5.10, this code has been modified by commit:527701eda5f196.
Fixes: 527701eda5f196 ("lib: Add a generic version of devmem_is_allowed")
Fixes: 087aaffcdf9c91 ("ARM: implement CONFIG_STRICT_DEVMEM by disabling access to RAM via /dev/mem")
Cc: stable@vger.kernel.org # v2.6.37
Signed-off-by: Liang Wang <wangliang101@huawei.com>
---
lib/devmem_is_allowed.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/devmem_is_allowed.c b/lib/devmem_is_allowed.c
index c0d67c541849..60be9e24bd57 100644
--- a/lib/devmem_is_allowed.c
+++ b/lib/devmem_is_allowed.c
@@ -19,7 +19,7 @@
*/
int devmem_is_allowed(unsigned long pfn)
{
- if (iomem_is_exclusive(pfn << PAGE_SHIFT))
+ if (iomem_is_exclusive(PFN_PHYS(pfn)))
return 0;
if (!page_is_ram(pfn))
return 1;
--
2.32.0
next reply other threads:[~2021-07-15 12:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-15 12:30 Liang Wang [this message]
2021-07-20 7:37 ` 答复: [PATCH] arm:mmap: fix physical address overflow when CONFIG_ARM_LPAE=y wangliang (C)
2021-07-20 7:37 ` wangliang (C)
-- strict thread matches above, loose matches on Subject: below --
2021-07-15 12:20 Liang Wang
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=20210715123012.61215-1-wangliang101@huawei.com \
--to=wangliang101@huawei.com \
--cc=gregkh@linuxfoundation.org \
--cc=kepler.chenxin@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=mcgrof@kernel.org \
--cc=nixiaoming@huawei.com \
--cc=palmerdabbelt@google.com \
--cc=stable@vger.kernel.org \
--cc=wangle6@huawei.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.