public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] IB/core: Fix different types mix in ib_device_cap_flags structure values
@ 2016-05-30 10:09 Max Gurtovoy
       [not found] ` <1464602994-21226-1-git-send-email-maxg-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
  2016-05-31 15:36 ` Bart Van Assche
  0 siblings, 2 replies; 16+ messages in thread
From: Max Gurtovoy @ 2016-05-30 10:09 UTC (permalink / raw)
  To: matanb, leon, sagi, linux-rdma; +Cc: stable, Max Gurtovoy

ib_device_cap_flags 64-bit expansion caused a possible caps overlapping
(depending on machine endianness) and made consumers read wrong device
capabilities. For example IB_DEVICE_SG_GAPS_REG was falsely read by the
iser driver causing it to use a non-existing capability. Fix this by
casting ib_device_cap_flags enumerations to ULL.

Fixes: 45686f2d6535 ('IB/core: Add Raw Scatter FCS device capability')
Fixes: 50174a7f2c24 ('IB/core: Add interfaces to control VF attributes')
Fixes: f5aa9159a418 ('IB/core: Add arbitrary sg_list support')
Fixes: fb532d6a79b9 ('IB/{core, ulp} Support above 32 possible device capability flags')
Reported-by: Robert LeBlanc <robert@leblancnet.us>
Cc: Stable <stable@vger.kernel.org> [v4.6+]
Acked-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Max Gurtovoy <maxg@mellanox.com>
Signed-off-by: Matan Barak <matanb@mellanox.com>
---
 include/rdma/ib_verbs.h |   66 +++++++++++++++++++++++-----------------------
 1 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 432bed5..8bb97dc 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -156,21 +156,21 @@ enum rdma_link_layer {
 };
 
 enum ib_device_cap_flags {
-	IB_DEVICE_RESIZE_MAX_WR			= (1 << 0),
-	IB_DEVICE_BAD_PKEY_CNTR			= (1 << 1),
-	IB_DEVICE_BAD_QKEY_CNTR			= (1 << 2),
-	IB_DEVICE_RAW_MULTI			= (1 << 3),
-	IB_DEVICE_AUTO_PATH_MIG			= (1 << 4),
-	IB_DEVICE_CHANGE_PHY_PORT		= (1 << 5),
-	IB_DEVICE_UD_AV_PORT_ENFORCE		= (1 << 6),
-	IB_DEVICE_CURR_QP_STATE_MOD		= (1 << 7),
-	IB_DEVICE_SHUTDOWN_PORT			= (1 << 8),
-	IB_DEVICE_INIT_TYPE			= (1 << 9),
-	IB_DEVICE_PORT_ACTIVE_EVENT		= (1 << 10),
-	IB_DEVICE_SYS_IMAGE_GUID		= (1 << 11),
-	IB_DEVICE_RC_RNR_NAK_GEN		= (1 << 12),
-	IB_DEVICE_SRQ_RESIZE			= (1 << 13),
-	IB_DEVICE_N_NOTIFY_CQ			= (1 << 14),
+	IB_DEVICE_RESIZE_MAX_WR			= (1ULL << 0),
+	IB_DEVICE_BAD_PKEY_CNTR			= (1ULL << 1),
+	IB_DEVICE_BAD_QKEY_CNTR			= (1ULL << 2),
+	IB_DEVICE_RAW_MULTI			= (1ULL << 3),
+	IB_DEVICE_AUTO_PATH_MIG			= (1ULL << 4),
+	IB_DEVICE_CHANGE_PHY_PORT		= (1ULL << 5),
+	IB_DEVICE_UD_AV_PORT_ENFORCE		= (1ULL << 6),
+	IB_DEVICE_CURR_QP_STATE_MOD		= (1ULL << 7),
+	IB_DEVICE_SHUTDOWN_PORT			= (1ULL << 8),
+	IB_DEVICE_INIT_TYPE			= (1ULL << 9),
+	IB_DEVICE_PORT_ACTIVE_EVENT		= (1ULL << 10),
+	IB_DEVICE_SYS_IMAGE_GUID		= (1ULL << 11),
+	IB_DEVICE_RC_RNR_NAK_GEN		= (1ULL << 12),
+	IB_DEVICE_SRQ_RESIZE			= (1ULL << 13),
+	IB_DEVICE_N_NOTIFY_CQ			= (1ULL << 14),
 
 	/*
 	 * This device supports a per-device lkey or stag that can be
@@ -179,9 +179,9 @@ enum ib_device_cap_flags {
 	 * instead of use the local_dma_lkey flag in the ib_pd structure,
 	 * which will always contain a usable lkey.
 	 */
-	IB_DEVICE_LOCAL_DMA_LKEY		= (1 << 15),
-	IB_DEVICE_RESERVED /* old SEND_W_INV */	= (1 << 16),
-	IB_DEVICE_MEM_WINDOW			= (1 << 17),
+	IB_DEVICE_LOCAL_DMA_LKEY		= (1ULL << 15),
+	IB_DEVICE_RESERVED /* old SEND_W_INV */	= (1ULL << 16),
+	IB_DEVICE_MEM_WINDOW			= (1ULL << 17),
 	/*
 	 * Devices should set IB_DEVICE_UD_IP_SUM if they support
 	 * insertion of UDP and TCP checksum on outgoing UD IPoIB
@@ -189,9 +189,9 @@ enum ib_device_cap_flags {
 	 * incoming messages.  Setting this flag implies that the
 	 * IPoIB driver may set NETIF_F_IP_CSUM for datagram mode.
 	 */
-	IB_DEVICE_UD_IP_CSUM			= (1 << 18),
-	IB_DEVICE_UD_TSO			= (1 << 19),
-	IB_DEVICE_XRC				= (1 << 20),
+	IB_DEVICE_UD_IP_CSUM			= (1ULL << 18),
+	IB_DEVICE_UD_TSO			= (1ULL << 19),
+	IB_DEVICE_XRC				= (1ULL << 20),
 
 	/*
 	 * This device supports the IB "base memory management extension",
@@ -202,25 +202,25 @@ enum ib_device_cap_flags {
 	 * IB_WR_RDMA_READ_WITH_INV verb for RDMA READs that invalidate the
 	 * stag.
 	 */
-	IB_DEVICE_MEM_MGT_EXTENSIONS		= (1 << 21),
-	IB_DEVICE_BLOCK_MULTICAST_LOOPBACK	= (1 << 22),
-	IB_DEVICE_MEM_WINDOW_TYPE_2A		= (1 << 23),
-	IB_DEVICE_MEM_WINDOW_TYPE_2B		= (1 << 24),
-	IB_DEVICE_RC_IP_CSUM			= (1 << 25),
-	IB_DEVICE_RAW_IP_CSUM			= (1 << 26),
+	IB_DEVICE_MEM_MGT_EXTENSIONS		= (1ULL << 21),
+	IB_DEVICE_BLOCK_MULTICAST_LOOPBACK	= (1ULL << 22),
+	IB_DEVICE_MEM_WINDOW_TYPE_2A		= (1ULL << 23),
+	IB_DEVICE_MEM_WINDOW_TYPE_2B		= (1ULL << 24),
+	IB_DEVICE_RC_IP_CSUM			= (1ULL << 25),
+	IB_DEVICE_RAW_IP_CSUM			= (1ULL << 26),
 	/*
 	 * Devices should set IB_DEVICE_CROSS_CHANNEL if they
 	 * support execution of WQEs that involve synchronization
 	 * of I/O operations with single completion queue managed
 	 * by hardware.
 	 */
-	IB_DEVICE_CROSS_CHANNEL		= (1 << 27),
-	IB_DEVICE_MANAGED_FLOW_STEERING		= (1 << 29),
-	IB_DEVICE_SIGNATURE_HANDOVER		= (1 << 30),
-	IB_DEVICE_ON_DEMAND_PAGING		= (1 << 31),
+	IB_DEVICE_CROSS_CHANNEL		= (1ULL << 27),
+	IB_DEVICE_MANAGED_FLOW_STEERING		= (1ULL << 29),
+	IB_DEVICE_SIGNATURE_HANDOVER		= (1ULL << 30),
+	IB_DEVICE_ON_DEMAND_PAGING		= (1ULL << 31),
 	IB_DEVICE_SG_GAPS_REG			= (1ULL << 32),
-	IB_DEVICE_VIRTUAL_FUNCTION		= ((u64)1 << 33),
-	IB_DEVICE_RAW_SCATTER_FCS		= ((u64)1 << 34),
+	IB_DEVICE_VIRTUAL_FUNCTION		= (1ULL << 33),
+	IB_DEVICE_RAW_SCATTER_FCS		= (1ULL << 34),
 };
 
 enum ib_signature_prot_cap {
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2016-06-01 15:35 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-30 10:09 [PATCH] IB/core: Fix different types mix in ib_device_cap_flags structure values Max Gurtovoy
     [not found] ` <1464602994-21226-1-git-send-email-maxg-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2016-05-31 15:35   ` Bart Van Assche
2016-05-31 17:13     ` Jason Gunthorpe
     [not found]       ` <20160531171306.GA6618-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-05-31 17:30         ` Leon Romanovsky
     [not found]           ` <20160531173033.GC7477-2ukJVAZIZ/Y@public.gmane.org>
2016-05-31 18:05             ` Bart Van Assche
2016-05-31 18:12               ` Leon Romanovsky
     [not found]                 ` <20160531181223.GE7477-2ukJVAZIZ/Y@public.gmane.org>
2016-05-31 18:21                   ` Jason Gunthorpe
     [not found]                     ` <20160531182100.GC21834-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-05-31 18:54                       ` Leon Romanovsky
2016-05-31 19:39                         ` Jason Gunthorpe
2016-06-01 12:04                           ` Max Gurtovoy
     [not found]                             ` <574ECF44.3070003-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2016-06-01 15:35                               ` Sagi Grimberg
2016-05-31 18:43                   ` Bart Van Assche
2016-05-31 18:16               ` Jason Gunthorpe
2016-05-31 19:16   ` Robert LeBlanc
2016-05-31 15:36 ` Bart Van Assche
     [not found]   ` <4156c03f-4977-17eb-db64-6df775b6e592-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2016-05-31 19:14     ` Max Gurtovoy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox