aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/bpf/syscall.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-05-11 17:14:46 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-05-11 17:14:46 -0400
commit4bc871984f7cb5b2dec3ae64b570cb02f9ce2227 (patch)
tree12b040a416857423929e7739b5babd81e861e90f /kernel/bpf/syscall.c
parenta1f45efbb90cce436bde335f8ce78538634951c8 (diff)
parenta52956dfc503f8cc5cfe6454959b7049fddb4413 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: 1) Verify lengths of keys provided by the user is AF_KEY, from Kevin Easton. 2) Add device ID for BCM89610 PHY. Thanks to Bhadram Varka. 3) Add Spectre guards to some ATM code, courtesy of Gustavo A. R. Silva. 4) Fix infinite loop in NSH protocol code. To Eric Dumazet we are most grateful for this fix. 5) Line up /proc/net/netlink headers properly. This fix from YU Bo, we do appreciate. 6) Use after free in TLS code. Once again we are blessed by the honorable Eric Dumazet with this fix. 7) Fix regression in TLS code causing stalls on partial TLS records. This fix is bestowed upon us by Andrew Tomt. 8) Deal with too small MTUs properly in LLC code, another great gift from Eric Dumazet. 9) Handle cached route flushing properly wrt. MTU locking in ipv4, to Hangbin Liu we give thanks for this. 10) Fix regression in SO_BINDTODEVIC handling wrt. UDP socket demux. Paolo Abeni, he gave us this. 11) Range check coalescing parameters in mlx4 driver, thank you Moshe Shemesh. 12) Some ipv6 ICMP error handling fixes in rxrpc, from our good brother David Howells. 13) Fix kexec on mlx5 by freeing IRQs in shutdown path. Daniel Juergens, you're the best! 14) Don't send bonding RLB updates to invalid MAC addresses. Debabrata Benerjee saved us! 15) Uh oh, we were leaking in udp_sendmsg and ping_v4_sendmsg. The ship is now water tight, thanks to Andrey Ignatov. 16) IPSEC memory leak in ixgbe from Colin Ian King, man we've got holes everywhere! 17) Fix error path in tcf_proto_create, Jiri Pirko what would we do without you! * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (92 commits) net sched actions: fix refcnt leak in skbmod net: sched: fix error path in tcf_proto_create() when modules are not configured net sched actions: fix invalid pointer dereferencing if skbedit flags missing ixgbe: fix memory leak on ipsec allocation ixgbevf: fix ixgbevf_xmit_frame()'s return type ixgbe: return error on unsupported SFP module when resetting ice: Set rq_last_status when cleaning rq ipv4: fix memory leaks in udp_sendmsg, ping_v4_sendmsg mlxsw: core: Fix an error handling path in 'mlxsw_core_bus_device_register()' bonding: send learning packets for vlans on slave bonding: do not allow rlb updates to invalid mac net/mlx5e: Err if asked to offload TC match on frag being first net/mlx5: E-Switch, Include VF RDMA stats in vport statistics net/mlx5: Free IRQs in shutdown path rxrpc: Trace UDP transmission failure rxrpc: Add a tracepoint to log ICMP/ICMP6 and error messages rxrpc: Fix the min security level for kernel calls rxrpc: Fix error reception on AF_INET6 sockets rxrpc: Fix missing start of call timeout qed: fix spelling mistake: "taskelt" -> "tasklet" ...
Diffstat (limited to 'kernel/bpf/syscall.c')
-rw-r--r--kernel/bpf/syscall.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index ebfe9f29dae8..016ef9025827 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -26,6 +26,7 @@
26#include <linux/cred.h> 26#include <linux/cred.h>
27#include <linux/timekeeping.h> 27#include <linux/timekeeping.h>
28#include <linux/ctype.h> 28#include <linux/ctype.h>
29#include <linux/nospec.h>
29 30
30#define IS_FD_ARRAY(map) ((map)->map_type == BPF_MAP_TYPE_PROG_ARRAY || \ 31#define IS_FD_ARRAY(map) ((map)->map_type == BPF_MAP_TYPE_PROG_ARRAY || \
31 (map)->map_type == BPF_MAP_TYPE_PERF_EVENT_ARRAY || \ 32 (map)->map_type == BPF_MAP_TYPE_PERF_EVENT_ARRAY || \
@@ -102,12 +103,14 @@ const struct bpf_map_ops bpf_map_offload_ops = {
102static struct bpf_map *find_and_alloc_map(union bpf_attr *attr) 103static struct bpf_map *find_and_alloc_map(union bpf_attr *attr)
103{ 104{
104 const struct bpf_map_ops *ops; 105 const struct bpf_map_ops *ops;
106 u32 type = attr->map_type;
105 struct bpf_map *map; 107 struct bpf_map *map;
106 int err; 108 int err;
107 109
108 if (attr->map_type >= ARRAY_SIZE(bpf_map_types)) 110 if (type >= ARRAY_SIZE(bpf_map_types))
109 return ERR_PTR(-EINVAL); 111 return ERR_PTR(-EINVAL);
110 ops = bpf_map_types[attr->map_type]; 112 type = array_index_nospec(type, ARRAY_SIZE(bpf_map_types));
113 ops = bpf_map_types[type];
111 if (!ops) 114 if (!ops)
112 return ERR_PTR(-EINVAL); 115 return ERR_PTR(-EINVAL);
113 116
@@ -122,7 +125,7 @@ static struct bpf_map *find_and_alloc_map(union bpf_attr *attr)
122 if (IS_ERR(map)) 125 if (IS_ERR(map))
123 return map; 126 return map;
124 map->ops = ops; 127 map->ops = ops;
125 map->map_type = attr->map_type; 128 map->map_type = type;
126 return map; 129 return map;
127} 130}
128 131
@@ -871,11 +874,17 @@ static const struct bpf_prog_ops * const bpf_prog_types[] = {
871 874
872static int find_prog_type(enum bpf_prog_type type, struct bpf_prog *prog) 875static int find_prog_type(enum bpf_prog_type type, struct bpf_prog *prog)
873{ 876{
874 if (type >= ARRAY_SIZE(bpf_prog_types) || !bpf_prog_types[type]) 877 const struct bpf_prog_ops *ops;
878
879 if (type >= ARRAY_SIZE(bpf_prog_types))
880 return -EINVAL;
881 type = array_index_nospec(type, ARRAY_SIZE(bpf_prog_types));
882 ops = bpf_prog_types[type];
883 if (!ops)
875 return -EINVAL; 884 return -EINVAL;
876 885
877 if (!bpf_prog_is_dev_bound(prog->aux)) 886 if (!bpf_prog_is_dev_bound(prog->aux))
878 prog->aux->ops = bpf_prog_types[type]; 887 prog->aux->ops = ops;
879 else 888 else
880 prog->aux->ops = &bpf_offload_prog_ops; 889 prog->aux->ops = &bpf_offload_prog_ops;
881 prog->type = type; 890 prog->type = type;