mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "tip-bot2 for Max Ramanouski" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Max Ramanouski <max8rr8@gmail.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Christoph Hellwig <hch@lst.de>,
	Alistair Popple <apopple@nvidia.com>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: x86/urgent] x86/ioremap: Use is_ioremap_addr() in iounmap()
Date: Fri, 16 Aug 2024 09:43:48 -0000	[thread overview]
Message-ID: <172380142877.2215.11720831620589167404.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20240815205606.16051-2-max8rr8@gmail.com>

The following commit has been merged into the x86/urgent branch of tip:

Commit-ID:     7b02ad32d83c16abd4961d79f3154b734d1d5d9c
Gitweb:        https://git.kernel.org/tip/7b02ad32d83c16abd4961d79f3154b734d1d5d9c
Author:        Max Ramanouski <max8rr8@gmail.com>
AuthorDate:    Thu, 15 Aug 2024 23:56:07 +03:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Fri, 16 Aug 2024 11:33:33 +02:00

x86/ioremap: Use is_ioremap_addr() in iounmap()

Restrict iounmap() to memory allocated in the ioremap region, by using
is_ioremap_addr(). Similarly to the generic iounmap() implementation.

Additionally, add a warning in case there is an attempt to iounmap()
invalid memory, instead of silently exiting, thus helping to avoid
incorrect usage of iounmap().

Signed-off-by: Max Ramanouski <max8rr8@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Alistair Popple <apopple@nvidia.com>
Link: https://lore.kernel.org/all/20240815205606.16051-2-max8rr8@gmail.com
---
 arch/x86/mm/ioremap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
index aa7d279..70b02fc 100644
--- a/arch/x86/mm/ioremap.c
+++ b/arch/x86/mm/ioremap.c
@@ -11,6 +11,7 @@
 #include <linux/init.h>
 #include <linux/io.h>
 #include <linux/ioport.h>
+#include <linux/ioremap.h>
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/mmiotrace.h>
@@ -457,7 +458,7 @@ void iounmap(volatile void __iomem *addr)
 {
 	struct vm_struct *p, *o;
 
-	if ((void __force *)addr <= high_memory)
+	if (WARN_ON_ONCE(!is_ioremap_addr((void __force *)addr)))
 		return;
 
 	/*

  parent reply	other threads:[~2024-08-16  9:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-15 20:56 [PATCH v3] " Max Ramanouski
2024-08-15 22:55 ` Alistair Popple
2024-08-16  9:43 ` tip-bot2 for Max Ramanouski [this message]
2024-08-20 20:35   ` [tip: x86/urgent] " Thomas Gleixner
2024-08-21  8:35     ` Max R
2024-08-21  9:27       ` Thomas Gleixner
2024-08-21 21:21         ` Max Ramanouski

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=172380142877.2215.11720831620589167404.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=apopple@nvidia.com \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=max8rr8@gmail.com \
    --cc=tglx@linutronix.de \
    --cc=x86@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®