From: Jason Gunthorpe <jgg@ziepe.ca>
To: Edward Adam Davis <eadavis@qq.com>
Cc: syzbot+093a8a8b859472e6c257@syzkaller.appspotmail.com,
iommu@lists.linux.dev, joro@8bytes.org, kevin.tian@intel.com,
linux-kernel@vger.kernel.org, robin.murphy@arm.com,
syzkaller-bugs@googlegroups.com, will@kernel.org
Subject: Re: [PATCH] iommufd: Prevent the use of nil data
Date: Wed, 8 Oct 2025 15:10:50 -0300 [thread overview]
Message-ID: <20251008181050.GA3833649@ziepe.ca> (raw)
In-Reply-To: <tencent_E46183A88440D77C977DA6CBD37DC362A905@qq.com>
On Wed, Oct 08, 2025 at 03:53:07PM +0800, Edward Adam Davis wrote:
> The division exception occurs because:
> The denominator bitmap->bitmap is 0, which is derived from the nil value
> of bitmap->data passed in by the reproducer.
No, that just causes the reproducer to bail early. The reported
problem is divide by zero. Which is caused by this:
unsigned long pgsize = 1UL << bitmap->mapped.pgshift;
return iova / (BITS_PER_TYPE(*bitmap->bitmap) * pgsize);
// ioctl$IOMMU_HWPT_GET_DIRTY_BITMAP arguments: [
// fd: fd_iommufd (resource)
// cmd: const = 0x3b8c (4 bytes)
// arg: ptr[in, iommu_hwpt_get_dirty_bitmap] {
// iommu_hwpt_get_dirty_bitmap {
// size: len = 0x30 (4 bytes)
// hwpt_id: hwpt_handle (resource)
// flags: iommufd_hwpt_get_dirty_bitmap_flags = 0x0 (4 bytes)
// __reserved: const = 0x0 (4 bytes)
// iova: int64 = 0x0 (8 bytes)
// length: int64 = 0x0 (8 bytes)
// page_size: int64 = 0x8000000000000000 (8 bytes)
^^^^^^^^^^^^^^^^^^^^^^^^^
0x8000000000000000 * BITS_PER_TYPE(*bitmap->bitmap) == 0
It should be fixed by adjusting the logic:
+ return (iova >> bitmap->mapped.pgshift) /
+ BITS_PER_TYPE(*bitmap->bitmap);
I will send a patch.
Jason
prev parent reply other threads:[~2025-10-08 18:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-07 23:32 [syzbot] [iommu?] divide error in iova_bitmap_alloc syzbot
2025-10-08 7:53 ` [PATCH] iommufd: Prevent the use of nil data Edward Adam Davis
2025-10-08 18:10 ` Jason Gunthorpe [this message]
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=20251008181050.GA3833649@ziepe.ca \
--to=jgg@ziepe.ca \
--cc=eadavis@qq.com \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=syzbot+093a8a8b859472e6c257@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.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