Patch "vfio/mdev: Do not allow a mdev_type to have a NULL parent pointer" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    vfio/mdev: Do not allow a mdev_type to have a NULL parent pointer

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     vfio-mdev-do-not-allow-a-mdev_type-to-have-a-null-pa.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 915190a02a917a350ed34cbd1a4abedf935076d0
Author: Jason Gunthorpe <jgg@xxxxxxxxxx>
Date:   Tue Apr 6 16:40:25 2021 -0300

    vfio/mdev: Do not allow a mdev_type to have a NULL parent pointer
    
    [ Upstream commit b5a1f8921d5040bb788492bf33a66758021e4be5 ]
    
    There is a small race where the parent is NULL even though the kobj has
    already been made visible in sysfs.
    
    For instance the attribute_group is made visible in sysfs_create_files()
    and the mdev_type_attr_show() does:
    
        ret = attr->show(kobj, type->parent->dev, buf);
    
    Which will crash on NULL parent. Move the parent setup to before the type
    pointer leaves the stack frame.
    
    Fixes: 7b96953bc640 ("vfio: Mediated device Core driver")
    Reviewed-by: Christoph Hellwig <hch@xxxxxx>
    Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx>
    Reviewed-by: Max Gurtovoy <mgurtovoy@xxxxxxxxxx>
    Reviewed-by: Cornelia Huck <cohuck@xxxxxxxxxx>
    Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxx>
    Message-Id: <2-v2-d36939638fc6+d54-vfio2_jgg@xxxxxxxxxx>
    Signed-off-by: Alex Williamson <alex.williamson@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/vfio/mdev/mdev_sysfs.c b/drivers/vfio/mdev/mdev_sysfs.c
index 917fd84c1c6f..367ff5412a38 100644
--- a/drivers/vfio/mdev/mdev_sysfs.c
+++ b/drivers/vfio/mdev/mdev_sysfs.c
@@ -105,6 +105,7 @@ static struct mdev_type *add_mdev_supported_type(struct mdev_parent *parent,
 		return ERR_PTR(-ENOMEM);
 
 	type->kobj.kset = parent->mdev_types_kset;
+	type->parent = parent;
 
 	ret = kobject_init_and_add(&type->kobj, &mdev_type_ktype, NULL,
 				   "%s-%s", dev_driver_string(parent->dev),
@@ -132,7 +133,6 @@ static struct mdev_type *add_mdev_supported_type(struct mdev_parent *parent,
 	}
 
 	type->group = group;
-	type->parent = parent;
 	return type;
 
 attrs_failed:



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux