Commit 3981f955 authored by David S. Miller's avatar David S. Miller
Browse files


Daniel Borkmann says:

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

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

We've added 12 non-merge commits during the last 9 day(s) which contain
a total of 13 files changed, 95 insertions(+), 43 deletions(-).

The main changes are:

1) Fix refcount leak for TCP time wait and request sockets for socket lookup
   related BPF helpers, from Lorenz Bauer.

2) Fix wrong verification of ARSH instruction under ALU32, from Daniel Borkmann.

3) Batch of several sockmap and related TLS fixes found while operating
   more complex BPF programs with Cilium and OpenSSL, from John Fastabend.

4) Fix sockmap to read psock's ingress_msg queue before regular sk_receive_queue()
   to avoid purging data upon teardown, from Lingpeng Chen.

5) Fix printing incorrect pointer in bpftool's btf_dump_ptr() in order to properly
   dump a BPF map's value with BTF, from Martin KaFai Lau.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 567110f1 85ddd9c3
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -358,17 +358,22 @@ static inline void sk_psock_update_proto(struct sock *sk,
static inline void sk_psock_restore_proto(struct sock *sk,
					  struct sk_psock *psock)
{
	sk->sk_write_space = psock->saved_write_space;
	sk->sk_prot->unhash = psock->saved_unhash;

	if (psock->sk_proto) {
		struct inet_connection_sock *icsk = inet_csk(sk);
		bool has_ulp = !!icsk->icsk_ulp_data;

		if (has_ulp)
			tcp_update_ulp(sk, psock->sk_proto);
		else
		if (has_ulp) {
			tcp_update_ulp(sk, psock->sk_proto,
				       psock->saved_write_space);
		} else {
			sk->sk_prot = psock->sk_proto;
			sk->sk_write_space = psock->saved_write_space;
		}
		psock->sk_proto = NULL;
	} else {
		sk->sk_write_space = psock->saved_write_space;
	}
}

+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ struct tnum tnum_lshift(struct tnum a, u8 shift);
/* Shift (rsh) a tnum right (by a fixed shift) */
struct tnum tnum_rshift(struct tnum a, u8 shift);
/* Shift (arsh) a tnum right (by a fixed min_shift) */
struct tnum tnum_arshift(struct tnum a, u8 min_shift);
struct tnum tnum_arshift(struct tnum a, u8 min_shift, u8 insn_bitness);
/* Add two tnums, return @a + @b */
struct tnum tnum_add(struct tnum a, struct tnum b);
/* Subtract two tnums, return @a - @b */
+4 −2
Original line number Diff line number Diff line
@@ -2147,7 +2147,8 @@ struct tcp_ulp_ops {
	/* initialize ulp */
	int (*init)(struct sock *sk);
	/* update ulp */
	void (*update)(struct sock *sk, struct proto *p);
	void (*update)(struct sock *sk, struct proto *p,
		       void (*write_space)(struct sock *sk));
	/* cleanup ulp */
	void (*release)(struct sock *sk);
	/* diagnostic */
@@ -2162,7 +2163,8 @@ void tcp_unregister_ulp(struct tcp_ulp_ops *type);
int tcp_set_ulp(struct sock *sk, const char *name);
void tcp_get_available_ulp(char *buf, size_t len);
void tcp_cleanup_ulp(struct sock *sk);
void tcp_update_ulp(struct sock *sk, struct proto *p);
void tcp_update_ulp(struct sock *sk, struct proto *p,
		    void (*write_space)(struct sock *sk));

#define MODULE_ALIAS_TCP_ULP(name)				\
	__MODULE_INFO(alias, alias_userspace, name);		\
+7 −2
Original line number Diff line number Diff line
@@ -44,14 +44,19 @@ struct tnum tnum_rshift(struct tnum a, u8 shift)
	return TNUM(a.value >> shift, a.mask >> shift);
}

struct tnum tnum_arshift(struct tnum a, u8 min_shift)
struct tnum tnum_arshift(struct tnum a, u8 min_shift, u8 insn_bitness)
{
	/* if a.value is negative, arithmetic shifting by minimum shift
	 * will have larger negative offset compared to more shifting.
	 * If a.value is nonnegative, arithmetic shifting by minimum shift
	 * will have larger positive offset compare to more shifting.
	 */
	return TNUM((s64)a.value >> min_shift, (s64)a.mask >> min_shift);
	if (insn_bitness == 32)
		return TNUM((u32)(((s32)a.value) >> min_shift),
			    (u32)(((s32)a.mask)  >> min_shift));
	else
		return TNUM((s64)a.value >> min_shift,
			    (s64)a.mask  >> min_shift);
}

struct tnum tnum_add(struct tnum a, struct tnum b)
+10 −3
Original line number Diff line number Diff line
@@ -5049,9 +5049,16 @@ static int adjust_scalar_min_max_vals(struct bpf_verifier_env *env,
		/* Upon reaching here, src_known is true and
		 * umax_val is equal to umin_val.
		 */
		if (insn_bitness == 32) {
			dst_reg->smin_value = (u32)(((s32)dst_reg->smin_value) >> umin_val);
			dst_reg->smax_value = (u32)(((s32)dst_reg->smax_value) >> umin_val);
		} else {
			dst_reg->smin_value >>= umin_val;
			dst_reg->smax_value >>= umin_val;
		dst_reg->var_off = tnum_arshift(dst_reg->var_off, umin_val);
		}

		dst_reg->var_off = tnum_arshift(dst_reg->var_off, umin_val,
						insn_bitness);

		/* blow away the dst_reg umin_value/umax_value and rely on
		 * dst_reg var_off to refine the result.
Loading