From: Deepanshu Kartikey <kartikey406@gmail.com>
To: jgg@ziepe.ca, kevin.tian@intel.com, joro@8bytes.org,
will@kernel.org, robin.murphy@arm.com
Cc: iommu@lists.linux.dev, Deepanshu Kartikey <kartikey406@gmail.com>,
syzbot+df28076a30d726933015@syzkaller.appspotmail.com
Subject: [PATCH] iommufd: Initialize batch->kind in batch_clear()
Date: Sat, 24 Jan 2026 18:52:14 +0530 [thread overview]
Message-ID: <20260124132214.624041-1-kartikey406@gmail.com> (raw)
KMSAN reported an uninitialized value when batch_add_pfn_num() reads
batch->kind. This occurs because batch_clear() does not initialize
the kind field, leaving it with garbage data when a struct pfn_batch
is declared on the stack.
When batch_add_pfn_num() checks "if (batch->kind != kind)", it reads
this uninitialized value, triggering KMSAN warnings.
Initialize batch->kind to zero in batch_clear() to ensure the field
always starts in a known state.
Reported-by: syzbot+df28076a30d726933015@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=df28076a30d726933015
Fixes: f394576eb11db ("iommufd: PFN handling for iopt_pages")
Tested-by: syzbot+df28076a30d726933015@syzkaller.appspotmail.com
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
drivers/iommu/iommufd/pages.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/iommu/iommufd/pages.c b/drivers/iommu/iommufd/pages.c
index dbe51ecb9a20..f606148920fa 100644
--- a/drivers/iommu/iommufd/pages.c
+++ b/drivers/iommu/iommufd/pages.c
@@ -289,6 +289,7 @@ static void batch_clear(struct pfn_batch *batch)
batch->end = 0;
batch->pfns[0] = 0;
batch->npfns[0] = 0;
+ batch->kind = 0;
}
/*
--
2.43.0
next reply other threads:[~2026-01-24 13:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-24 13:22 Deepanshu Kartikey [this message]
2026-01-26 7:56 ` [PATCH] iommufd: Initialize batch->kind in batch_clear() Tian, Kevin
2026-01-28 16:55 ` Jason Gunthorpe
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=20260124132214.624041-1-kartikey406@gmail.com \
--to=kartikey406@gmail.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=robin.murphy@arm.com \
--cc=syzbot+df28076a30d726933015@syzkaller.appspotmail.com \
--cc=will@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