Skip to content

Commit 07cbce2

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next
Daniel Borkmann says: ==================== pull-request: bpf-next 2020-11-14 1) Add BTF generation for kernel modules and extend BTF infra in kernel e.g. support for split BTF loading and validation, from Andrii Nakryiko. 2) Support for pointers beyond pkt_end to recognize LLVM generated patterns on inlined branch conditions, from Alexei Starovoitov. 3) Implements bpf_local_storage for task_struct for BPF LSM, from KP Singh. 4) Enable FENTRY/FEXIT/RAW_TP tracing program to use the bpf_sk_storage infra, from Martin KaFai Lau. 5) Add XDP bulk APIs that introduce a defer/flush mechanism to optimize the XDP_REDIRECT path, from Lorenzo Bianconi. 6) Fix a potential (although rather theoretical) deadlock of hashtab in NMI context, from Song Liu. 7) Fixes for cross and out-of-tree build of bpftool and runqslower allowing build for different target archs on same source tree, from Jean-Philippe Brucker. 8) Fix error path in htab_map_alloc() triggered from syzbot, from Eric Dumazet. 9) Move functionality from test_tcpbpf_user into the test_progs framework so it can run in BPF CI, from Alexander Duyck. 10) Lift hashtab key_size limit to be larger than MAX_BPF_STACK, from Florian Lehner. Note that for the fix from Song we have seen a sparse report on context imbalance which requires changes in sparse itself for proper annotation detection where this is currently being discussed on linux-sparse among developers [0]. Once we have more clarification/guidance after their fix, Song will follow-up. [0] https://lore.kernel.org/linux-sparse/CAHk-=wh4bx8A8dHnX612MsDO13st6uzAz1mJ1PaHHVevJx_ZCw@mail.gmail.com/T/ https://lore.kernel.org/linux-sparse/20201109221345.uklbp3lzgq6g42zb@ltop.local/T/ * git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next: (66 commits) net: mlx5: Add xdp tx return bulking support net: mvpp2: Add xdp tx return bulking support net: mvneta: Add xdp tx return bulking support net: page_pool: Add bulk support for ptr_ring net: xdp: Introduce bulking for xdp tx return path bpf: Expose bpf_d_path helper to sleepable LSM hooks bpf: Augment the set of sleepable LSM hooks bpf: selftest: Use bpf_sk_storage in FENTRY/FEXIT/RAW_TP bpf: Allow using bpf_sk_storage in FENTRY/FEXIT/RAW_TP bpf: Rename some functions in bpf_sk_storage bpf: Folding omem_charge() into sk_storage_charge() selftests/bpf: Add asm tests for pkt vs pkt_end comparison. selftests/bpf: Add skb_pkt_end test bpf: Support for pointers beyond pkt_end. tools/bpf: Always run the *-clean recipes tools/bpf: Add bootstrap/ to .gitignore bpf: Fix NULL dereference in bpf_task_storage tools/bpftool: Fix build slowdown tools/runqslower: Build bpftool using HOSTCC tools/runqslower: Enable out-of-tree build ... ==================== Link: https://lore.kernel.org/r/20201114020819.29584-1-daniel@iogearbox.net Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents 774626f + c14d61f commit 07cbce2

83 files changed

Lines changed: 3907 additions & 1271 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Documentation/ABI/testing/sysfs-kernel-btf‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,11 @@ Description:
1515
information with description of all internal kernel types. See
1616
Documentation/bpf/btf.rst for detailed description of format
1717
itself.
18+
19+
What: /sys/kernel/btf/<module-name>
20+
Date: Nov 2020
21+
KernelVersion: 5.11
22+
Contact: bpf@vger.kernel.org
23+
Description:
24+
Read-only binary attribute exposing kernel module's BTF type
25+
information as an add-on to the kernel's BTF (/sys/kernel/btf/vmlinux).

‎drivers/net/ethernet/marvell/mvneta.c‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1834,8 +1834,13 @@ static void mvneta_txq_bufs_free(struct mvneta_port *pp,
18341834
struct netdev_queue *nq, bool napi)
18351835
{
18361836
unsigned int bytes_compl = 0, pkts_compl = 0;
1837+
struct xdp_frame_bulk bq;
18371838
int i;
18381839

1840+
xdp_frame_bulk_init(&bq);
1841+
1842+
rcu_read_lock(); /* need for xdp_return_frame_bulk */
1843+
18391844
for (i = 0; i < num; i++) {
18401845
struct mvneta_tx_buf *buf = &txq->buf[txq->txq_get_index];
18411846
struct mvneta_tx_desc *tx_desc = txq->descs +
@@ -1857,9 +1862,12 @@ static void mvneta_txq_bufs_free(struct mvneta_port *pp,
18571862
if (napi && buf->type == MVNETA_TYPE_XDP_TX)
18581863
xdp_return_frame_rx_napi(buf->xdpf);
18591864
else
1860-
xdp_return_frame(buf->xdpf);
1865+
xdp_return_frame_bulk(buf->xdpf, &bq);
18611866
}
18621867
}
1868+
xdp_flush_frame_bulk(&bq);
1869+
1870+
rcu_read_unlock();
18631871

18641872
netdev_tx_completed_queue(nq, pkts_compl, bytes_compl);
18651873
}

‎drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2440,8 +2440,13 @@ static void mvpp2_txq_bufs_free(struct mvpp2_port *port,
24402440
struct mvpp2_tx_queue *txq,
24412441
struct mvpp2_txq_pcpu *txq_pcpu, int num)
24422442
{
2443+
struct xdp_frame_bulk bq;
24432444
int i;
24442445

2446+
xdp_frame_bulk_init(&bq);
2447+
2448+
rcu_read_lock(); /* need for xdp_return_frame_bulk */
2449+
24452450
for (i = 0; i < num; i++) {
24462451
struct mvpp2_txq_pcpu_buf *tx_buf =
24472452
txq_pcpu->buffs + txq_pcpu->txq_get_index;
@@ -2454,10 +2459,13 @@ static void mvpp2_txq_bufs_free(struct mvpp2_port *port,
24542459
dev_kfree_skb_any(tx_buf->skb);
24552460
else if (tx_buf->type == MVPP2_TYPE_XDP_TX ||
24562461
tx_buf->type == MVPP2_TYPE_XDP_NDO)
2457-
xdp_return_frame(tx_buf->xdpf);
2462+
xdp_return_frame_bulk(tx_buf->xdpf, &bq);
24582463

24592464
mvpp2_txq_inc_get(txq_pcpu);
24602465
}
2466+
xdp_flush_frame_bulk(&bq);
2467+
2468+
rcu_read_unlock();
24612469
}
24622470

24632471
static inline struct mvpp2_rx_queue *mvpp2_get_rx_queue(struct mvpp2_port *port,

‎drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,8 @@ mlx5e_xmit_xdp_frame(struct mlx5e_xdpsq *sq, struct mlx5e_xmit_data *xdptxd,
366366
static void mlx5e_free_xdpsq_desc(struct mlx5e_xdpsq *sq,
367367
struct mlx5e_xdp_wqe_info *wi,
368368
u32 *xsk_frames,
369-
bool recycle)
369+
bool recycle,
370+
struct xdp_frame_bulk *bq)
370371
{
371372
struct mlx5e_xdp_info_fifo *xdpi_fifo = &sq->db.xdpi_fifo;
372373
u16 i;
@@ -379,7 +380,7 @@ static void mlx5e_free_xdpsq_desc(struct mlx5e_xdpsq *sq,
379380
/* XDP_TX from the XSK RQ and XDP_REDIRECT */
380381
dma_unmap_single(sq->pdev, xdpi.frame.dma_addr,
381382
xdpi.frame.xdpf->len, DMA_TO_DEVICE);
382-
xdp_return_frame(xdpi.frame.xdpf);
383+
xdp_return_frame_bulk(xdpi.frame.xdpf, bq);
383384
break;
384385
case MLX5E_XDP_XMIT_MODE_PAGE:
385386
/* XDP_TX from the regular RQ */
@@ -397,12 +398,15 @@ static void mlx5e_free_xdpsq_desc(struct mlx5e_xdpsq *sq,
397398

398399
bool mlx5e_poll_xdpsq_cq(struct mlx5e_cq *cq)
399400
{
401+
struct xdp_frame_bulk bq;
400402
struct mlx5e_xdpsq *sq;
401403
struct mlx5_cqe64 *cqe;
402404
u32 xsk_frames = 0;
403405
u16 sqcc;
404406
int i;
405407

408+
xdp_frame_bulk_init(&bq);
409+
406410
sq = container_of(cq, struct mlx5e_xdpsq, cq);
407411

408412
if (unlikely(!test_bit(MLX5E_SQ_STATE_ENABLED, &sq->state)))
@@ -434,7 +438,7 @@ bool mlx5e_poll_xdpsq_cq(struct mlx5e_cq *cq)
434438

435439
sqcc += wi->num_wqebbs;
436440

437-
mlx5e_free_xdpsq_desc(sq, wi, &xsk_frames, true);
441+
mlx5e_free_xdpsq_desc(sq, wi, &xsk_frames, true, &bq);
438442
} while (!last_wqe);
439443

440444
if (unlikely(get_cqe_opcode(cqe) != MLX5_CQE_REQ)) {
@@ -447,6 +451,8 @@ bool mlx5e_poll_xdpsq_cq(struct mlx5e_cq *cq)
447451
}
448452
} while ((++i < MLX5E_TX_CQ_POLL_BUDGET) && (cqe = mlx5_cqwq_get_cqe(&cq->wq)));
449453

454+
xdp_flush_frame_bulk(&bq);
455+
450456
if (xsk_frames)
451457
xsk_tx_completed(sq->xsk_pool, xsk_frames);
452458

@@ -463,8 +469,13 @@ bool mlx5e_poll_xdpsq_cq(struct mlx5e_cq *cq)
463469

464470
void mlx5e_free_xdpsq_descs(struct mlx5e_xdpsq *sq)
465471
{
472+
struct xdp_frame_bulk bq;
466473
u32 xsk_frames = 0;
467474

475+
xdp_frame_bulk_init(&bq);
476+
477+
rcu_read_lock(); /* need for xdp_return_frame_bulk */
478+
468479
while (sq->cc != sq->pc) {
469480
struct mlx5e_xdp_wqe_info *wi;
470481
u16 ci;
@@ -474,9 +485,12 @@ void mlx5e_free_xdpsq_descs(struct mlx5e_xdpsq *sq)
474485

475486
sq->cc += wi->num_wqebbs;
476487

477-
mlx5e_free_xdpsq_desc(sq, wi, &xsk_frames, false);
488+
mlx5e_free_xdpsq_desc(sq, wi, &xsk_frames, false, &bq);
478489
}
479490

491+
xdp_flush_frame_bulk(&bq);
492+
rcu_read_unlock();
493+
480494
if (xsk_frames)
481495
xsk_tx_completed(sq->xsk_pool, xsk_frames);
482496
}

‎include/linux/bpf.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ struct seq_operations;
3636
struct bpf_iter_aux_info;
3737
struct bpf_local_storage;
3838
struct bpf_local_storage_map;
39+
struct kobject;
3940

4041
extern struct idr btf_idr;
4142
extern spinlock_t btf_idr_lock;
43+
extern struct kobject *btf_kobj;
4244

4345
typedef int (*bpf_iter_init_seq_priv_t)(void *private_data,
4446
struct bpf_iter_aux_info *aux);
@@ -310,6 +312,7 @@ enum bpf_return_type {
310312
RET_PTR_TO_BTF_ID_OR_NULL, /* returns a pointer to a btf_id or NULL */
311313
RET_PTR_TO_MEM_OR_BTF_ID_OR_NULL, /* returns a pointer to a valid memory or a btf_id or NULL */
312314
RET_PTR_TO_MEM_OR_BTF_ID, /* returns a pointer to a valid memory or a btf_id */
315+
RET_PTR_TO_BTF_ID, /* returns a pointer to a btf_id */
313316
};
314317

315318
/* eBPF function prototype used by verifier to allow BPF_CALLs from eBPF programs
@@ -1294,6 +1297,10 @@ typedef void (*bpf_iter_show_fdinfo_t) (const struct bpf_iter_aux_info *aux,
12941297
typedef int (*bpf_iter_fill_link_info_t)(const struct bpf_iter_aux_info *aux,
12951298
struct bpf_link_info *info);
12961299

1300+
enum bpf_iter_feature {
1301+
BPF_ITER_RESCHED = BIT(0),
1302+
};
1303+
12971304
#define BPF_ITER_CTX_ARG_MAX 2
12981305
struct bpf_iter_reg {
12991306
const char *target;
@@ -1302,6 +1309,7 @@ struct bpf_iter_reg {
13021309
bpf_iter_show_fdinfo_t show_fdinfo;
13031310
bpf_iter_fill_link_info_t fill_link_info;
13041311
u32 ctx_arg_info_size;
1312+
u32 feature;
13051313
struct bpf_ctx_arg_aux ctx_arg_info[BPF_ITER_CTX_ARG_MAX];
13061314
const struct bpf_iter_seq_info *seq_info;
13071315
};

‎include/linux/bpf_lsm.h‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#ifndef _LINUX_BPF_LSM_H
88
#define _LINUX_BPF_LSM_H
99

10+
#include <linux/sched.h>
1011
#include <linux/bpf.h>
1112
#include <linux/lsm_hooks.h>
1213

@@ -26,6 +27,8 @@ extern struct lsm_blob_sizes bpf_lsm_blob_sizes;
2627
int bpf_lsm_verify_prog(struct bpf_verifier_log *vlog,
2728
const struct bpf_prog *prog);
2829

30+
bool bpf_lsm_is_sleepable_hook(u32 btf_id);
31+
2932
static inline struct bpf_storage_blob *bpf_inode(
3033
const struct inode *inode)
3134
{
@@ -35,12 +38,29 @@ static inline struct bpf_storage_blob *bpf_inode(
3538
return inode->i_security + bpf_lsm_blob_sizes.lbs_inode;
3639
}
3740

41+
static inline struct bpf_storage_blob *bpf_task(
42+
const struct task_struct *task)
43+
{
44+
if (unlikely(!task->security))
45+
return NULL;
46+
47+
return task->security + bpf_lsm_blob_sizes.lbs_task;
48+
}
49+
3850
extern const struct bpf_func_proto bpf_inode_storage_get_proto;
3951
extern const struct bpf_func_proto bpf_inode_storage_delete_proto;
52+
extern const struct bpf_func_proto bpf_task_storage_get_proto;
53+
extern const struct bpf_func_proto bpf_task_storage_delete_proto;
4054
void bpf_inode_storage_free(struct inode *inode);
55+
void bpf_task_storage_free(struct task_struct *task);
4156

4257
#else /* !CONFIG_BPF_LSM */
4358

59+
static inline bool bpf_lsm_is_sleepable_hook(u32 btf_id)
60+
{
61+
return false;
62+
}
63+
4464
static inline int bpf_lsm_verify_prog(struct bpf_verifier_log *vlog,
4565
const struct bpf_prog *prog)
4666
{
@@ -53,10 +73,20 @@ static inline struct bpf_storage_blob *bpf_inode(
5373
return NULL;
5474
}
5575

76+
static inline struct bpf_storage_blob *bpf_task(
77+
const struct task_struct *task)
78+
{
79+
return NULL;
80+
}
81+
5682
static inline void bpf_inode_storage_free(struct inode *inode)
5783
{
5884
}
5985

86+
static inline void bpf_task_storage_free(struct task_struct *task)
87+
{
88+
}
89+
6090
#endif /* CONFIG_BPF_LSM */
6191

6292
#endif /* _LINUX_BPF_LSM_H */

‎include/linux/bpf_types.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ BPF_MAP_TYPE(BPF_MAP_TYPE_SOCKHASH, sock_hash_ops)
109109
#endif
110110
#ifdef CONFIG_BPF_LSM
111111
BPF_MAP_TYPE(BPF_MAP_TYPE_INODE_STORAGE, inode_storage_map_ops)
112+
BPF_MAP_TYPE(BPF_MAP_TYPE_TASK_STORAGE, task_storage_map_ops)
112113
#endif
113114
BPF_MAP_TYPE(BPF_MAP_TYPE_CPUMAP, cpu_map_ops)
114115
#if defined(CONFIG_XDP_SOCKETS)

‎include/linux/bpf_verifier.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ struct bpf_reg_state {
4545
enum bpf_reg_type type;
4646
union {
4747
/* valid when type == PTR_TO_PACKET */
48-
u16 range;
48+
int range;
4949

5050
/* valid when type == CONST_PTR_TO_MAP | PTR_TO_MAP_VALUE |
5151
* PTR_TO_MAP_VALUE_OR_NULL

‎include/linux/module.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,10 @@ struct module {
475475
unsigned int num_bpf_raw_events;
476476
struct bpf_raw_event_map *bpf_raw_events;
477477
#endif
478+
#ifdef CONFIG_DEBUG_INFO_BTF_MODULES
479+
unsigned int btf_data_size;
480+
void *btf_data;
481+
#endif
478482
#ifdef CONFIG_JUMP_LABEL
479483
struct jump_entry *jump_entries;
480484
unsigned int num_jump_entries;

‎include/net/bpf_sk_storage.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ void bpf_sk_storage_free(struct sock *sk);
2020

2121
extern const struct bpf_func_proto bpf_sk_storage_get_proto;
2222
extern const struct bpf_func_proto bpf_sk_storage_delete_proto;
23+
extern const struct bpf_func_proto bpf_sk_storage_get_tracing_proto;
24+
extern const struct bpf_func_proto bpf_sk_storage_delete_tracing_proto;
2325

2426
struct bpf_local_storage_elem;
2527
struct bpf_sk_storage_diag;

0 commit comments

Comments
 (0)