]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Make abd_raidz_gen_iterate() pass an initialized pointer to the callback
authorMark Johnston <markjdb@gmail.com>
Tue, 7 Nov 2023 18:24:15 +0000 (13:24 -0500)
committerGitHub <noreply@github.com>
Tue, 7 Nov 2023 18:24:15 +0000 (10:24 -0800)
Otherwise callbacks may trigger KMSAN violations in the dlen == 0 case.
For example, raidz_syn_pq_abd() will compare an uninitialized pointer
with itself before returning.  This seems harmless, but let's maintain
good hygiene and avoid passing uninitialized variables, if only to
placate KMSAN.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Allan Jude <allan@klarasystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Mark Johnston <markj@FreeBSD.org>
Closes #15491

module/zfs/abd.c

index bcc6ddd5e81b9a9d202c69a66c75a67fbdeb0ad4..0a2411a2d572e1e38c2b0415ed16d91555bf67a9 100644 (file)
@@ -1025,7 +1025,7 @@ abd_raidz_gen_iterate(abd_t **cabds, abd_t *dabd, size_t off,
        size_t len, dlen;
        struct abd_iter caiters[3];
        struct abd_iter daiter;
-       void *caddrs[3];
+       void *caddrs[3], *daddr;
        unsigned long flags __maybe_unused = 0;
        abd_t *c_cabds[3];
        abd_t *c_dabd = NULL;
@@ -1057,10 +1057,13 @@ abd_raidz_gen_iterate(abd_t **cabds, abd_t *dabd, size_t off,
                if (dsize > 0) {
                        IMPLY(abd_is_gang(dabd), c_dabd != NULL);
                        abd_iter_map(&daiter);
+                       daddr = daiter.iter_mapaddr;
                        len = MIN(daiter.iter_mapsize, len);
                        dlen = len;
-               } else
+               } else {
+                       daddr = NULL;
                        dlen = 0;
+               }
 
                /* must be progressive */
                ASSERT3U(len, >, 0);
@@ -1070,7 +1073,7 @@ abd_raidz_gen_iterate(abd_t **cabds, abd_t *dabd, size_t off,
                 */
                ASSERT3U(((uint64_t)len & 511ULL), ==, 0);
 
-               func_raidz_gen(caddrs, daiter.iter_mapaddr, len, dlen);
+               func_raidz_gen(caddrs, daddr, len, dlen);
 
                for (i = parity-1; i >= 0; i--) {
                        abd_iter_unmap(&caiters[i]);