From: Aleksei Nikiforov <aleksei.nikiforov@linux.ibm.com>
To: Alexander Potapenko <glider@google.com>
Cc: Marco Elver <elver@google.com>,
Dmitry Vyukov <dvyukov@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
kasan-dev@googlegroups.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org,
Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Sven Schnelle <svens@linux.ibm.com>,
Thomas Huth <thuth@redhat.com>,
Juergen Christ <jchrist@linux.ibm.com>,
Ilya Leoshkevich <iii@linux.ibm.com>,
Aleksei Nikiforov <aleksei.nikiforov@linux.ibm.com>
Subject: [PATCH 1/2] instrumented.h: Add function instrument_write_after
Date: Thu, 6 Nov 2025 17:08:46 +0100 [thread overview]
Message-ID: <20251106160845.1334274-4-aleksei.nikiforov@linux.ibm.com> (raw)
In-Reply-To: <20251106160845.1334274-2-aleksei.nikiforov@linux.ibm.com>
clang generates call to __msan_instrument_asm_store with size calculated
based on inline asm constraints. It looks like there's no way to properly
write constraint for var-size memory write and make clang generate
__msan_instrument_asm_store call based on runtime-obtained size.
Implement instrument_write_after similar to instrument_write and
instrument_copy_from_user_after to manually fix kmsan behaviour
in such cases.
Signed-off-by: Aleksei Nikiforov <aleksei.nikiforov@linux.ibm.com>
---
include/linux/instrumented.h | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/include/linux/instrumented.h b/include/linux/instrumented.h
index 711a1f0d1a73..a498d914a8b0 100644
--- a/include/linux/instrumented.h
+++ b/include/linux/instrumented.h
@@ -41,6 +41,20 @@ static __always_inline void instrument_write(const volatile void *v, size_t size
kcsan_check_write(v, size);
}
+/**
+ * instrument_write_after - instrument regular write access
+ * @v: address of access
+ * @size: size of access
+ *
+ * Instrument a regular write access. The instrumentation should be inserted
+ * after the actual write happens.
+ */
+static __always_inline void instrument_write_after(const volatile void *v,
+ size_t size)
+{
+ kmsan_unpoison_memory((const void *)v, size);
+}
+
/**
* instrument_read_write - instrument regular read-write access
* @v: address of access
--
2.43.7
next prev parent reply other threads:[~2025-11-06 16:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-06 16:08 [PATCH 0/2] s390/fpu: Fix kmsan false-positive report Aleksei Nikiforov
2025-11-06 16:08 ` Aleksei Nikiforov [this message]
2025-11-06 16:08 ` [PATCH 2/2] s390/fpu: Fix kmsan in fpu_vstl function Aleksei Nikiforov
2025-11-07 10:26 ` Alexander Potapenko
2025-11-07 10:49 ` Heiko Carstens
2025-11-07 13:32 ` Alexander Potapenko
2025-11-07 15:33 ` Aleksei Nikiforov
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=20251106160845.1334274-4-aleksei.nikiforov@linux.ibm.com \
--to=aleksei.nikiforov@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=borntraeger@linux.ibm.com \
--cc=dvyukov@google.com \
--cc=elver@google.com \
--cc=glider@google.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=iii@linux.ibm.com \
--cc=jchrist@linux.ibm.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-s390@vger.kernel.org \
--cc=svens@linux.ibm.com \
--cc=thuth@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox