From: Jason Gunthorpe <jgg@nvidia.com>
To: iommu@lists.linux.dev
Cc: Lu Baolu <baolu.lu@linux.intel.com>,
Eric Auger <eric.auger@redhat.com>,
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+7574ebfe589049630608@syzkaller.appspotmail.com,
syzbot+d31adfb277377ef8fcba@syzkaller.appspotmail.com,
Yi Liu <yi.l.liu@intel.com>
Subject: Re: [PATCH rc v2 0/2] Do not UAF during iommufd_put_object()
Date: Wed, 29 Nov 2023 20:37:22 -0400 [thread overview]
Message-ID: <20231130003722.GA1395235@nvidia.com> (raw)
In-Reply-To: <0-v2-ca9e00171c5b+123-iommufd_syz4_jgg@nvidia.com>
On Wed, Nov 22, 2023 at 09:13:17AM -0400, Jason Gunthorpe wrote:
> The mixture of kernel and user space lifecycle objects continues to be
> complicated inside iommufd. The obj->destroy_rwsem is used to bring order
> to the kernel driver destruction sequence but it cannot be sequenced right
> with the other refcounts so we end up possibly UAF'ing.
>
> Fix it by using two refcounts and a wait queue to sequence the destruction
> process.
>
> v2:
> - Use refcount_inc_not_zero in both places in iommu_lock_obj() for
> robustness
> - Move the wait_event_timeout sequence into
> iommufd_object_dec_wait_shortterm()
> - Consistently dec users on the bug path to give close() a chance to
> recover
> - Change the order so if users reaches zero then we clean the xarray and
> then unlock. Wait for shortterm to reach zero outside the lock
> - Make iommufd_object_remove() non-static and use inlines to call it in
> the various cases
> - Comments
> v1: https://lore.kernel.org/r/0-v1-4c9a7fbb5702+107a-iommufd_syz4_jgg@nvidia.com
>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
>
> Jason Gunthorpe (2):
> iommufd: Add iommufd_ctx to iommufd_put_object()
> iommufd: Do not UAF during iommufd_put_object()
Applied to the rc branch with the comment updates
Jason
prev parent reply other threads:[~2023-11-30 0:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-22 13:13 [PATCH rc v2 0/2] Do not UAF during iommufd_put_object() Jason Gunthorpe
2023-11-22 13:13 ` [PATCH rc v2 1/2] iommufd: Add iommufd_ctx to iommufd_put_object() Jason Gunthorpe
2023-11-22 13:13 ` [PATCH rc v2 2/2] iommufd: Do not UAF during iommufd_put_object() Jason Gunthorpe
2023-11-24 6:48 ` Tian, Kevin
2023-11-24 12:50 ` Jason Gunthorpe
2023-11-28 7:59 ` Tian, Kevin
2023-11-29 1:03 ` Jason Gunthorpe
2023-11-30 0:37 ` 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=20231130003722.GA1395235@nvidia.com \
--to=jgg@nvidia.com \
--cc=baolu.lu@linux.intel.com \
--cc=eric.auger@redhat.com \
--cc=iommu@lists.linux.dev \
--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+7574ebfe589049630608@syzkaller.appspotmail.com \
--cc=syzbot+d31adfb277377ef8fcba@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