git: be5464ae233a - main - kmsan: Add kmsan_check_uio()

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Wed, 06 Dec 2023 18:55:26 UTC
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=be5464ae233ada46a778cc82f7107a10a7d5343b

commit be5464ae233ada46a778cc82f7107a10a7d5343b
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-12-06 16:31:15 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-12-06 17:46:25 +0000

    kmsan: Add kmsan_check_uio()
    
    This was handy for some ad-hoc debugging and fits in with other
    kmsan_check_*() routines which operate on some kind of data container.
    
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
---
 share/man/man9/Makefile | 1 +
 share/man/man9/kmsan.9  | 5 ++++-
 sys/kern/subr_msan.c    | 9 +++++++++
 sys/sys/msan.h          | 3 +++
 4 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile
index 6768f52a38d6..81de035defb9 100644
--- a/share/man/man9/Makefile
+++ b/share/man/man9/Makefile
@@ -1370,6 +1370,7 @@ MLINKS+=kmsan.9 KMSAN.9 \
 	kmsan.9 kmsan_check_bio.9 \
 	kmsan.9 kmsan_check_ccb.9 \
 	kmsan.9 kmsan_check_mbuf.9 \
+	kmsan.9 kmsan_check_uio.9 \
 	kmsan.9 kmsan_mark.9 \
 	kmsan.9 kmsan_oirg.9
 MLINKS+=kobj.9 DEFINE_CLASS.9 \
diff --git a/share/man/man9/kmsan.9 b/share/man/man9/kmsan.9
index 714442e4d9fe..90faf8f82e5e 100644
--- a/share/man/man9/kmsan.9
+++ b/share/man/man9/kmsan.9
@@ -25,7 +25,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd October 13, 2023
+.Dd December 6, 2023
 .Dt KMSAN 9
 .Os
 .Sh NAME
@@ -56,6 +56,8 @@ kernel configuration file:
 .Fn kmsan_check_ccb "const union ccb *" "const char *descr"
 .Ft void
 .Fn kmsan_check_mbuf "const struct mbuf *" "const char *descr"
+.Ft void
+.Fn kmsan_check_uio "const struct uio *" "const char *descr"
 .Sh DESCRIPTION
 .Nm
 is a subsystem which leverages compiler instrumentation to detect uses of
@@ -306,6 +308,7 @@ f(size_t osz)
 .Xr busdma 9 ,
 .Xr copyout 9 ,
 .Xr KASAN 9 ,
+.Xr uio 9 ,
 .Xr uma 9
 .Rs
 .%A Evgeniy Stepanov
diff --git a/sys/kern/subr_msan.c b/sys/kern/subr_msan.c
index abac71da6d64..ef3c6c10b0ba 100644
--- a/sys/kern/subr_msan.c
+++ b/sys/kern/subr_msan.c
@@ -587,6 +587,15 @@ kmsan_check_mbuf(const struct mbuf *m, const char *descr)
 	} while ((m = m->m_next) != NULL);
 }
 
+void
+kmsan_check_uio(const struct uio *uio, const char *descr)
+{
+	for (int i = 0; i < uio->uio_iovcnt; i++) {
+		kmsan_check(uio->uio_iov[i].iov_base, uio->uio_iov[i].iov_len,
+		    descr);
+	}
+}
+
 void
 kmsan_init(void)
 {
diff --git a/sys/sys/msan.h b/sys/sys/msan.h
index 4baa71ec8113..58110d7306e6 100644
--- a/sys/sys/msan.h
+++ b/sys/sys/msan.h
@@ -50,6 +50,7 @@ union ccb;
 struct bio;
 struct mbuf;
 struct memdesc;
+struct uio;
 
 void kmsan_init(void);
 
@@ -69,6 +70,7 @@ void kmsan_check(const void *, size_t, const char *);
 void kmsan_check_bio(const struct bio *, const char *);
 void kmsan_check_ccb(const union ccb *, const char *);
 void kmsan_check_mbuf(const struct mbuf *, const char *);
+void kmsan_check_uio(const struct uio *, const char *);
 
 #else
 #define kmsan_init(u)
@@ -85,6 +87,7 @@ void kmsan_check_mbuf(const struct mbuf *, const char *);
 #define kmsan_check_bio(b, d)
 #define kmsan_check_ccb(c, d)
 #define kmsan_check_mbuf(m, d)
+#define kmsan_check_uio(u, d)
 #define	kmsan_bus_dmamap_sync(d, op)
 #endif