From: Jason Gunthorpe <jgg@nvidia.com>
To: iommu@lists.linux.dev, Joerg Roedel <joro@8bytes.org>
Cc: Kevin Tian <kevin.tian@intel.com>,
Lixiao Yang <lixiao.yang@intel.com>,
Matthew Rosato <mjrosato@linux.ibm.com>,
Nicolin Chen <nicolinc@nvidia.com>,
patches@lists.linux.dev,
syzbot+16073ebbc4c64b819b47@syzkaller.appspotmail.com,
Yi Liu <yi.l.liu@intel.com>
Subject: Re: [PATCH] iommufd: Protect against overflow of ALIGN() during iova allocation
Date: Thu, 5 Sep 2024 16:03:10 -0300 [thread overview]
Message-ID: <20240905190310.GA3474936@nvidia.com> (raw)
In-Reply-To: <0-v1-8009738b9891+1f7-iommufd_align_overflow_jgg@nvidia.com>
On Tue, Aug 27, 2024 at 01:46:45PM -0300, Jason Gunthorpe wrote:
> Userspace can supply an iova and uptr such that the target iova alignment
> becomes really big and ALIGN() overflows which corrupts the selected area
> range during allocation. CONFIG_IOMMUFD_TEST can detect this:
>
> WARNING: CPU: 1 PID: 5092 at drivers/iommu/iommufd/io_pagetable.c:268 iopt_alloc_area_pages drivers/iommu/iommufd/io_pagetable.c:268 [inline]
> WARNING: CPU: 1 PID: 5092 at drivers/iommu/iommufd/io_pagetable.c:268 iopt_map_pages+0xf95/0x1050 drivers/iommu/iommufd/io_pagetable.c:352
> Modules linked in:
> CPU: 1 PID: 5092 Comm: syz-executor294 Not tainted 6.10.0-rc5-syzkaller-00294-g3ffea9a7a6f7 #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024
> RIP: 0010:iopt_alloc_area_pages drivers/iommu/iommufd/io_pagetable.c:268 [inline]
> RIP: 0010:iopt_map_pages+0xf95/0x1050 drivers/iommu/iommufd/io_pagetable.c:352
> Code: fc e9 a4 f3 ff ff e8 1a 8b 4c fc 41 be e4 ff ff ff e9 8a f3 ff ff e8 0a 8b 4c fc 90 0f 0b 90 e9 37 f5 ff ff e8 fc 8a 4c fc 90 <0f> 0b 90 e9 68 f3 ff ff 48 c7 c1 ec 82 ad 8f 80 e1 07 80 c1 03 38
> RSP: 0018:ffffc90003ebf9e0 EFLAGS: 00010293
> RAX: ffffffff85499fa4 RBX: 00000000ffffffef RCX: ffff888079b49e00
> RDX: 0000000000000000 RSI: 00000000ffffffef RDI: 0000000000000000
> RBP: ffffc90003ebfc50 R08: ffffffff85499b30 R09: ffffffff85499942
> R10: 0000000000000002 R11: ffff888079b49e00 R12: ffff8880228e0010
> R13: 0000000000000000 R14: 1ffff920007d7f68 R15: ffffc90003ebfd00
> FS: 000055557d760380(0000) GS:ffff8880b9500000(0000) knlGS:0000000000000000
> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 00000000005fdeb8 CR3: 000000007404a000 CR4: 00000000003506f0
> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
> Call Trace:
> <TASK>
> iommufd_ioas_copy+0x610/0x7b0 drivers/iommu/iommufd/ioas.c:274
> iommufd_fops_ioctl+0x4d9/0x5a0 drivers/iommu/iommufd/main.c:421
> vfs_ioctl fs/ioctl.c:51 [inline]
> __do_sys_ioctl fs/ioctl.c:907 [inline]
> __se_sys_ioctl+0xfc/0x170 fs/ioctl.c:893
> do_syscall_x64 arch/x86/entry/common.c:52 [inline]
> do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
> entry_SYSCALL_64_after_hwframe+0x77/0x7f
>
> Cap the automatic alignment to the huge page size, which is probably a
> better idea overall. Huge automatic alignments can fragment and chew up
> the available IOVA space without any reason.
>
> Cc: stable@vger.kernel.org
> Fixes: 51fe6141f0f6 ("iommufd: Data structure to provide IOVA to PFN mapping")
> Reported-by: syzbot+16073ebbc4c64b819b47@syzkaller.appspotmail.com
> Closes: https://lore.kernel.org/r/000000000000388410061a74f014@google.com
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
> drivers/iommu/iommufd/io_pagetable.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
Applied to for-next
Thanks,
Jason
prev parent reply other threads:[~2024-09-05 19:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-27 16:46 [PATCH] iommufd: Protect against overflow of ALIGN() during iova allocation Jason Gunthorpe
2024-08-27 17:46 ` Nicolin Chen
2024-09-05 19:03 ` 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=20240905190310.GA3474936@nvidia.com \
--to=jgg@nvidia.com \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=lixiao.yang@intel.com \
--cc=mjrosato@linux.ibm.com \
--cc=nicolinc@nvidia.com \
--cc=patches@lists.linux.dev \
--cc=syzbot+16073ebbc4c64b819b47@syzkaller.appspotmail.com \
--cc=yi.l.liu@intel.com \
/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