@@ -7066,15 +7066,15 @@ static int bpf_gen_ld_abs(const struct bpf_insn *orig,
70667066 bool indirect = BPF_MODE (orig -> code ) == BPF_IND ;
70677067 struct bpf_insn * insn = insn_buf ;
70687068
7069- /* We're guaranteed here that CTX is in R6. */
7070- * insn ++ = BPF_MOV64_REG (BPF_REG_1 , BPF_REG_CTX );
70717069 if (!indirect ) {
70727070 * insn ++ = BPF_MOV64_IMM (BPF_REG_2 , orig -> imm );
70737071 } else {
70747072 * insn ++ = BPF_MOV64_REG (BPF_REG_2 , orig -> src_reg );
70757073 if (orig -> imm )
70767074 * insn ++ = BPF_ALU64_IMM (BPF_ADD , BPF_REG_2 , orig -> imm );
70777075 }
7076+ /* We're guaranteed here that CTX is in R6. */
7077+ * insn ++ = BPF_MOV64_REG (BPF_REG_1 , BPF_REG_CTX );
70787078
70797079 switch (BPF_SIZE (orig -> code )) {
70807080 case BPF_B :
@@ -9523,7 +9523,7 @@ BPF_CALL_1(bpf_skc_to_tcp6_sock, struct sock *, sk)
95239523 * trigger an explicit type generation here.
95249524 */
95259525 BTF_TYPE_EMIT (struct tcp6_sock );
9526- if (sk_fullsock (sk ) && sk -> sk_protocol == IPPROTO_TCP &&
9526+ if (sk && sk_fullsock (sk ) && sk -> sk_protocol == IPPROTO_TCP &&
95279527 sk -> sk_family == AF_INET6 )
95289528 return (unsigned long )sk ;
95299529
@@ -9541,7 +9541,7 @@ const struct bpf_func_proto bpf_skc_to_tcp6_sock_proto = {
95419541
95429542BPF_CALL_1 (bpf_skc_to_tcp_sock , struct sock * , sk )
95439543{
9544- if (sk_fullsock (sk ) && sk -> sk_protocol == IPPROTO_TCP )
9544+ if (sk && sk_fullsock (sk ) && sk -> sk_protocol == IPPROTO_TCP )
95459545 return (unsigned long )sk ;
95469546
95479547 return (unsigned long )NULL ;
@@ -9559,12 +9559,12 @@ const struct bpf_func_proto bpf_skc_to_tcp_sock_proto = {
95599559BPF_CALL_1 (bpf_skc_to_tcp_timewait_sock , struct sock * , sk )
95609560{
95619561#ifdef CONFIG_INET
9562- if (sk -> sk_prot == & tcp_prot && sk -> sk_state == TCP_TIME_WAIT )
9562+ if (sk && sk -> sk_prot == & tcp_prot && sk -> sk_state == TCP_TIME_WAIT )
95639563 return (unsigned long )sk ;
95649564#endif
95659565
95669566#if IS_BUILTIN (CONFIG_IPV6 )
9567- if (sk -> sk_prot == & tcpv6_prot && sk -> sk_state == TCP_TIME_WAIT )
9567+ if (sk && sk -> sk_prot == & tcpv6_prot && sk -> sk_state == TCP_TIME_WAIT )
95689568 return (unsigned long )sk ;
95699569#endif
95709570
@@ -9583,12 +9583,12 @@ const struct bpf_func_proto bpf_skc_to_tcp_timewait_sock_proto = {
95839583BPF_CALL_1 (bpf_skc_to_tcp_request_sock , struct sock * , sk )
95849584{
95859585#ifdef CONFIG_INET
9586- if (sk -> sk_prot == & tcp_prot && sk -> sk_state == TCP_NEW_SYN_RECV )
9586+ if (sk && sk -> sk_prot == & tcp_prot && sk -> sk_state == TCP_NEW_SYN_RECV )
95879587 return (unsigned long )sk ;
95889588#endif
95899589
95909590#if IS_BUILTIN (CONFIG_IPV6 )
9591- if (sk -> sk_prot == & tcpv6_prot && sk -> sk_state == TCP_NEW_SYN_RECV )
9591+ if (sk && sk -> sk_prot == & tcpv6_prot && sk -> sk_state == TCP_NEW_SYN_RECV )
95929592 return (unsigned long )sk ;
95939593#endif
95949594
@@ -9610,7 +9610,7 @@ BPF_CALL_1(bpf_skc_to_udp6_sock, struct sock *, sk)
96109610 * trigger an explicit type generation here.
96119611 */
96129612 BTF_TYPE_EMIT (struct udp6_sock );
9613- if (sk_fullsock (sk ) && sk -> sk_protocol == IPPROTO_UDP &&
9613+ if (sk && sk_fullsock (sk ) && sk -> sk_protocol == IPPROTO_UDP &&
96149614 sk -> sk_type == SOCK_DGRAM && sk -> sk_family == AF_INET6 )
96159615 return (unsigned long )sk ;
96169616
0 commit comments