Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 05c85a6d authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

Merge 4.9.56 into android-4.9



Changes in 4.9.56
	Revert "socket, bpf: fix possible use after free"
	Linux 4.9.56

Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parents cdbe07ad 9d36d3ef
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
VERSION = 4
PATCHLEVEL = 9
SUBLEVEL = 55
SUBLEVEL = 56
EXTRAVERSION =
NAME = Roaring Lionus

+2 −13
Original line number Diff line number Diff line
@@ -947,31 +947,20 @@ void sk_filter_uncharge(struct sock *sk, struct sk_filter *fp)
/* try to charge the socket memory if there is space available
 * return true on success
 */
static bool __sk_filter_charge(struct sock *sk, struct sk_filter *fp)
bool sk_filter_charge(struct sock *sk, struct sk_filter *fp)
{
	u32 filter_size = bpf_prog_size(fp->prog->len);

	/* same check as in sock_kmalloc() */
	if (filter_size <= sysctl_optmem_max &&
	    atomic_read(&sk->sk_omem_alloc) + filter_size < sysctl_optmem_max) {
		atomic_inc(&fp->refcnt);
		atomic_add(filter_size, &sk->sk_omem_alloc);
		return true;
	}
	return false;
}

bool sk_filter_charge(struct sock *sk, struct sk_filter *fp)
{
	if (!atomic_inc_not_zero(&fp->refcnt))
		return false;

	if (!__sk_filter_charge(sk, fp)) {
		sk_filter_release(fp);
		return false;
	}
	return true;
}

static struct bpf_prog *bpf_migrate_filter(struct bpf_prog *fp)
{
	struct sock_filter *old_prog;
+1 −4
Original line number Diff line number Diff line
@@ -1536,16 +1536,13 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority)
		sock_reset_flag(newsk, SOCK_DONE);
		skb_queue_head_init(&newsk->sk_error_queue);

		rcu_read_lock();
		filter = rcu_dereference(sk->sk_filter);
		filter = rcu_dereference_protected(newsk->sk_filter, 1);
		if (filter != NULL)
			/* though it's an empty new sock, the charging may fail
			 * if sysctl_optmem_max was changed between creation of
			 * original socket and cloning
			 */
			is_charged = sk_filter_charge(newsk, filter);
		RCU_INIT_POINTER(newsk->sk_filter, filter);
		rcu_read_unlock();

		if (unlikely(!is_charged || xfrm_sk_clone_policy(newsk, sk))) {
			/* We need to make sure that we don't uncharge the new