aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/bpf
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-04-09 20:04:10 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-04-09 20:04:10 -0400
commitc18bb396d3d261ebbb4efbc05129c5d354c541e4 (patch)
tree058a1413dd34fe4e1d9a998a43d56f3358b93e36 /kernel/bpf
parentfd3b36d275660c905da9900b078eea341847d5e4 (diff)
parenta2ac99905f1ea8b15997a6ec39af69aa28a3653b (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: 1) The sockmap code has to free socket memory on close if there is corked data, from John Fastabend. 2) Tunnel names coming from userspace need to be length validated. From Eric Dumazet. 3) arp_filter() has to take VRFs properly into account, from Miguel Fadon Perlines. 4) Fix oops in error path of tcf_bpf_init(), from Davide Caratti. 5) Missing idr_remove() in u32_delete_key(), from Cong Wang. 6) More syzbot stuff. Several use of uninitialized value fixes all over, from Eric Dumazet. 7) Do not leak kernel memory to userspace in sctp, also from Eric Dumazet. 8) Discard frames from unused ports in DSA, from Andrew Lunn. 9) Fix DMA mapping and reset/failover problems in ibmvnic, from Thomas Falcon. 10) Do not access dp83640 PHY registers prematurely after reset, from Esben Haabendal. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (46 commits) vhost-net: set packet weight of tx polling to 2 * vq size net: thunderx: rework mac addresses list to u64 array inetpeer: fix uninit-value in inet_getpeer dp83640: Ensure against premature access to PHY registers after reset devlink: convert occ_get op to separate registration ARM: dts: ls1021a: Specify TBIPA register address net/fsl_pq_mdio: Allow explicit speficition of TBIPA address ibmvnic: Do not reset CRQ for Mobility driver resets ibmvnic: Fix failover case for non-redundant configuration ibmvnic: Fix reset scheduler error handling ibmvnic: Zero used TX descriptor counter on reset ibmvnic: Fix DMA mapping mistakes tipc: use the right skb in tipc_sk_fill_sock_diag() sctp: sctp_sockaddr_af must check minimal addr length for AF_INET6 net: dsa: Discard frames from unused ports sctp: do not leak kernel memory to user space soreuseport: initialise timewait reuseport field ipv4: fix uninit-value in ip_route_output_key_hash_rcu() dccp: initialize ireq->ir_mark net: fix uninit-value in __hw_addr_add_ex() ...
Diffstat (limited to 'kernel/bpf')
-rw-r--r--kernel/bpf/sockmap.c12
-rw-r--r--kernel/bpf/syscall.c24
2 files changed, 22 insertions, 14 deletions
diff --git a/kernel/bpf/sockmap.c b/kernel/bpf/sockmap.c
index d2bda5aa25d7..8dd9210d7db7 100644
--- a/kernel/bpf/sockmap.c
+++ b/kernel/bpf/sockmap.c
@@ -182,8 +182,10 @@ static void bpf_tcp_release(struct sock *sk)
182 psock->cork = NULL; 182 psock->cork = NULL;
183 } 183 }
184 184
185 sk->sk_prot = psock->sk_proto; 185 if (psock->sk_proto) {
186 psock->sk_proto = NULL; 186 sk->sk_prot = psock->sk_proto;
187 psock->sk_proto = NULL;
188 }
187out: 189out:
188 rcu_read_unlock(); 190 rcu_read_unlock();
189} 191}
@@ -211,6 +213,12 @@ static void bpf_tcp_close(struct sock *sk, long timeout)
211 close_fun = psock->save_close; 213 close_fun = psock->save_close;
212 214
213 write_lock_bh(&sk->sk_callback_lock); 215 write_lock_bh(&sk->sk_callback_lock);
216 if (psock->cork) {
217 free_start_sg(psock->sock, psock->cork);
218 kfree(psock->cork);
219 psock->cork = NULL;
220 }
221
214 list_for_each_entry_safe(md, mtmp, &psock->ingress, list) { 222 list_for_each_entry_safe(md, mtmp, &psock->ingress, list) {
215 list_del(&md->list); 223 list_del(&md->list);
216 free_start_sg(psock->sock, md); 224 free_start_sg(psock->sock, md);
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 0244973ee544..4ca46df19c9a 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -1226,18 +1226,6 @@ bpf_prog_load_check_attach_type(enum bpf_prog_type prog_type,
1226 } 1226 }
1227} 1227}
1228 1228
1229static int bpf_prog_attach_check_attach_type(const struct bpf_prog *prog,
1230 enum bpf_attach_type attach_type)
1231{
1232 switch (prog->type) {
1233 case BPF_PROG_TYPE_CGROUP_SOCK:
1234 case BPF_PROG_TYPE_CGROUP_SOCK_ADDR:
1235 return attach_type == prog->expected_attach_type ? 0 : -EINVAL;
1236 default:
1237 return 0;
1238 }
1239}
1240
1241/* last field in 'union bpf_attr' used by this command */ 1229/* last field in 'union bpf_attr' used by this command */
1242#define BPF_PROG_LOAD_LAST_FIELD expected_attach_type 1230#define BPF_PROG_LOAD_LAST_FIELD expected_attach_type
1243 1231
@@ -1465,6 +1453,18 @@ out_free_tp:
1465 1453
1466#ifdef CONFIG_CGROUP_BPF 1454#ifdef CONFIG_CGROUP_BPF
1467 1455
1456static int bpf_prog_attach_check_attach_type(const struct bpf_prog *prog,
1457 enum bpf_attach_type attach_type)
1458{
1459 switch (prog->type) {
1460 case BPF_PROG_TYPE_CGROUP_SOCK:
1461 case BPF_PROG_TYPE_CGROUP_SOCK_ADDR:
1462 return attach_type == prog->expected_attach_type ? 0 : -EINVAL;
1463 default:
1464 return 0;
1465 }
1466}
1467
1468#define BPF_PROG_ATTACH_LAST_FIELD attach_flags 1468#define BPF_PROG_ATTACH_LAST_FIELD attach_flags
1469 1469
1470static int sockmap_get_from_fd(const union bpf_attr *attr, 1470static int sockmap_get_from_fd(const union bpf_attr *attr,