IB/core: Split uverbs_get_const/default to consider target type
authorYishai Hadas <yishaih@nvidia.com>
Thu, 4 Mar 2021 13:05:00 +0000 (15:05 +0200)
committerJason Gunthorpe <jgg@nvidia.com>
Fri, 12 Mar 2021 00:20:36 +0000 (20:20 -0400)
commit2904bb37b35d07be7bfa3fb4a0fc1a3daa6678b3
tree13b31401b907cc38deebf0327e1ab35d76b40c66
parent3f32dc0f4601b180bbfd7b5adc7f82557f1408d0
IB/core: Split uverbs_get_const/default to consider target type

Change uverbs_get_const/uverbs_get_const_default to work properly with
both signed/unsigned parameters.

Current APIs mix s64 and u64 which leads to incorrect check when u64
value was supplied and its upper bit was set. In that case
uverbs_get_const() / uverbs_get_const_default() lower bound check may
fail unexpectedly, target is unsigned (lower bound is 0) but value
became negative as of the s64 usage.

Split to have two different APIs, no change to callers as the required
API will be called internally according to the target type.

Link: https://lore.kernel.org/r/20210304130501.1102577-3-leon@kernel.org
Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/core/uverbs_ioctl.c
drivers/infiniband/hw/mlx5/main.c
include/rdma/uverbs_ioctl.h