public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexander Potapenko <glider@google.com>
To: glider@google.com
Cc: elver@google.com, dvyukov@google.com, bvanassche@acm.org,
	 kent.overstreet@linux.dev, iii@linux.ibm.com,
	akpm@linux-foundation.org,  linux-kernel@vger.kernel.org,
	kasan-dev@googlegroups.com
Subject: [PATCH 2/5] kmsan: fix usage of kmsan_enter_runtime() in kmsan_vmap_pages_range_noflush()
Date: Wed,  7 May 2025 18:00:09 +0200	[thread overview]
Message-ID: <20250507160012.3311104-2-glider@google.com> (raw)
In-Reply-To: <20250507160012.3311104-1-glider@google.com>

Only enter the runtime to call __vmap_pages_range_noflush(), so that error
handling does not skip kmsan_leave_runtime().

This bug was spotted by CONFIG_WARN_CAPABILITY_ANALYSIS=y

Cc: Marco Elver <elver@google.com>
Cc: Bart Van Assche <bvanassche@acm.org>
Cc: Kent Overstreet <kent.overstreet@linux.dev>
Signed-off-by: Alexander Potapenko <glider@google.com>
---
 mm/kmsan/shadow.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mm/kmsan/shadow.c b/mm/kmsan/shadow.c
index 6d32bfc18d6a2..54f3c3c962f07 100644
--- a/mm/kmsan/shadow.c
+++ b/mm/kmsan/shadow.c
@@ -247,17 +247,19 @@ int kmsan_vmap_pages_range_noflush(unsigned long start, unsigned long end,
 	kmsan_enter_runtime();
 	mapped = __vmap_pages_range_noflush(shadow_start, shadow_end, prot,
 					    s_pages, page_shift);
+	kmsan_leave_runtime();
 	if (mapped) {
 		err = mapped;
 		goto ret;
 	}
+	kmsan_enter_runtime();
 	mapped = __vmap_pages_range_noflush(origin_start, origin_end, prot,
 					    o_pages, page_shift);
+	kmsan_leave_runtime();
 	if (mapped) {
 		err = mapped;
 		goto ret;
 	}
-	kmsan_leave_runtime();
 	flush_tlb_kernel_range(shadow_start, shadow_end);
 	flush_tlb_kernel_range(origin_start, origin_end);
 	flush_cache_vmap(shadow_start, shadow_end);
-- 
2.49.0.967.g6a0df3ecc3-goog


  reply	other threads:[~2025-05-07 16:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-07 16:00 [PATCH 1/5] kmsan: apply clang-format to files mm/kmsan/ Alexander Potapenko
2025-05-07 16:00 ` Alexander Potapenko [this message]
2025-05-07 16:09   ` [PATCH 2/5] kmsan: fix usage of kmsan_enter_runtime() in kmsan_vmap_pages_range_noflush() Marco Elver
2025-05-08  8:19     ` Alexander Potapenko
2025-05-08  8:31       ` Alexander Potapenko
2025-05-07 16:00 ` [PATCH 3/5] kmsan: drop the declaration of kmsan_save_stack() Alexander Potapenko
2025-05-07 16:09   ` Marco Elver
2025-05-07 16:00 ` [PATCH 4/5] kmsan: enter the runtime around kmsan_internal_memmove_metadata() call Alexander Potapenko
2025-05-07 16:09   ` Marco Elver
2025-05-07 16:00 ` [PATCH 5/5] kmsan: rework kmsan_in_runtime() handling in kmsan_report() Alexander Potapenko
2025-05-07 16:10   ` Marco Elver

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=20250507160012.3311104-2-glider@google.com \
    --to=glider@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=bvanassche@acm.org \
    --cc=dvyukov@google.com \
    --cc=elver@google.com \
    --cc=iii@linux.ibm.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=kent.overstreet@linux.dev \
    --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