aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-11-21 16:26:28 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-11-21 16:26:28 -0500
commit27e7ab99db51569886f52f9d025473e9f453a67b (patch)
tree843a889d4565ff1122161d2abb09c90b03dd8c5d /kernel
parent9c763584b7c8911106bb77af7e648bef09af9d80 (diff)
parent7082c5c3f2407c52022507ffaf644dbbab97a883 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: 1) Clear congestion control state when changing algorithms on an existing socket, from Florian Westphal. 2) Fix register bit values in altr_tse_pcs portion of stmmac driver, from Jia Jie Ho. 3) Fix PTP handling in stammc driver for GMAC4, from Giuseppe CAVALLARO. 4) Fix udplite multicast delivery handling, it ignores the udp_table parameter passed into the lookups, from Pablo Neira Ayuso. 5) Synchronize the space estimated by rtnl_vfinfo_size and the space actually used by rtnl_fill_vfinfo. From Sabrina Dubroca. 6) Fix memory leak in fib_info when splitting nodes, from Alexander Duyck. 7) If a driver does a napi_hash_del() explicitily and not via netif_napi_del(), it must perform RCU synchronization as needed. Fix this in virtio-net and bnxt drivers, from Eric Dumazet. 8) Likewise, it is not necessary to invoke napi_hash_del() is we are also doing neif_napi_del() in the same code path. Remove such calls from be2net and cxgb4 drivers, also from Eric Dumazet. 9) Don't allocate an ID in peernet2id_alloc() if the netns is dead, from WANG Cong. 10) Fix OF node and device struct leaks in of_mdio, from Johan Hovold. 11) We cannot cache routes in ip6_tunnel when using inherited traffic classes, from Paolo Abeni. 12) Fix several crashes and leaks in cpsw driver, from Johan Hovold. 13) Splice operations cannot use freezable blocking calls in AF_UNIX, from WANG Cong. 14) Link dump filtering by master device and kind support added an error in loop index updates during the dump if we actually do filter, fix from Zhang Shengju. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (59 commits) tcp: zero ca_priv area when switching cc algorithms net: l2tp: Treat NET_XMIT_CN as success in l2tp_eth_dev_xmit ethernet: stmmac: make DWMAC_STM32 depend on it's associated SoC tipc: eliminate obsolete socket locking policy description rtnl: fix the loop index update error in rtnl_dump_ifinfo() l2tp: fix racy SOCK_ZAPPED flag check in l2tp_ip{,6}_bind() net: macb: add check for dma mapping error in start_xmit() rtnetlink: fix FDB size computation netns: fix get_net_ns_by_fd(int pid) typo af_unix: conditionally use freezable blocking calls in read net: ethernet: ti: cpsw: fix fixed-link phy probe deferral net: ethernet: ti: cpsw: add missing sanity check net: ethernet: ti: cpsw: fix secondary-emac probe error path net: ethernet: ti: cpsw: fix of_node and phydev leaks net: ethernet: ti: cpsw: fix deferred probe net: ethernet: ti: cpsw: fix mdio device reference leak net: ethernet: ti: cpsw: fix bad register access in probe error path net: sky2: Fix shutdown crash cfg80211: limit scan results cache size net sched filters: pass netlink message flags in event notification ...
Diffstat (limited to 'kernel')
-rw-r--r--kernel/bpf/verifier.c70
1 files changed, 47 insertions, 23 deletions
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 99a7e5b388f2..6a936159c6e0 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -216,8 +216,8 @@ static void print_verifier_state(struct bpf_verifier_state *state)
216 reg->map_ptr->key_size, 216 reg->map_ptr->key_size,
217 reg->map_ptr->value_size); 217 reg->map_ptr->value_size);
218 if (reg->min_value != BPF_REGISTER_MIN_RANGE) 218 if (reg->min_value != BPF_REGISTER_MIN_RANGE)
219 verbose(",min_value=%llu", 219 verbose(",min_value=%lld",
220 (unsigned long long)reg->min_value); 220 (long long)reg->min_value);
221 if (reg->max_value != BPF_REGISTER_MAX_RANGE) 221 if (reg->max_value != BPF_REGISTER_MAX_RANGE)
222 verbose(",max_value=%llu", 222 verbose(",max_value=%llu",
223 (unsigned long long)reg->max_value); 223 (unsigned long long)reg->max_value);
@@ -758,7 +758,7 @@ static int check_mem_access(struct bpf_verifier_env *env, u32 regno, int off,
758 * index'es we need to make sure that whatever we use 758 * index'es we need to make sure that whatever we use
759 * will have a set floor within our range. 759 * will have a set floor within our range.
760 */ 760 */
761 if ((s64)reg->min_value < 0) { 761 if (reg->min_value < 0) {
762 verbose("R%d min value is negative, either use unsigned index or do a if (index >=0) check.\n", 762 verbose("R%d min value is negative, either use unsigned index or do a if (index >=0) check.\n",
763 regno); 763 regno);
764 return -EACCES; 764 return -EACCES;
@@ -1468,7 +1468,8 @@ static void check_reg_overflow(struct bpf_reg_state *reg)
1468{ 1468{
1469 if (reg->max_value > BPF_REGISTER_MAX_RANGE) 1469 if (reg->max_value > BPF_REGISTER_MAX_RANGE)
1470 reg->max_value = BPF_REGISTER_MAX_RANGE; 1470 reg->max_value = BPF_REGISTER_MAX_RANGE;
1471 if ((s64)reg->min_value < BPF_REGISTER_MIN_RANGE) 1471 if (reg->min_value < BPF_REGISTER_MIN_RANGE ||
1472 reg->min_value > BPF_REGISTER_MAX_RANGE)
1472 reg->min_value = BPF_REGISTER_MIN_RANGE; 1473 reg->min_value = BPF_REGISTER_MIN_RANGE;
1473} 1474}
1474 1475
@@ -1476,7 +1477,8 @@ static void adjust_reg_min_max_vals(struct bpf_verifier_env *env,
1476 struct bpf_insn *insn) 1477 struct bpf_insn *insn)
1477{ 1478{
1478 struct bpf_reg_state *regs = env->cur_state.regs, *dst_reg; 1479 struct bpf_reg_state *regs = env->cur_state.regs, *dst_reg;
1479 u64 min_val = BPF_REGISTER_MIN_RANGE, max_val = BPF_REGISTER_MAX_RANGE; 1480 s64 min_val = BPF_REGISTER_MIN_RANGE;
1481 u64 max_val = BPF_REGISTER_MAX_RANGE;
1480 bool min_set = false, max_set = false; 1482 bool min_set = false, max_set = false;
1481 u8 opcode = BPF_OP(insn->code); 1483 u8 opcode = BPF_OP(insn->code);
1482 1484
@@ -1512,22 +1514,43 @@ static void adjust_reg_min_max_vals(struct bpf_verifier_env *env,
1512 return; 1514 return;
1513 } 1515 }
1514 1516
1517 /* If one of our values was at the end of our ranges then we can't just
1518 * do our normal operations to the register, we need to set the values
1519 * to the min/max since they are undefined.
1520 */
1521 if (min_val == BPF_REGISTER_MIN_RANGE)
1522 dst_reg->min_value = BPF_REGISTER_MIN_RANGE;
1523 if (max_val == BPF_REGISTER_MAX_RANGE)
1524 dst_reg->max_value = BPF_REGISTER_MAX_RANGE;
1525
1515 switch (opcode) { 1526 switch (opcode) {
1516 case BPF_ADD: 1527 case BPF_ADD:
1517 dst_reg->min_value += min_val; 1528 if (dst_reg->min_value != BPF_REGISTER_MIN_RANGE)
1518 dst_reg->max_value += max_val; 1529 dst_reg->min_value += min_val;
1530 if (dst_reg->max_value != BPF_REGISTER_MAX_RANGE)
1531 dst_reg->max_value += max_val;
1519 break; 1532 break;
1520 case BPF_SUB: 1533 case BPF_SUB:
1521 dst_reg->min_value -= min_val; 1534 if (dst_reg->min_value != BPF_REGISTER_MIN_RANGE)
1522 dst_reg->max_value -= max_val; 1535 dst_reg->min_value -= min_val;
1536 if (dst_reg->max_value != BPF_REGISTER_MAX_RANGE)
1537 dst_reg->max_value -= max_val;
1523 break; 1538 break;
1524 case BPF_MUL: 1539 case BPF_MUL:
1525 dst_reg->min_value *= min_val; 1540 if (dst_reg->min_value != BPF_REGISTER_MIN_RANGE)
1526 dst_reg->max_value *= max_val; 1541 dst_reg->min_value *= min_val;
1542 if (dst_reg->max_value != BPF_REGISTER_MAX_RANGE)
1543 dst_reg->max_value *= max_val;
1527 break; 1544 break;
1528 case BPF_AND: 1545 case BPF_AND:
1529 /* & is special since it could end up with 0 bits set. */ 1546 /* Disallow AND'ing of negative numbers, ain't nobody got time
1530 dst_reg->min_value &= min_val; 1547 * for that. Otherwise the minimum is 0 and the max is the max
1548 * value we could AND against.
1549 */
1550 if (min_val < 0)
1551 dst_reg->min_value = BPF_REGISTER_MIN_RANGE;
1552 else
1553 dst_reg->min_value = 0;
1531 dst_reg->max_value = max_val; 1554 dst_reg->max_value = max_val;
1532 break; 1555 break;
1533 case BPF_LSH: 1556 case BPF_LSH:
@@ -1537,24 +1560,25 @@ static void adjust_reg_min_max_vals(struct bpf_verifier_env *env,
1537 */ 1560 */
1538 if (min_val > ilog2(BPF_REGISTER_MAX_RANGE)) 1561 if (min_val > ilog2(BPF_REGISTER_MAX_RANGE))
1539 dst_reg->min_value = BPF_REGISTER_MIN_RANGE; 1562 dst_reg->min_value = BPF_REGISTER_MIN_RANGE;
1540 else 1563 else if (dst_reg->min_value != BPF_REGISTER_MIN_RANGE)
1541 dst_reg->min_value <<= min_val; 1564 dst_reg->min_value <<= min_val;
1542 1565
1543 if (max_val > ilog2(BPF_REGISTER_MAX_RANGE)) 1566 if (max_val > ilog2(BPF_REGISTER_MAX_RANGE))
1544 dst_reg->max_value = BPF_REGISTER_MAX_RANGE; 1567 dst_reg->max_value = BPF_REGISTER_MAX_RANGE;
1545 else 1568 else if (dst_reg->max_value != BPF_REGISTER_MAX_RANGE)
1546 dst_reg->max_value <<= max_val; 1569 dst_reg->max_value <<= max_val;
1547 break; 1570 break;
1548 case BPF_RSH: 1571 case BPF_RSH:
1549 dst_reg->min_value >>= min_val; 1572 /* RSH by a negative number is undefined, and the BPF_RSH is an
1550 dst_reg->max_value >>= max_val; 1573 * unsigned shift, so make the appropriate casts.
1551 break;
1552 case BPF_MOD:
1553 /* % is special since it is an unsigned modulus, so the floor
1554 * will always be 0.
1555 */ 1574 */
1556 dst_reg->min_value = 0; 1575 if (min_val < 0 || dst_reg->min_value < 0)
1557 dst_reg->max_value = max_val - 1; 1576 dst_reg->min_value = BPF_REGISTER_MIN_RANGE;
1577 else
1578 dst_reg->min_value =
1579 (u64)(dst_reg->min_value) >> min_val;
1580 if (dst_reg->max_value != BPF_REGISTER_MAX_RANGE)
1581 dst_reg->max_value >>= max_val;
1558 break; 1582 break;
1559 default: 1583 default:
1560 reset_reg_range_values(regs, insn->dst_reg); 1584 reset_reg_range_values(regs, insn->dst_reg);