[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250905133136.GD616306@nvidia.com>
Date: Fri, 5 Sep 2025 10:31:36 -0300
From: Jason Gunthorpe <jgg@...dia.com>
To: ankita@...dia.com
Cc: alex.williamson@...hat.com, yishaih@...dia.com, skolothumtho@...dia.com,
kevin.tian@...el.com, yi.l.liu@...el.com, zhiw@...dia.com,
aniketa@...dia.com, cjia@...dia.com, kwankhede@...dia.com,
targupta@...dia.com, vsethi@...dia.com, acurrid@...dia.com,
apopple@...dia.com, jhubbard@...dia.com, danw@...dia.com,
anuaggarwal@...dia.com, mochs@...dia.com, kjaju@...dia.com,
dnigam@...dia.com, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [RFC 07/14] vfio/nvgrace-egm: Register auxiliary driver ops
On Thu, Sep 04, 2025 at 04:08:21AM +0000, ankita@...dia.com wrote:
> +static const struct auxiliary_device_id egm_id_table[] = {
> + { .name = "nvgrace_gpu_vfio_pci.egm" },
> + { .name = "nvidia_vgpu_vfio.egm" },
Not in tree
> static char *egm_devnode(const struct device *device, umode_t *mode)
> {
> if (mode)
> @@ -35,19 +59,28 @@ static int __init nvgrace_egm_init(void)
>
> class = class_create(NVGRACE_EGM_DEV_NAME);
> if (IS_ERR(class)) {
> - unregister_chrdev_region(dev, MAX_EGM_NODES);
> - return PTR_ERR(class);
> + ret = PTR_ERR(class);
> + goto unregister_chrdev;
> }
>
> class->devnode = egm_devnode;
>
> - return 0;
> + ret = auxiliary_driver_register(&egm_driver);
> + if (!ret)
> + goto fn_exit;
> +
> + class_destroy(class);
> +unregister_chrdev:
> + unregister_chrdev_region(dev, MAX_EGM_NODES);
> +fn_exit:
> + return ret;
> }
>
> static void __exit nvgrace_egm_cleanup(void)
> {
> class_destroy(class);
> unregister_chrdev_region(dev, MAX_EGM_NODES);
> + auxiliary_driver_unregister(&egm_driver);
> }
Out of order, the order should be the reverse of init. This will UAF
the class as-is.
Jason
Powered by blists - more mailing lists