aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/socket.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-09-04 15:45:11 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-09-04 15:45:11 -0400
commit28619527b8a712590c93d0a9e24b4425b9376a8c (patch)
treed27f7ae2341049d2f41c97bcb3071b081dc97c66 /net/tipc/socket.c
parent60c1f89241d49bacf71035470684a8d7b4bb46ea (diff)
parenta33710bdb6b284f8f1e24f1119d167037b374ebb (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: 1) Must perform TXQ teardown before unregistering interfaces in mac80211, from Toke Høiland-Jørgensen. 2) Don't allow creating mac80211_hwsim with less than one channel, from Johannes Berg. 3) Division by zero in cfg80211, fix from Johannes Berg. 4) Fix endian issue in tipc, from Haiqing Bai. 5) BPF sockmap use-after-free fixes from Daniel Borkmann. 6) Spectre-v1 in mac80211_hwsim, from Jinbum Park. 7) Missing rhashtable_walk_exit() in tipc, from Cong Wang. 8) Revert kvzalloc() conversion of AF_PACKET, it breaks mmap() when kvzalloc() tries to use kmalloc() pages. From Eric Dumazet. 9) Fix deadlock in hv_netvsc, from Dexuan Cui. 10) Do not restart timewait timer on RST, from Florian Westphal. 11) Fix double lwstate refcount grab in ipv6, from Alexey Kodanev. 12) Unsolicit report count handling is off-by-one, fix from Hangbin Liu. 13) Sleep-in-atomic in cadence driver, from Jia-Ju Bai. 14) Respect ttl-inherit in ip6 tunnel driver, from Hangbin Liu. 15) Use-after-free in act_ife, fix from Cong Wang. 16) Missing hold to meta module in act_ife, from Vlad Buslov. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (91 commits) net: phy: sfp: Handle unimplemented hwmon limits and alarms net: sched: action_ife: take reference to meta module act_ife: fix a potential use-after-free net/mlx5: Fix SQ offset in QPs with small RQ tipc: correct spelling errors for tipc_topsrv_queue_evt() comments tipc: correct spelling errors for struct tipc_bc_base's comment bnxt_en: Do not adjust max_cp_rings by the ones used by RDMA. bnxt_en: Clean up unused functions. bnxt_en: Fix firmware signaled resource change logic in open. sctp: not traverse asoc trans list if non-ipv6 trans exists for ipv6_flowlabel sctp: fix invalid reference to the index variable of the iterator net/ibm/emac: wrong emac_calc_base call was used by typo net: sched: null actions array pointer before releasing action vhost: fix VHOST_GET_BACKEND_FEATURES ioctl request definition r8169: add support for NCube 8168 network card ip6_tunnel: respect ttl inherit for ip6tnl mac80211: shorten the IBSS debug messages mac80211: don't Tx a deauth frame if the AP forbade Tx mac80211: Fix station bandwidth setting after channel switch mac80211: fix a race between restart and CSA flows ...
Diffstat (limited to 'net/tipc/socket.c')
-rw-r--r--net/tipc/socket.c78
1 files changed, 52 insertions, 26 deletions
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index c1e93c9515bc..ab7a2a7178f7 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -2672,6 +2672,8 @@ void tipc_sk_reinit(struct net *net)
2672 2672
2673 rhashtable_walk_stop(&iter); 2673 rhashtable_walk_stop(&iter);
2674 } while (tsk == ERR_PTR(-EAGAIN)); 2674 } while (tsk == ERR_PTR(-EAGAIN));
2675
2676 rhashtable_walk_exit(&iter);
2675} 2677}
2676 2678
2677static struct tipc_sock *tipc_sk_lookup(struct net *net, u32 portid) 2679static struct tipc_sock *tipc_sk_lookup(struct net *net, u32 portid)
@@ -3227,45 +3229,69 @@ int tipc_nl_sk_walk(struct sk_buff *skb, struct netlink_callback *cb,
3227 struct netlink_callback *cb, 3229 struct netlink_callback *cb,
3228 struct tipc_sock *tsk)) 3230 struct tipc_sock *tsk))
3229{ 3231{
3230 struct net *net = sock_net(skb->sk); 3232 struct rhashtable_iter *iter = (void *)cb->args[0];
3231 struct tipc_net *tn = tipc_net(net);
3232 const struct bucket_table *tbl;
3233 u32 prev_portid = cb->args[1];
3234 u32 tbl_id = cb->args[0];
3235 struct rhash_head *pos;
3236 struct tipc_sock *tsk; 3233 struct tipc_sock *tsk;
3237 int err; 3234 int err;
3238 3235
3239 rcu_read_lock(); 3236 rhashtable_walk_start(iter);
3240 tbl = rht_dereference_rcu((&tn->sk_rht)->tbl, &tn->sk_rht); 3237 while ((tsk = rhashtable_walk_next(iter)) != NULL) {
3241 for (; tbl_id < tbl->size; tbl_id++) { 3238 if (IS_ERR(tsk)) {
3242 rht_for_each_entry_rcu(tsk, pos, tbl, tbl_id, node) { 3239 err = PTR_ERR(tsk);
3243 spin_lock_bh(&tsk->sk.sk_lock.slock); 3240 if (err == -EAGAIN) {
3244 if (prev_portid && prev_portid != tsk->portid) { 3241 err = 0;
3245 spin_unlock_bh(&tsk->sk.sk_lock.slock);
3246 continue; 3242 continue;
3247 } 3243 }
3244 break;
3245 }
3248 3246
3249 err = skb_handler(skb, cb, tsk); 3247 sock_hold(&tsk->sk);
3250 if (err) { 3248 rhashtable_walk_stop(iter);
3251 prev_portid = tsk->portid; 3249 lock_sock(&tsk->sk);
3252 spin_unlock_bh(&tsk->sk.sk_lock.slock); 3250 err = skb_handler(skb, cb, tsk);
3253 goto out; 3251 if (err) {
3254 } 3252 release_sock(&tsk->sk);
3255 3253 sock_put(&tsk->sk);
3256 prev_portid = 0; 3254 goto out;
3257 spin_unlock_bh(&tsk->sk.sk_lock.slock);
3258 } 3255 }
3256 release_sock(&tsk->sk);
3257 rhashtable_walk_start(iter);
3258 sock_put(&tsk->sk);
3259 } 3259 }
3260 rhashtable_walk_stop(iter);
3260out: 3261out:
3261 rcu_read_unlock();
3262 cb->args[0] = tbl_id;
3263 cb->args[1] = prev_portid;
3264
3265 return skb->len; 3262 return skb->len;
3266} 3263}
3267EXPORT_SYMBOL(tipc_nl_sk_walk); 3264EXPORT_SYMBOL(tipc_nl_sk_walk);
3268 3265
3266int tipc_dump_start(struct netlink_callback *cb)
3267{
3268 struct rhashtable_iter *iter = (void *)cb->args[0];
3269 struct net *net = sock_net(cb->skb->sk);
3270 struct tipc_net *tn = tipc_net(net);
3271
3272 if (!iter) {
3273 iter = kmalloc(sizeof(*iter), GFP_KERNEL);
3274 if (!iter)
3275 return -ENOMEM;
3276
3277 cb->args[0] = (long)iter;
3278 }
3279
3280 rhashtable_walk_enter(&tn->sk_rht, iter);
3281 return 0;
3282}
3283EXPORT_SYMBOL(tipc_dump_start);
3284
3285int tipc_dump_done(struct netlink_callback *cb)
3286{
3287 struct rhashtable_iter *hti = (void *)cb->args[0];
3288
3289 rhashtable_walk_exit(hti);
3290 kfree(hti);
3291 return 0;
3292}
3293EXPORT_SYMBOL(tipc_dump_done);
3294
3269int tipc_sk_fill_sock_diag(struct sk_buff *skb, struct netlink_callback *cb, 3295int tipc_sk_fill_sock_diag(struct sk_buff *skb, struct netlink_callback *cb,
3270 struct tipc_sock *tsk, u32 sk_filter_state, 3296 struct tipc_sock *tsk, u32 sk_filter_state,
3271 u64 (*tipc_diag_gen_cookie)(struct sock *sk)) 3297 u64 (*tipc_diag_gen_cookie)(struct sock *sk))