Blob Blame History Raw
From: Jason Gunthorpe <jgg@mellanox.com>
Date: Thu, 9 Aug 2018 19:19:35 +0300
Subject: IB/uverbs: Fix reading of 32 bit flags
Patch-mainline: v4.19-rc1
Git-commit: 922983c2a1a2f679cd576eb7162f413c15a4e979
References: bsc#1103992 FATE#326009

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 <michael.j.ruhl@intel.com>
Fixes: bccd06223f21 ("IB/uverbs: Add UVERBS_ATTR_FLAGS_IN to the specs language")
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Reviewed-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
Acked-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
---
 drivers/infiniband/core/uverbs_ioctl.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- 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 st
 	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;