[RFC PATCH 09/14] iommu: lazy-populate iommu_group reserved_regions/type attrs

Greg Kroah-Hartman gregkh at linuxfoundation.org
Fri Jul 10 07:19:02 PDT 2026


On Thu, Jul 02, 2026 at 07:51:09PM +0200, Pavol Sakac wrote:
> +	/*
> +	 * Defer reserved_regions and type - both are read only on
> +	 * VFIO/iommufd ioctl paths, so let the populate callbacks
> +	 * materialise them on demand.
> +	 *
> +	 * KERNFS_LAZY MUST be set before kobject_create_and_add("devices"),
> +	 * which calls kernfs_inc_rev() on this kobject's directory and
> +	 * would otherwise leave a stale negative dentry cached for a
> +	 * missing reserved_regions/type child.  WARN_ON because
> +	 * iommu_group_alloc() controls all group kobjects directly.
> +	 */
> +	WARN_ON(kernfs_set_lazy(group->kobj.sd));

You just crashed the kernel, that's not nice :(

>  	group->devices_kobj = kobject_create_and_add("devices", &group->kobj);
>  	if (!group->devices_kobj) {
>  		kobject_put(&group->kobj); /* triggers .release & free */
> @@ -1091,19 +1210,6 @@ struct iommu_group *iommu_group_alloc(void)
>  	 */
>  	kobject_put(&group->kobj);
>  
> -	ret = iommu_group_create_file(group,
> -				      &iommu_group_attr_reserved_regions);
> -	if (ret) {
> -		kobject_put(group->devices_kobj);
> -		return ERR_PTR(ret);
> -	}
> -
> -	ret = iommu_group_create_file(group, &iommu_group_attr_type);
> -	if (ret) {
> -		kobject_put(group->devices_kobj);
> -		return ERR_PTR(ret);
> -	}

Why isn't the driver core creating these properly on its own today?
These calls should not have to be done.  Also, what's up with the "raw"
kobject?  That's not ok, this is circumventing the driver core in a way
that is not going to work out at all (as you are finding here...)

thanks,

greg k-h



More information about the kexec mailing list