Skip to content

Commit e708e2b

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf
Daniel Borkmann says: ==================== pull-request: bpf 2020-06-30 The following pull-request contains BPF updates for your *net* tree. We've added 28 non-merge commits during the last 9 day(s) which contain a total of 35 files changed, 486 insertions(+), 232 deletions(-). The main changes are: 1) Fix an incorrect verifier branch elimination for PTR_TO_BTF_ID pointer types, from Yonghong Song. 2) Fix UAPI for sockmap and flow_dissector progs that were ignoring various arguments passed to BPF_PROG_{ATTACH,DETACH}, from Lorenz Bauer & Jakub Sitnicki. 3) Fix broken AF_XDP DMA hacks that are poking into dma-direct and swiotlb internals and integrate it properly into DMA core, from Christoph Hellwig. 4) Fix RCU splat from recent changes to avoid skipping ingress policy when kTLS is enabled, from John Fastabend. 5) Fix BPF ringbuf map to enforce size to be the power of 2 in order for its position masking to work, from Andrii Nakryiko. 6) Fix regression from CAP_BPF work to re-allow CAP_SYS_ADMIN for loading of network programs, from Maciej Żenczykowski. 7) Fix libbpf section name prefix for devmap progs, from Jesper Dangaard Brouer. 8) Fix formatting in UAPI documentation for BPF helpers, from Quentin Monnet. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 0433c93 + d923021 commit e708e2b

35 files changed

Lines changed: 486 additions & 232 deletions

‎Documentation/core-api/dma-api.rst‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,14 @@ Returns the maximum size of a mapping for the device. The size parameter
204204
of the mapping functions like dma_map_single(), dma_map_page() and
205205
others should not be larger than the returned value.
206206

207+
::
208+
209+
bool
210+
dma_need_sync(struct device *dev, dma_addr_t dma_addr);
211+
212+
Returns %true if dma_sync_single_for_{device,cpu} calls are required to
213+
transfer memory ownership. Returns %false if those calls can be skipped.
214+
207215
::
208216

209217
unsigned long

‎include/linux/bpf-netns.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ int netns_bpf_prog_query(const union bpf_attr *attr,
3333
union bpf_attr __user *uattr);
3434
int netns_bpf_prog_attach(const union bpf_attr *attr,
3535
struct bpf_prog *prog);
36-
int netns_bpf_prog_detach(const union bpf_attr *attr);
36+
int netns_bpf_prog_detach(const union bpf_attr *attr, enum bpf_prog_type ptype);
3737
int netns_bpf_link_create(const union bpf_attr *attr,
3838
struct bpf_prog *prog);
3939
#else
@@ -49,7 +49,8 @@ static inline int netns_bpf_prog_attach(const union bpf_attr *attr,
4949
return -EOPNOTSUPP;
5050
}
5151

52-
static inline int netns_bpf_prog_detach(const union bpf_attr *attr)
52+
static inline int netns_bpf_prog_detach(const union bpf_attr *attr,
53+
enum bpf_prog_type ptype)
5354
{
5455
return -EOPNOTSUPP;
5556
}

‎include/linux/bpf.h‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,13 +1543,16 @@ static inline void bpf_map_offload_map_free(struct bpf_map *map)
15431543
#endif /* CONFIG_NET && CONFIG_BPF_SYSCALL */
15441544

15451545
#if defined(CONFIG_BPF_STREAM_PARSER)
1546-
int sock_map_prog_update(struct bpf_map *map, struct bpf_prog *prog, u32 which);
1546+
int sock_map_prog_update(struct bpf_map *map, struct bpf_prog *prog,
1547+
struct bpf_prog *old, u32 which);
15471548
int sock_map_get_from_fd(const union bpf_attr *attr, struct bpf_prog *prog);
1549+
int sock_map_prog_detach(const union bpf_attr *attr, enum bpf_prog_type ptype);
15481550
void sock_map_unhash(struct sock *sk);
15491551
void sock_map_close(struct sock *sk, long timeout);
15501552
#else
15511553
static inline int sock_map_prog_update(struct bpf_map *map,
1552-
struct bpf_prog *prog, u32 which)
1554+
struct bpf_prog *prog,
1555+
struct bpf_prog *old, u32 which)
15531556
{
15541557
return -EOPNOTSUPP;
15551558
}
@@ -1559,6 +1562,12 @@ static inline int sock_map_get_from_fd(const union bpf_attr *attr,
15591562
{
15601563
return -EINVAL;
15611564
}
1565+
1566+
static inline int sock_map_prog_detach(const union bpf_attr *attr,
1567+
enum bpf_prog_type ptype)
1568+
{
1569+
return -EOPNOTSUPP;
1570+
}
15621571
#endif /* CONFIG_BPF_STREAM_PARSER */
15631572

15641573
#if defined(CONFIG_INET) && defined(CONFIG_BPF_SYSCALL)

‎include/linux/btf.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ static inline bool btf_type_is_int(const struct btf_type *t)
8282
return BTF_INFO_KIND(t->info) == BTF_KIND_INT;
8383
}
8484

85+
static inline bool btf_type_is_small_int(const struct btf_type *t)
86+
{
87+
return btf_type_is_int(t) && t->size <= sizeof(u64);
88+
}
89+
8590
static inline bool btf_type_is_enum(const struct btf_type *t)
8691
{
8792
return BTF_INFO_KIND(t->info) == BTF_KIND_ENUM;

‎include/linux/dma-direct.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,5 @@ int dma_direct_mmap(struct device *dev, struct vm_area_struct *vma,
8787
void *cpu_addr, dma_addr_t dma_addr, size_t size,
8888
unsigned long attrs);
8989
int dma_direct_supported(struct device *dev, u64 mask);
90+
bool dma_direct_need_sync(struct device *dev, dma_addr_t dma_addr);
9091
#endif /* _LINUX_DMA_DIRECT_H */

‎include/linux/dma-mapping.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ int dma_set_mask(struct device *dev, u64 mask);
461461
int dma_set_coherent_mask(struct device *dev, u64 mask);
462462
u64 dma_get_required_mask(struct device *dev);
463463
size_t dma_max_mapping_size(struct device *dev);
464+
bool dma_need_sync(struct device *dev, dma_addr_t dma_addr);
464465
unsigned long dma_get_merge_boundary(struct device *dev);
465466
#else /* CONFIG_HAS_DMA */
466467
static inline dma_addr_t dma_map_page_attrs(struct device *dev,
@@ -571,6 +572,10 @@ static inline size_t dma_max_mapping_size(struct device *dev)
571572
{
572573
return 0;
573574
}
575+
static inline bool dma_need_sync(struct device *dev, dma_addr_t dma_addr)
576+
{
577+
return false;
578+
}
574579
static inline unsigned long dma_get_merge_boundary(struct device *dev)
575580
{
576581
return 0;

‎include/linux/skmsg.h‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,19 @@ static inline void psock_set_prog(struct bpf_prog **pprog,
430430
bpf_prog_put(prog);
431431
}
432432

433+
static inline int psock_replace_prog(struct bpf_prog **pprog,
434+
struct bpf_prog *prog,
435+
struct bpf_prog *old)
436+
{
437+
if (cmpxchg(pprog, old, prog) != old)
438+
return -ENOENT;
439+
440+
if (old)
441+
bpf_prog_put(old);
442+
443+
return 0;
444+
}
445+
433446
static inline void psock_progs_drop(struct sk_psock_progs *progs)
434447
{
435448
psock_set_prog(&progs->msg_parser, NULL);

‎include/net/flow_dissector.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,8 @@ flow_dissector_init_keys(struct flow_dissector_key_control *key_control,
372372
}
373373

374374
#ifdef CONFIG_BPF_SYSCALL
375-
int flow_dissector_bpf_prog_attach(struct net *net, struct bpf_prog *prog);
375+
int flow_dissector_bpf_prog_attach_check(struct net *net,
376+
struct bpf_prog *prog);
376377
#endif /* CONFIG_BPF_SYSCALL */
377378

378379
#endif

‎include/net/netns/bpf.h‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@
99
#include <linux/bpf-netns.h>
1010

1111
struct bpf_prog;
12+
struct bpf_prog_array;
1213

1314
struct netns_bpf {
14-
struct bpf_prog __rcu *progs[MAX_NETNS_BPF_ATTACH_TYPE];
15-
struct bpf_link *links[MAX_NETNS_BPF_ATTACH_TYPE];
15+
/* Array of programs to run compiled from progs or links */
16+
struct bpf_prog_array __rcu *run_array[MAX_NETNS_BPF_ATTACH_TYPE];
17+
struct bpf_prog *progs[MAX_NETNS_BPF_ATTACH_TYPE];
18+
struct list_head links[MAX_NETNS_BPF_ATTACH_TYPE];
1619
};
1720

1821
#endif /* __NETNS_BPF_H__ */

‎include/net/xsk_buff_pool.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ struct xsk_buff_pool {
4040
u32 headroom;
4141
u32 chunk_size;
4242
u32 frame_len;
43-
bool cheap_dma;
43+
bool dma_need_sync;
4444
bool unaligned;
4545
void *addrs;
4646
struct device *dev;
@@ -80,7 +80,7 @@ static inline dma_addr_t xp_get_frame_dma(struct xdp_buff_xsk *xskb)
8080
void xp_dma_sync_for_cpu_slow(struct xdp_buff_xsk *xskb);
8181
static inline void xp_dma_sync_for_cpu(struct xdp_buff_xsk *xskb)
8282
{
83-
if (xskb->pool->cheap_dma)
83+
if (!xskb->pool->dma_need_sync)
8484
return;
8585

8686
xp_dma_sync_for_cpu_slow(xskb);
@@ -91,7 +91,7 @@ void xp_dma_sync_for_device_slow(struct xsk_buff_pool *pool, dma_addr_t dma,
9191
static inline void xp_dma_sync_for_device(struct xsk_buff_pool *pool,
9292
dma_addr_t dma, size_t size)
9393
{
94-
if (pool->cheap_dma)
94+
if (!pool->dma_need_sync)
9595
return;
9696

9797
xp_dma_sync_for_device_slow(pool, dma, size);

0 commit comments

Comments
 (0)