Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf
authorDavid S. Miller <davem@davemloft.net>
Wed, 16 Sep 2020 02:26:21 +0000 (19:26 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 16 Sep 2020 02:26:21 +0000 (19:26 -0700)
Alexei Starovoitov says:

====================
pull-request: bpf 2020-09-15

The following pull-request contains BPF updates for your *net* tree.

We've added 12 non-merge commits during the last 19 day(s) which contain
a total of 10 files changed, 47 insertions(+), 38 deletions(-).

The main changes are:

1) docs/bpf fixes, from Andrii.

2) ld_abs fix, from Daniel.

3) socket casting helpers fix, from Martin.

4) hash iterator fixes, from Yonghong.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
1  2 
net/core/filter.c

diff --combined net/core/filter.c
@@@ -4838,7 -4838,6 +4838,7 @@@ static int bpf_ipv4_fib_lookup(struct n
        fl4.saddr = params->ipv4_src;
        fl4.fl4_sport = params->sport;
        fl4.fl4_dport = params->dport;
 +      fl4.flowi4_multipath_hash = 0;
  
        if (flags & BPF_FIB_LOOKUP_DIRECT) {
                u32 tbid = l3mdev_fib_table_rcu(dev) ? : RT_TABLE_MAIN;
@@@ -7066,8 -7065,6 +7066,6 @@@ static int bpf_gen_ld_abs(const struct 
        bool indirect = BPF_MODE(orig->code) == BPF_IND;
        struct bpf_insn *insn = insn_buf;
  
-       /* We're guaranteed here that CTX is in R6. */
-       *insn++ = BPF_MOV64_REG(BPF_REG_1, BPF_REG_CTX);
        if (!indirect) {
                *insn++ = BPF_MOV64_IMM(BPF_REG_2, orig->imm);
        } else {
                if (orig->imm)
                        *insn++ = BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, orig->imm);
        }
+       /* We're guaranteed here that CTX is in R6. */
+       *insn++ = BPF_MOV64_REG(BPF_REG_1, BPF_REG_CTX);
  
        switch (BPF_SIZE(orig->code)) {
        case BPF_B:
@@@ -9224,7 -9223,7 +9224,7 @@@ sk_reuseport_is_valid_access(int off, i
        case bpf_ctx_range(struct sk_reuseport_md, eth_protocol):
                if (size < sizeof_field(struct sk_buff, protocol))
                        return false;
 -              /* fall through */
 +              fallthrough;
        case bpf_ctx_range(struct sk_reuseport_md, ip_protocol):
        case bpf_ctx_range(struct sk_reuseport_md, bind_inany):
        case bpf_ctx_range(struct sk_reuseport_md, len):
@@@ -9523,7 -9522,7 +9523,7 @@@ BPF_CALL_1(bpf_skc_to_tcp6_sock, struc
         * trigger an explicit type generation here.
         */
        BTF_TYPE_EMIT(struct tcp6_sock);
-       if (sk_fullsock(sk) && sk->sk_protocol == IPPROTO_TCP &&
+       if (sk && sk_fullsock(sk) && sk->sk_protocol == IPPROTO_TCP &&
            sk->sk_family == AF_INET6)
                return (unsigned long)sk;
  
@@@ -9541,7 -9540,7 +9541,7 @@@ const struct bpf_func_proto bpf_skc_to_
  
  BPF_CALL_1(bpf_skc_to_tcp_sock, struct sock *, sk)
  {
-       if (sk_fullsock(sk) && sk->sk_protocol == IPPROTO_TCP)
+       if (sk && sk_fullsock(sk) && sk->sk_protocol == IPPROTO_TCP)
                return (unsigned long)sk;
  
        return (unsigned long)NULL;
@@@ -9559,12 -9558,12 +9559,12 @@@ const struct bpf_func_proto bpf_skc_to_
  BPF_CALL_1(bpf_skc_to_tcp_timewait_sock, struct sock *, sk)
  {
  #ifdef CONFIG_INET
-       if (sk->sk_prot == &tcp_prot && sk->sk_state == TCP_TIME_WAIT)
+       if (sk && sk->sk_prot == &tcp_prot && sk->sk_state == TCP_TIME_WAIT)
                return (unsigned long)sk;
  #endif
  
  #if IS_BUILTIN(CONFIG_IPV6)
-       if (sk->sk_prot == &tcpv6_prot && sk->sk_state == TCP_TIME_WAIT)
+       if (sk && sk->sk_prot == &tcpv6_prot && sk->sk_state == TCP_TIME_WAIT)
                return (unsigned long)sk;
  #endif
  
@@@ -9583,12 -9582,12 +9583,12 @@@ const struct bpf_func_proto bpf_skc_to_
  BPF_CALL_1(bpf_skc_to_tcp_request_sock, struct sock *, sk)
  {
  #ifdef CONFIG_INET
-       if (sk->sk_prot == &tcp_prot  && sk->sk_state == TCP_NEW_SYN_RECV)
+       if (sk && sk->sk_prot == &tcp_prot && sk->sk_state == TCP_NEW_SYN_RECV)
                return (unsigned long)sk;
  #endif
  
  #if IS_BUILTIN(CONFIG_IPV6)
-       if (sk->sk_prot == &tcpv6_prot && sk->sk_state == TCP_NEW_SYN_RECV)
+       if (sk && sk->sk_prot == &tcpv6_prot && sk->sk_state == TCP_NEW_SYN_RECV)
                return (unsigned long)sk;
  #endif
  
@@@ -9610,7 -9609,7 +9610,7 @@@ BPF_CALL_1(bpf_skc_to_udp6_sock, struc
         * trigger an explicit type generation here.
         */
        BTF_TYPE_EMIT(struct udp6_sock);
-       if (sk_fullsock(sk) && sk->sk_protocol == IPPROTO_UDP &&
+       if (sk && sk_fullsock(sk) && sk->sk_protocol == IPPROTO_UDP &&
            sk->sk_type == SOCK_DGRAM && sk->sk_family == AF_INET6)
                return (unsigned long)sk;