RDMA fixes for 4.15
Subsystems (3)
cover RDMA fixes for 4.15
The patches from Daniel are targeted for stable@.
The patches are available in the git repository at:
git.kernel.org/pub/scm/linux/kernel/git/leon/linux-rdma.git tags/rdma-rc-2017-12-05
Thanks
---------------------------------------
Daniel Jurgens (2):
IB/core: Bound check alternate path port number IB/core: Don't enforce PKey security on SMI MADs
Guy Levi (1):
IB/mlx4: Fix RSS hash fields restrictions
Leon Romanovsky (1):
RDMA/netlink: Fix general protection fault
drivers/infiniband/core/cma.c | 2 +- drivers/infiniband/core/device.c | 2 +- drivers/infiniband/core/iwcm.c | 2 +- drivers/infiniband/core/nldev.c | 2 +- drivers/infiniband/core/security.c | 7 +++++-- drivers/infiniband/core/uverbs_cmd.c | 6 ++++++ drivers/infiniband/hw/mlx4/qp.c | 26 +++++++++++++++++++------- 7 files changed, 34 insertions(+), 13 deletions(-)
--
2.15.1
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 1/4 IB/core: Bound check alternate path port number
From: Daniel Jurgens <[email protected]>
The alternate port number is used as an array index in the IB security implementation, invalid values can result in a kernel panic.
--- drivers/infiniband/core/uverbs_cmd.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/infiniband/core/uverbs_cmd.c +6 -0
@@ -1971,6 +1971,12 @@ static int modify_qp(struct ib_uverbs_file *file, goto release_qp; } +if ((cmd->base.attr_mask &IB_QP_ALT_PATH ) && + !rdma_is_port_valid (qp->device, cmd->base.alt_port_num)) { + ret = -EINVAL ; + goto release_qp; + } + attr->qp_state = cmd->base.qp_state; attr->cur_qp_state = cmd->base.cur_qp_state; attr->path_mtu = cmd->base.path_mtu;
Signature · 1 line
2.15.1
PATCH 2/4 IB/core: Don't enforce PKey security on SMI MADs
In reply to Leon RomanovskyFrom: Daniel Jurgens <[email protected]>
Per the infiniband spec an SMI MAD can have any PKey. Checking the pkey on SMI MADs is not necessary, and it seems that some older adapters using the mthca driver don't follow the convention of using the default PKey, resulting in false denials, or errors querying the PKey cache.
SMI MAD security is still enforced, only agents allowed to manage the subnet are able to receive or send SMI MADs.
--- drivers/infiniband/core/security.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/infiniband/core/security.c +5 -2
@@ -739,8 +739,11 @@ int ib_mad_enforce_security(struct ib_mad_agent_private *map, u16 pkey_index)if (!rdma_protocol_ib (map->agent.device, map->agent.port_num))return 0 ; -if (map->agent.qp->qp_type ==IB_QPT_SMI && !map->agent.smp_allowed) -return -EACCES ; +if (map->agent.qp->qp_type ==IB_QPT_SMI ) { +if (!map->agent.smp_allowed) +return -EACCES ; +return 0 ; + } return ib_security_pkey_access(map->agent.device, map->agent.port_num,
Signature · 1 line
2.15.1
PATCH 3/4 IB/mlx4: Fix RSS hash fields restrictions
In reply to a message not in the archiveFrom: Guy Levi <guyle-VPRAkNaXOzVWk0Htik3J/[email protected]>
Mistakenly the driver didn't allow RSS hash fields combinations which involve both IPv4 and IPv6 protocols. This bug caused to failures for user's use cases for RSS.
Consequently, this patch fixes this bug and allows any combination that the HW can support.
Additionally, the patch fixes the driver to return an error in case the user provides an unsupported mask for RSS hash fields.
--- drivers/infiniband/hw/mlx4/qp.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-)
drivers/infiniband/hw/mlx4/qp.c +19 -7
@@ -666,6 +666,19 @@ static int set_qp_rss(struct mlx4_ib_dev *dev, struct mlx4_ib_rss *rss_ctx,return (-EOPNOTSUPP ); } +if (ucmd->rx_hash_fields_mask & ~(MLX4_IB_RX_HASH_SRC_IPV4 | +MLX4_IB_RX_HASH_DST_IPV4 | +MLX4_IB_RX_HASH_SRC_IPV6 | +MLX4_IB_RX_HASH_DST_IPV6 | +MLX4_IB_RX_HASH_SRC_PORT_TCP | +MLX4_IB_RX_HASH_DST_PORT_TCP | +MLX4_IB_RX_HASH_SRC_PORT_UDP | +MLX4_IB_RX_HASH_DST_PORT_UDP )) { +pr_debug ("RX Hash fields_mask has unsupported mask (0x%llx)\n" , + ucmd->rx_hash_fields_mask); +return (-EOPNOTSUPP ); + } +if ((ucmd->rx_hash_fields_mask &MLX4_IB_RX_HASH_SRC_IPV4 ) && (ucmd->rx_hash_fields_mask &MLX4_IB_RX_HASH_DST_IPV4 )) { rss_ctx->flags =MLX4_RSS_IPV4 ;
@@ -691,11 +704,11 @@ static int set_qp_rss(struct mlx4_ib_dev *dev, struct mlx4_ib_rss *rss_ctx,return (-EOPNOTSUPP ); } -if (rss_ctx->flags &MLX4_RSS_IPV4 ) { +if (rss_ctx->flags &MLX4_RSS_IPV4 ) rss_ctx->flags |=MLX4_RSS_UDP_IPV4 ; - }else if (rss_ctx->flags &MLX4_RSS_IPV6 ) { +if (rss_ctx->flags &MLX4_RSS_IPV6 ) rss_ctx->flags |=MLX4_RSS_UDP_IPV6 ; - }else { +if (!(rss_ctx->flags & (MLX4_RSS_IPV6 |MLX4_RSS_IPV4 ))) {pr_debug ("RX Hash fields_mask is not supported - UDP must be set with IPv4 or IPv6\n" );return (-EOPNOTSUPP ); }
@@ -707,15 +720,14 @@ static int set_qp_rss(struct mlx4_ib_dev *dev, struct mlx4_ib_rss *rss_ctx,if ((ucmd->rx_hash_fields_mask &MLX4_IB_RX_HASH_SRC_PORT_TCP ) && (ucmd->rx_hash_fields_mask &MLX4_IB_RX_HASH_DST_PORT_TCP )) { -if (rss_ctx->flags &MLX4_RSS_IPV4 ) { +if (rss_ctx->flags &MLX4_RSS_IPV4 ) rss_ctx->flags |=MLX4_RSS_TCP_IPV4 ; - }else if (rss_ctx->flags &MLX4_RSS_IPV6 ) { +if (rss_ctx->flags &MLX4_RSS_IPV6 ) rss_ctx->flags |=MLX4_RSS_TCP_IPV6 ; - }else { +if (!(rss_ctx->flags & (MLX4_RSS_IPV6 |MLX4_RSS_IPV4 ))) {pr_debug ("RX Hash fields_mask is not supported - TCP must be set with IPv4 or IPv6\n" );return (-EOPNOTSUPP ); } - }else if ((ucmd->rx_hash_fields_mask &MLX4_IB_RX_HASH_SRC_PORT_TCP ) || (ucmd->rx_hash_fields_mask &MLX4_IB_RX_HASH_DST_PORT_TCP )) {pr_debug ("RX Hash fields_mask is not supported - both TCP SRC and DST must be set\n" );
Signature · 6 lines
2.15.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 4/4 RDMA/netlink: Fix general protection fault
In reply to a message not in the archiveFrom: Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/[email protected]>
The RDMA netlink core code checks validity of messages by ensuring that type and operand are in range. It works well for almost all clients except NLDEV, which has cb_table less than number of operands.
Request to access such operand will trigger the following kernel panic.
This patch updates all places where cb_table is declared for the consistency, but only NLDEV is actually need it.
general protection fault: 0000 [#1] SMP DEBUG_PAGEALLOC KASAN Modules linked in: CPU: 0 PID: 522 Comm: syz-executor6 Not tainted 4.13.0+ #4 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.7.5-0-ge51488c-20140602_164612-nilsson.home.kraxel.org 04/01/2014 task: ffff8800657799c0 task.stack: ffff8800695d000 RIP: 0010:rdma_nl_rcv_msg+0x13a/0x4c0 RSP: 0018:ffff8800695d7838 EFLAGS: 00010207 RAX: dffffc0000000000 RBX: 1ffff1000d2baf0b RCX: 00000000704ff4d7 RDX: 0000000000000000 RSI: ffffffff81ddb03c RDI: 00000003827fa6bc RBP: ffff8800695d7900 R08: ffffffff82ec0578 R09: 0000000000000000 R10: ffff8800695d7900 R11: 0000000000000001 R12: 000000000000001c R13: ffff880069d31e00 R14: 00000000ffffffff R15: ffff880069d357c0 FS: 00007fee6acb8700(0000) GS:ffff88006ca00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00000000201a9000 CR3: 0000000059766000 CR4: 00000000000006b0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: ? rdma_nl_multicast+0x80/0x80 rdma_nl_rcv+0x36b/0x4d0 ? ibnl_put_attr+0xc0/0xc0 netlink_unicast+0x4bd/0x6d0 ? netlink_sendskb+0x50/0x50 ? drop_futex_key_refs.isra.4+0x68/0xb0 netlink_sendmsg+0x9ab/0xbd0 ? nlmsg_notify+0x140/0x140 ? wake_up_q+0xa1/0xf0 ? drop_futex_key_refs.isra.4+0x68/0xb0 sock_sendmsg+0x88/0xd0 sock_write_iter+0x228/0x3c0 ? sock_sendmsg+0xd0/0xd0 ? do_futex+0x3e5/0xb20 ? iov_iter_init+0xaf/0x1d0 __vfs_write+0x46e/0x640 ? sched_clock_cpu+0x1b/0x190 ? __vfs_read+0x620/0x620 ? __fget+0x23a/0x390 ? rw_verify_area+0xca/0x290 vfs_write+0x192/0x490 SyS_write+0xde/0x1c0 ? SyS_read+0x1c0/0x1c0 ? trace_hardirqs_on_thunk+0x1a/0x1c entry_SYSCALL_64_fastpath+0x18/0xad RIP: 0033:0x7fee6a74a219 RSP: 002b:00007fee6acb7d58 EFLAGS: 00000212 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 0000000000638000 RCX: 00007fee6a74a219 RDX: 0000000000000078 RSI: 0000000020141000 RDI: 0000000000000006 RBP: 0000000000000046 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000212 R12: ffff8800695d7f98 R13: 0000000020141000 R14: 0000000000000006 R15: 00000000ffffffff Code: d6 48 b8 00 00 00 00 00 fc ff df 66 41 81 e4 ff 03 44 8d 72 ff 4a 8d 3c b5 c0 a6 7f 82 44 89 b5 4c ff ff ff 48 89 f9 48 c1 e9 03 <0f> b6 0c 01 48 89 f8 83 e0 07 83 c0 03 38 c8 7c 08 84 c9 0f 85 RIP: rdma_nl_rcv_msg+0x13a/0x4c0 RSP: ffff8800695d7838 ---[ end trace ba085d123959c8ec ]--- Kernel panic - not syncing: Fatal exception
--- drivers/infiniband/core/cma.c | 2 +- drivers/infiniband/core/device.c | 2 +- drivers/infiniband/core/iwcm.c | 2 +- drivers/infiniband/core/nldev.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
drivers/infiniband/core/cma.c +1 -1
@@ -4458,7 +4458,7 @@ static int cma_get_id_stats(struct sk_buff *skb, struct netlink_callback *cb)return skb->len; } -static const struct rdma_nl_cbs cma_cb_table[] = { +static const struct rdma_nl_cbs cma_cb_table[RDMA_NL_RDMA_CM_NUM_OPS ] = { [RDMA_NL_RDMA_CM_ID_STATS ] = { .dump = cma_get_id_stats}, };
drivers/infiniband/core/device.c +1 -1
@@ -1146,7 +1146,7 @@ struct net_device *ib_get_net_dev_by_params(struct ib_device *dev, }EXPORT_SYMBOL (ib_get_net_dev_by_params); -static const struct rdma_nl_cbs ibnl_ls_cb_table[] = { +static const struct rdma_nl_cbs ibnl_ls_cb_table[RDMA_NL_LS_NUM_OPS ] = { [RDMA_NL_LS_OP_RESOLVE ] = { .doit = ib_nl_handle_resolve_resp, .flags =RDMA_NL_ADMIN_PERM ,
drivers/infiniband/core/iwcm.c +1 -1
@@ -80,7 +80,7 @@ const char *__attribute_const__ iwcm_reject_msg(int reason) }EXPORT_SYMBOL (iwcm_reject_msg); -static struct rdma_nl_cbs iwcm_nl_cb_table[] = { +static struct rdma_nl_cbs iwcm_nl_cb_table[RDMA_NL_IWPM_NUM_OPS ] = { [RDMA_NL_IWPM_REG_PID ] = {.dump = iwpm_register_pid_cb}, [RDMA_NL_IWPM_ADD_MAPPING ] = {.dump = iwpm_add_mapping_cb}, [RDMA_NL_IWPM_QUERY_MAPPING ] = {.dump = iwpm_add_and_query_mapping_cb},
drivers/infiniband/core/nldev.c +1 -1
@@ -303,7 +303,7 @@ out: cb->args[0] = idx;return skb->len; } -static const struct rdma_nl_cbs nldev_cb_table[] = { +static const struct rdma_nl_cbs nldev_cb_table[RDMA_NLDEV_NUM_OPS ] = { [RDMA_NLDEV_CMD_GET ] = { .doit = nldev_get_doit, .dump = nldev_get_dumpit,
Signature · 6 lines
2.15.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 27 lines · Leon Romanovsky
The patches from Daniel are targeted for stable@.
The patches are available in the git repository at:
git.kernel.org/pub/scm/linux/kernel/git/leon/linux-rdma.git tags/rdma-rc-2017-12-05Thanks
---------------------------------------Daniel Jurgens (2):
IB/core: Bound check alternate path port number IB/core: Don't enforce PKey security on SMI MADsGuy Levi (1):
IB/mlx4: Fix RSS hash fields restrictionsLeon Romanovsky (1):
RDMA/netlink: Fix general protection faultdrivers/infiniband/core/cma.c | 2 +- drivers/infiniband/core/device.c | 2 +- drivers/infiniband/core/iwcm.c | 2 +- drivers/infiniband/core/nldev.c | 2 +- drivers/infiniband/core/security.c | 7 +++++-- drivers/infiniband/core/uverbs_cmd.c | 6 ++++++ drivers/infiniband/hw/mlx4/qp.c | 26 +++++++++++++++++++------- 7 files changed, 34 insertions(+), 13 deletions(-)
Quoted 3 lines
--
2.15.1
Thanks Leon, applied to -rc.
Signature · 3 lines
Doug Ledford <[email protected]> GPG KeyID: B826A3330E572FDD Key fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD