* [PATCH] arm:mmap: fix physical address overflow when CONFIG_ARM_LPAE=y
@ 2021-07-15 12:30 Liang Wang
2021-07-20 7:37 ` wangliang (C)
0 siblings, 1 reply; 3+ messages in thread
From: Liang Wang @ 2021-07-15 12:30 UTC (permalink / raw)
To: palmerdabbelt, mcgrof, linux-kernel, gregkh, linux
Cc: stable, wangliang101, wangle6, kepler.chenxin, nixiaoming
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* 答复: [PATCH] arm:mmap: fix physical address overflow when CONFIG_ARM_LPAE=y
2021-07-15 12:30 [PATCH] arm:mmap: fix physical address overflow when CONFIG_ARM_LPAE=y Liang Wang
@ 2021-07-20 7:37 ` wangliang (C)
0 siblings, 0 replies; 3+ messages in thread
From: wangliang (C) @ 2021-07-20 7:37 UTC (permalink / raw)
To: palmerdabbelt, mcgrof, linux-kernel, gregkh, linux, linux-arm-kernel
Cc: stable, Wangle (RTOS FAE), Chenxin (RTOS),
Nixiaoming, Wangkefeng (OS Kernel Lab)
add arm list
-----邮件原件-----
发件人: wangliang (C)
发送时间: 2021年7月15日 20:30
收件人: palmerdabbelt@google.com; mcgrof@kernel.org; linux-kernel@vger.kernel.org; gregkh@linuxfoundation.org; linux@armlinux.org.uk
抄送: stable@vger.kernel.org; wangliang (C) <wangliang101@huawei.com>; Wangle (RTOS FAE) <wangle6@huawei.com>; Chenxin (RTOS) <kepler.chenxin@huawei.com>; Nixiaoming <nixiaoming@huawei.com>
主题: [PATCH] arm:mmap: fix physical address overflow when CONFIG_ARM_LPAE=y
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* 答复: [PATCH] arm:mmap: fix physical address overflow when CONFIG_ARM_LPAE=y
@ 2021-07-20 7:37 ` wangliang (C)
0 siblings, 0 replies; 3+ messages in thread
From: wangliang (C) @ 2021-07-20 7:37 UTC (permalink / raw)
To: palmerdabbelt, mcgrof, linux-kernel, gregkh, linux, linux-arm-kernel
Cc: stable, Wangle (RTOS FAE), Chenxin (RTOS),
Nixiaoming, Wangkefeng (OS Kernel Lab)
add arm list
-----邮件原件-----
发件人: wangliang (C)
发送时间: 2021年7月15日 20:30
收件人: palmerdabbelt@google.com; mcgrof@kernel.org; linux-kernel@vger.kernel.org; gregkh@linuxfoundation.org; linux@armlinux.org.uk
抄送: stable@vger.kernel.org; wangliang (C) <wangliang101@huawei.com>; Wangle (RTOS FAE) <wangle6@huawei.com>; Chenxin (RTOS) <kepler.chenxin@huawei.com>; Nixiaoming <nixiaoming@huawei.com>
主题: [PATCH] arm:mmap: fix physical address overflow when CONFIG_ARM_LPAE=y
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
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-07-20 7:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-15 12:30 [PATCH] arm:mmap: fix physical address overflow when CONFIG_ARM_LPAE=y Liang Wang
2021-07-20 7:37 ` 答复: " wangliang (C)
2021-07-20 7:37 ` wangliang (C)
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.