History

Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net

Pull networking fixes from David Miller: 1) ICE, E1000, IGB, IXGBE, and I40E bug fixes from the Intel folks. 2) Better fix for AB-BA deadlock in packet scheduler code, from Cong Wang. 3) bpf sockmap fixes (zero sized key handling, etc.) from Daniel Borkmann. 4) Send zero IPID in TCP resets and SYN-RECV state ACKs, to prevent attackers using it as a side-channel. From Eric Dumazet. 5) Memory leak in mediatek bluetooth driver, from Gustavo A. R. Silva. 6) Hook up rt->dst.input of ipv6 anycast routes properly, from Hangbin Liu. 7) hns and hns3 bug fixes from Huazhong Tan. 8) Fix RIF leak in mlxsw driver, from Ido Schimmel. 9) iova range check fix in vhost, from Jason Wang. 10) Fix hang in do_tcp_sendpages() with tls, from John Fastabend. 11) More r8152 chips need to disable RX aggregation, from Kai-Heng Feng. 12) Memory exposure in TCA_U32_SEL handling, from Kees Cook. 13) TCP BBR congestion control fixes from Kevin Yang. 14) hv_netvsc, ignore non-PCI devices, from Stephen Hemminger. 15) qed driver fixes from Tomer Tayar. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (77 commits) net: sched: Fix memory exposure from short TCA_U32_SEL qed: fix spelling mistake "comparsion" -> "comparison" vhost: correctly check the iova range when waking virtqueue qlge: Fix netdev features configuration. net: macb: do not disable MDIO bus at open/close time Revert "net: stmmac: fix build failure due to missing COMMON_CLK dependency" net: macb: Fix regression breaking non-MDIO fixed-link PHYs mlxsw: spectrum_switchdev: Do not leak RIFs when removing bridge i40e: fix condition of WARN_ONCE for stat strings i40e: Fix for Tx timeouts when interface is brought up if DCB is enabled ixgbe: fix driver behaviour after issuing VFLR ixgbe: Prevent unsupported configurations with XDP ixgbe: Replace GFP_ATOMIC with GFP_KERNEL igb: Replace mdelay() with msleep() in igb_integrated_phy_loopback() igb: Replace GFP_ATOMIC with GFP_KERNEL in igb_sw_init() igb: Use an advanced ctx descriptor for launchtime e1000: ensure to free old tx/rx rings in set_ringparam() e1000: check on netif_running() before calling e1000_up() ixgb: use dma_zalloc_coherent instead of allocator/memset ice: Trivial formatting fixes ...

Linus Torvalds committed 8 years ago

Commit 050cdc62 parents 908946c 98c8f1292 files · +754 −711Browse files

Showing the changes to kernel (2 of 92 files). Show all

Unified · Split

2 files
  1. kernel/bpf/hashtab.c +13 −10
  2. kernel/bpf/sockmap.c +9 −2
kernel/bpf/hashtab.c+13−10
@@ -15,6 +15,7 @@ · 14 unmodified lines
1515 #include <linux/jhash.h>
1616 #include <linux/filter.h>
1717 #include <linux/rculist_nulls.h>
18+#include <linux/random.h>
1819 #include <uapi/linux/btf.h>
1920 #include "percpu_freelist.h"
2021 #include "bpf_lru_list.h"
@@ -41,6 +42,7 @@ struct bpf_htab { · 20 unmodified lines
4142 atomic_t count; /* number of elements in this hashtable */
4243 u32 n_buckets; /* number of hash buckets */
4344 u32 elem_size; /* size of each element in bytes */
45+ u32 hashrnd;
4446 };
4547
4648 /* each htab element is struct htab_elem + key + value */
@@ -371,6 +373,7 @@ static struct bpf_map *htab_map_alloc(union bpf_attr *attr) · 324 unmodified lines
371373 if (!htab->buckets)
372374 goto free_htab;
373375
376+ htab->hashrnd = get_random_int();
374377 for (i = 0; i < htab->n_buckets; i++) {
375378 INIT_HLIST_NULLS_HEAD(&htab->buckets[i].head, i);
376379 raw_spin_lock_init(&htab->buckets[i].lock);
@@ -402,9 +405,9 @@ free_htab: · 25 unmodified lines
402405 return ERR_PTR(err);
403406 }
404407
405−static inline u32 htab_map_hash(const void *key, u32 key_len)
408+static inline u32 htab_map_hash(const void *key, u32 key_len, u32 hashrnd)
406409 {
407− return jhash(key, key_len, 0);
410+ return jhash(key, key_len, hashrnd);
408411 }
409412
410413 static inline struct bucket *__select_bucket(struct bpf_htab *htab, u32 hash)
@@ -470,7 +473,7 @@ static void *__htab_map_lookup_elem(struct bpf_map *map, void *key) · 59 unmodified lines
470473
471474 key_size = map->key_size;
472475
473− hash = htab_map_hash(key, key_size);
476+ hash = htab_map_hash(key, key_size, htab->hashrnd);
474477
475478 head = select_bucket(htab, hash);
476479
@@ -597,7 +600,7 @@ static int htab_map_get_next_key(struct bpf_map *map, void *key, void *next_key) · 120 unmodified lines
597600 if (!key)
598601 goto find_first_elem;
599602
600− hash = htab_map_hash(key, key_size);
603+ hash = htab_map_hash(key, key_size, htab->hashrnd);
601604
602605 head = select_bucket(htab, hash);
603606
@@ -824,7 +827,7 @@ static int htab_map_update_elem(struct bpf_map *map, void *key, void *value, · 220 unmodified lines
824827
825828 key_size = map->key_size;
826829
827− hash = htab_map_hash(key, key_size);
830+ hash = htab_map_hash(key, key_size, htab->hashrnd);
828831
829832 b = __select_bucket(htab, hash);
830833 head = &b->head;
@@ -880,7 +883,7 @@ static int htab_lru_map_update_elem(struct bpf_map *map, void *key, void *value, · 49 unmodified lines
880883
881884 key_size = map->key_size;
882885
883− hash = htab_map_hash(key, key_size);
886+ hash = htab_map_hash(key, key_size, htab->hashrnd);
884887
885888 b = __select_bucket(htab, hash);
886889 head = &b->head;
@@ -945,7 +948,7 @@ static int __htab_percpu_map_update_elem(struct bpf_map *map, void *key, · 58 unmodified lines
945948
946949 key_size = map->key_size;
947950
948− hash = htab_map_hash(key, key_size);
951+ hash = htab_map_hash(key, key_size, htab->hashrnd);
949952
950953 b = __select_bucket(htab, hash);
951954 head = &b->head;
@@ -998,7 +1001,7 @@ static int __htab_lru_percpu_map_update_elem(struct bpf_map *map, void *key, · 46 unmodified lines
9981001
9991002 key_size = map->key_size;
10001003
1001− hash = htab_map_hash(key, key_size);
1004+ hash = htab_map_hash(key, key_size, htab->hashrnd);
10021005
10031006 b = __select_bucket(htab, hash);
10041007 head = &b->head;
@@ -1071,7 +1074,7 @@ static int htab_map_delete_elem(struct bpf_map *map, void *key) · 66 unmodified lines
10711074
10721075 key_size = map->key_size;
10731076
1074− hash = htab_map_hash(key, key_size);
1077+ hash = htab_map_hash(key, key_size, htab->hashrnd);
10751078 b = __select_bucket(htab, hash);
10761079 head = &b->head;
10771080
@@ -1103,7 +1106,7 @@ static int htab_lru_map_delete_elem(struct bpf_map *map, void *key) · 25 unmodified lines
11031106
11041107 key_size = map->key_size;
11051108
1106− hash = htab_map_hash(key, key_size);
1109+ hash = htab_map_hash(key, key_size, htab->hashrnd);
11071110 b = __select_bucket(htab, hash);
11081111 head = &b->head;
11091112
kernel/bpf/sockmap.c+9−2
@@ -1427,12 +1427,15 @@ out: · 1426 unmodified lines
14271427 static void smap_write_space(struct sock *sk)
14281428 {
14291429 struct smap_psock *psock;
1430+ void (*write_space)(struct sock *sk);
14301431
14311432 rcu_read_lock();
14321433 psock = smap_psock_sk(sk);
14331434 if (likely(psock && test_bit(SMAP_TX_RUNNING, &psock->state)))
14341435 schedule_work(&psock->tx_work);
1436+ write_space = psock->save_write_space;
14351437 rcu_read_unlock();
1438+ write_space(sk);
14361439 }
14371440
14381441 static void smap_stop_sock(struct smap_psock *psock, struct sock *sk)
@@ -2140,7 +2143,9 @@ static struct bpf_map *sock_hash_alloc(union bpf_attr *attr) · 701 unmodified lines
21402143 return ERR_PTR(-EPERM);
21412144
21422145 /* check sanity of attributes */
2143− if (attr->max_entries == 0 || attr->value_size != 4 ||
2146+ if (attr->max_entries == 0 ||
2147+ attr->key_size == 0 ||
2148+ attr->value_size != 4 ||
21442149 attr->map_flags & ~SOCK_CREATE_FLAG_MASK)
21452150 return ERR_PTR(-EINVAL);
21462151
@@ -2267,8 +2272,10 @@ static struct htab_elem *alloc_sock_hash_elem(struct bpf_htab *htab, · 120 unmodified lines
22672272 }
22682273 l_new = kmalloc_node(htab->elem_size, GFP_ATOMIC | __GFP_NOWARN,
22692274 htab->map.numa_node);
2270− if (!l_new)
2275+ if (!l_new) {
2276+ atomic_dec(&htab->count);
22712277 return ERR_PTR(-ENOMEM);
2278+ }
22722279
22732280 memcpy(l_new->key, key, key_size);
22742281 l_new->sk = sk;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t