RE: [PATCH rdma-next 1/8] IB/core: Convert ah_attr from OPA to IB when copying to user

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

 



> -void ib_copy_ah_attr_to_user(struct ib_uverbs_ah_attr *dst,
> -			     struct rdma_ah_attr *src)
> +static int rdma_ah_conv_opa_to_ib(struct ib_device *dev,
> +				  struct rdma_ah_attr *ib,
> +				  struct rdma_ah_attr *opa)
>  {
> +	struct ib_port_attr port_attr;
> +
> +	if (ib_query_port(dev, opa->port_num, &port_attr))
> +		return -EINVAL;
> +
> +	/* Do structure copy and the over-write fields */
> +	*ib = *opa;
> +
> +	ib->type = RDMA_AH_ATTR_TYPE_IB;
> +	rdma_ah_set_grh(ib, NULL, 0, 0, 1, 0);
> +	rdma_ah_set_subnet_prefix(ib,
> cpu_to_be64(port_attr.subnet_prefix));
> +	rdma_ah_set_interface_id(ib,
> OPA_MAKE_ID(rdma_ah_get_dlid(opa)));
> +	return 0;
> +}
> +
> +void ib_copy_ah_attr_to_user(struct ib_device *device,
> +			     struct ib_uverbs_ah_attr *dst,
> +			     struct rdma_ah_attr *ah_attr)
> +{
> +	struct rdma_ah_attr *src = ah_attr;
> +	struct rdma_ah_attr conv_ah;
> +
>  	memset(&dst->grh.reserved, 0, sizeof(dst->grh.reserved));
> +
> +	if ((ah_attr->type == RDMA_AH_ATTR_TYPE_OPA) &&
> +	    (rdma_ah_get_dlid(ah_attr) >=
> +	     be16_to_cpu(IB_MULTICAST_LID_BASE)) &&
> +	    (!rdma_ah_conv_opa_to_ib(device, &conv_ah, ah_attr)))

Doesn't a failure result in copying the wrong data to user space?  Can rdma_ah_conv_opa_to_ib() use some sort of default subnet prefix if query_port fails?

- Sean
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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