Re: [RFC rdma-next 09/11] RDMA/restrack: Translate from ID to restrack object

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

 



On Thu, Jan 03, 2019 at 10:05:57AM +0200, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@xxxxxxxxxxxx>
> 
> Add new general helper to get restrack entry given by ID and
> their respective type.
> 
> Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx>
>  drivers/infiniband/core/restrack.c | 13 +++++++++++++
>  include/rdma/restrack.h            | 11 +++++++++++
>  2 files changed, 24 insertions(+)
> 
> diff --git a/drivers/infiniband/core/restrack.c b/drivers/infiniband/core/restrack.c
> index 473422da0856..d65758a3a7b6 100644
> +++ b/drivers/infiniband/core/restrack.c
> @@ -249,6 +249,19 @@ int __must_check rdma_restrack_get(struct rdma_restrack_entry *res)
>  }
>  EXPORT_SYMBOL(rdma_restrack_get);
> 
> +struct rdma_restrack_entry *
> +rdma_restrack_get_byid(struct rdma_restrack_root *rt,
> +		       enum rdma_restrack_type type, u32 id)
> +{
> +	struct rdma_restrack_entry *res;
> +
> +	res = xa_load(&rt->xa[type], id);

the previous patch did:

+	id = res_to_id(res);
+	ret = xa_insert(&dev->res.xa[res->type], id, res, GFP_KERNEL);

Where res_to_id() returns a pointer casted to an unsigned long - so
the use of 'u32 id' is wrong here.

Also, it seems to expose kernel pointers to user space, which is a
security no-no.

I think this needs actual device-unique IDs for all objects, no use of
pointers.

Probably better to use the xarray in the IDR mode and have it generate
unique ID's for all the cases where a HW ID is not already present.

Jason




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux