git: c07ebf5becae - stable/14 - kmsan: Add kmsan_check_uio()

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Thu, 14 Dec 2023 14:44:46 UTC
The branch stable/14 has been updated by markj:

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

commit c07ebf5becae76dd9843b8a835df9f7ccd65e897
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-12-06 16:31:15 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-12-14 14:44:38 +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
    
    (cherry picked from commit be5464ae233ada46a778cc82f7107a10a7d5343b)
---
 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 c82ce254f681..99ec5219d8e0 100644
--- a/share/man/man9/Makefile
+++ b/share/man/man9/Makefile
@@ -1369,6 +1369,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