Skip to content

Commit d5dfe4f

Browse files
committed
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma
Pull rdma fixes from Jason Gunthorpe: "A few minor bug fixes for user visible defects, and one regression: - Various bugs from static checkers and syzkaller - Add missing error checking in mlx4 - Prevent RTNL lock recursion in i40iw - Fix segfault in cxgb4 in peer abort cases - Fix a regression added in 5.7 where the IB_EVENT_DEVICE_FATAL could be lost, and wasn't delivered to all the FDs" * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma: RDMA/uverbs: Move IB_EVENT_DEVICE_FATAL to destroy_uobj RDMA/uverbs: Do not discard the IB_EVENT_DEVICE_FATAL event RDMA/iw_cxgb4: Fix incorrect function parameters RDMA/core: Fix double put of resource IB/core: Fix potential NULL pointer dereference in pkey cache IB/hfi1: Fix another case where pq is left on waitlist IB/i40iw: Remove bogus call to netdev_master_upper_dev_get() IB/mlx4: Test return value of calls to ib_get_cached_pkey RDMA/rxe: Always return ERR_PTR from rxe_create_mmap_info() i40iw: Fix error handling in i40iw_manage_arp_cache()
2 parents ce24729 + ccfdbaa commit d5dfe4f

File tree

13 files changed

+68
-39
lines changed

13 files changed

+68
-39
lines changed

drivers/infiniband/core/cache.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,8 +1553,11 @@ int ib_cache_setup_one(struct ib_device *device)
15531553
if (err)
15541554
return err;
15551555

1556-
rdma_for_each_port (device, p)
1557-
ib_cache_update(device, p, true);
1556+
rdma_for_each_port (device, p) {
1557+
err = ib_cache_update(device, p, true);
1558+
if (err)
1559+
return err;
1560+
}
15581561

15591562
return 0;
15601563
}

drivers/infiniband/core/nldev.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,11 +1292,10 @@ static int res_get_common_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
12921292
has_cap_net_admin = netlink_capable(skb, CAP_NET_ADMIN);
12931293

12941294
ret = fill_func(msg, has_cap_net_admin, res, port);
1295-
1296-
rdma_restrack_put(res);
12971295
if (ret)
12981296
goto err_free;
12991297

1298+
rdma_restrack_put(res);
13001299
nlmsg_end(msg, nlh);
13011300
ib_device_put(device);
13021301
return rdma_nl_unicast(sock_net(skb->sk), msg, NETLINK_CB(skb).portid);

drivers/infiniband/core/rdma_core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,8 @@ alloc_begin_fd_uobject(const struct uverbs_api_object *obj,
459459
struct ib_uobject *uobj;
460460
struct file *filp;
461461

462-
if (WARN_ON(fd_type->fops->release != &uverbs_uobject_fd_release))
462+
if (WARN_ON(fd_type->fops->release != &uverbs_uobject_fd_release &&
463+
fd_type->fops->release != &uverbs_async_event_release))
463464
return ERR_PTR(-EINVAL);
464465

465466
new_fd = get_unused_fd_flags(O_CLOEXEC);

drivers/infiniband/core/uverbs.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ void ib_uverbs_init_event_queue(struct ib_uverbs_event_queue *ev_queue);
219219
void ib_uverbs_init_async_event_file(struct ib_uverbs_async_event_file *ev_file);
220220
void ib_uverbs_free_event_queue(struct ib_uverbs_event_queue *event_queue);
221221
void ib_uverbs_flow_resources_free(struct ib_uflow_resources *uflow_res);
222+
int uverbs_async_event_release(struct inode *inode, struct file *filp);
222223

223224
int ib_alloc_ucontext(struct uverbs_attr_bundle *attrs);
224225
int ib_init_ucontext(struct uverbs_attr_bundle *attrs);
@@ -227,6 +228,9 @@ void ib_uverbs_release_ucq(struct ib_uverbs_completion_event_file *ev_file,
227228
struct ib_ucq_object *uobj);
228229
void ib_uverbs_release_uevent(struct ib_uevent_object *uobj);
229230
void ib_uverbs_release_file(struct kref *ref);
231+
void ib_uverbs_async_handler(struct ib_uverbs_async_event_file *async_file,
232+
__u64 element, __u64 event,
233+
struct list_head *obj_list, u32 *counter);
230234

231235
void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context);
232236
void ib_uverbs_cq_event_handler(struct ib_event *event, void *context_ptr);

drivers/infiniband/core/uverbs_main.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ const struct file_operations uverbs_async_event_fops = {
346346
.owner = THIS_MODULE,
347347
.read = ib_uverbs_async_event_read,
348348
.poll = ib_uverbs_async_event_poll,
349-
.release = uverbs_uobject_fd_release,
349+
.release = uverbs_async_event_release,
350350
.fasync = ib_uverbs_async_event_fasync,
351351
.llseek = no_llseek,
352352
};
@@ -386,10 +386,9 @@ void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context)
386386
kill_fasync(&ev_queue->async_queue, SIGIO, POLL_IN);
387387
}
388388

389-
static void
390-
ib_uverbs_async_handler(struct ib_uverbs_async_event_file *async_file,
391-
__u64 element, __u64 event, struct list_head *obj_list,
392-
u32 *counter)
389+
void ib_uverbs_async_handler(struct ib_uverbs_async_event_file *async_file,
390+
__u64 element, __u64 event,
391+
struct list_head *obj_list, u32 *counter)
393392
{
394393
struct ib_uverbs_event *entry;
395394
unsigned long flags;
@@ -1187,9 +1186,6 @@ static void ib_uverbs_free_hw_resources(struct ib_uverbs_device *uverbs_dev,
11871186
*/
11881187
mutex_unlock(&uverbs_dev->lists_mutex);
11891188

1190-
ib_uverbs_async_handler(READ_ONCE(file->async_file), 0,
1191-
IB_EVENT_DEVICE_FATAL, NULL, NULL);
1192-
11931189
uverbs_destroy_ufile_hw(file, RDMA_REMOVE_DRIVER_REMOVE);
11941190
kref_put(&file->ref, ib_uverbs_release_file);
11951191

drivers/infiniband/core/uverbs_std_types_async_fd.c

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,38 @@ static int uverbs_async_event_destroy_uobj(struct ib_uobject *uobj,
2626
container_of(uobj, struct ib_uverbs_async_event_file, uobj);
2727

2828
ib_unregister_event_handler(&event_file->event_handler);
29-
ib_uverbs_free_event_queue(&event_file->ev_queue);
29+
30+
if (why == RDMA_REMOVE_DRIVER_REMOVE)
31+
ib_uverbs_async_handler(event_file, 0, IB_EVENT_DEVICE_FATAL,
32+
NULL, NULL);
3033
return 0;
3134
}
3235

36+
int uverbs_async_event_release(struct inode *inode, struct file *filp)
37+
{
38+
struct ib_uverbs_async_event_file *event_file;
39+
struct ib_uobject *uobj = filp->private_data;
40+
int ret;
41+
42+
if (!uobj)
43+
return uverbs_uobject_fd_release(inode, filp);
44+
45+
event_file =
46+
container_of(uobj, struct ib_uverbs_async_event_file, uobj);
47+
48+
/*
49+
* The async event FD has to deliver IB_EVENT_DEVICE_FATAL even after
50+
* disassociation, so cleaning the event list must only happen after
51+
* release. The user knows it has reached the end of the event stream
52+
* when it sees IB_EVENT_DEVICE_FATAL.
53+
*/
54+
uverbs_uobject_get(uobj);
55+
ret = uverbs_uobject_fd_release(inode, filp);
56+
ib_uverbs_free_event_queue(&event_file->ev_queue);
57+
uverbs_uobject_put(uobj);
58+
return ret;
59+
}
60+
3361
DECLARE_UVERBS_NAMED_METHOD(
3462
UVERBS_METHOD_ASYNC_EVENT_ALLOC,
3563
UVERBS_ATTR_FD(UVERBS_ATTR_ASYNC_EVENT_ALLOC_FD_HANDLE,

drivers/infiniband/hw/cxgb4/cm.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2891,8 +2891,7 @@ static int peer_abort(struct c4iw_dev *dev, struct sk_buff *skb)
28912891
srqidx = ABORT_RSS_SRQIDX_G(
28922892
be32_to_cpu(req->srqidx_status));
28932893
if (srqidx) {
2894-
complete_cached_srq_buffers(ep,
2895-
req->srqidx_status);
2894+
complete_cached_srq_buffers(ep, srqidx);
28962895
} else {
28972896
/* Hold ep ref until finish_peer_abort() */
28982897
c4iw_get_ep(&ep->com);
@@ -3878,8 +3877,8 @@ static int read_tcb_rpl(struct c4iw_dev *dev, struct sk_buff *skb)
38783877
return 0;
38793878
}
38803879

3881-
ep->srqe_idx = t4_tcb_get_field32(tcb, TCB_RQ_START_W, TCB_RQ_START_W,
3882-
TCB_RQ_START_S);
3880+
ep->srqe_idx = t4_tcb_get_field32(tcb, TCB_RQ_START_W, TCB_RQ_START_M,
3881+
TCB_RQ_START_S);
38833882
cleanup:
38843883
pr_debug("ep %p tid %u %016x\n", ep, ep->hwtid, ep->srqe_idx);
38853884

drivers/infiniband/hw/hfi1/user_sdma.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -589,10 +589,6 @@ int hfi1_user_sdma_process_request(struct hfi1_filedata *fd,
589589

590590
set_comp_state(pq, cq, info.comp_idx, QUEUED, 0);
591591
pq->state = SDMA_PKT_Q_ACTIVE;
592-
/* Send the first N packets in the request to buy us some time */
593-
ret = user_sdma_send_pkts(req, pcount);
594-
if (unlikely(ret < 0 && ret != -EBUSY))
595-
goto free_req;
596592

597593
/*
598594
* This is a somewhat blocking send implementation.

drivers/infiniband/hw/i40iw/i40iw_cm.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1987,7 +1987,6 @@ static int i40iw_addr_resolve_neigh(struct i40iw_device *iwdev,
19871987
struct rtable *rt;
19881988
struct neighbour *neigh;
19891989
int rc = arpindex;
1990-
struct net_device *netdev = iwdev->netdev;
19911990
__be32 dst_ipaddr = htonl(dst_ip);
19921991
__be32 src_ipaddr = htonl(src_ip);
19931992

@@ -1997,9 +1996,6 @@ static int i40iw_addr_resolve_neigh(struct i40iw_device *iwdev,
19971996
return rc;
19981997
}
19991998

2000-
if (netif_is_bond_slave(netdev))
2001-
netdev = netdev_master_upper_dev_get(netdev);
2002-
20031999
neigh = dst_neigh_lookup(&rt->dst, &dst_ipaddr);
20042000

20052001
rcu_read_lock();
@@ -2065,7 +2061,6 @@ static int i40iw_addr_resolve_neigh_ipv6(struct i40iw_device *iwdev,
20652061
{
20662062
struct neighbour *neigh;
20672063
int rc = arpindex;
2068-
struct net_device *netdev = iwdev->netdev;
20692064
struct dst_entry *dst;
20702065
struct sockaddr_in6 dst_addr;
20712066
struct sockaddr_in6 src_addr;
@@ -2086,9 +2081,6 @@ static int i40iw_addr_resolve_neigh_ipv6(struct i40iw_device *iwdev,
20862081
return rc;
20872082
}
20882083

2089-
if (netif_is_bond_slave(netdev))
2090-
netdev = netdev_master_upper_dev_get(netdev);
2091-
20922084
neigh = dst_neigh_lookup(dst, dst_addr.sin6_addr.in6_u.u6_addr32);
20932085

20942086
rcu_read_lock();

drivers/infiniband/hw/i40iw/i40iw_hw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ void i40iw_manage_arp_cache(struct i40iw_device *iwdev,
534534
int arp_index;
535535

536536
arp_index = i40iw_arp_table(iwdev, ip_addr, ipv4, mac_addr, action);
537-
if (arp_index == -1)
537+
if (arp_index < 0)
538538
return;
539539
cqp_request = i40iw_get_cqp_request(&iwdev->cqp, false);
540540
if (!cqp_request)

0 commit comments

Comments
 (0)