From: Jason Gunthorpe Date: Thu, 9 Aug 2018 16:19:35 +0000 (+0300) Subject: IB/uverbs: Fix reading of 32 bit flags X-Git-Tag: v4.19~309^2~30 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=922983c2a1a2f679cd576eb7162f413c15a4e979;p=platform%2Fkernel%2Flinux-rpi.git IB/uverbs: Fix reading of 32 bit flags This is missing a zeroing of the high bits of flags, and is also not correct for big endian machines. Properly zero extend the 32 bit flags into the 64 bit stack variable. Reported-by: Michael J. Ruhl Fixes: bccd06223f21 ("IB/uverbs: Add UVERBS_ATTR_FLAGS_IN to the specs language") Signed-off-by: Jason Gunthorpe Signed-off-by: Leon Romanovsky Reviewed-by: Michael J. Ruhl --- diff --git a/drivers/infiniband/core/uverbs_ioctl.c b/drivers/infiniband/core/uverbs_ioctl.c index f0655a8..23ff698 100644 --- a/drivers/infiniband/core/uverbs_ioctl.c +++ b/drivers/infiniband/core/uverbs_ioctl.c @@ -535,7 +535,7 @@ int uverbs_get_flags64(u64 *to, const struct uverbs_attr_bundle *attrs_bundle, if (attr->ptr_attr.len == 8) flags = attr->ptr_attr.data; else if (attr->ptr_attr.len == 4) - memcpy(&flags, &attr->ptr_attr.data, 4); + flags = *(u32 *)&attr->ptr_attr.data; else return -EINVAL;