History

Merge https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf

Daniel Borkmann says: ==================== bpf 2021-12-08 We've added 12 non-merge commits during the last 22 day(s) which contain a total of 29 files changed, 659 insertions(+), 80 deletions(-). The main changes are: 1) Fix an off-by-two error in packet range markings and also add a batch of new tests for coverage of these corner cases, from Maxim Mikityanskiy. 2) Fix a compilation issue on MIPS JIT for R10000 CPUs, from Johan Almbladh. 3) Fix two functional regressions and a build warning related to BTF kfunc for modules, from Kumar Kartikeya Dwivedi. 4) Fix outdated code and docs regarding BPF's migrate_disable() use on non- PREEMPT_RT kernels, from Sebastian Andrzej Siewior. 5) Add missing includes in order to be able to detangle cgroup vs bpf header dependencies, from Jakub Kicinski. 6) Fix regression in BPF sockmap tests caused by missing detachment of progs from sockets when they are removed from the map, from John Fastabend. 7) Fix a missing "no previous prototype" warning in x86 JIT caused by BPF dispatcher, from Björn Töpel. * https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf: bpf: Add selftests to cover packet access corner cases bpf: Fix the off-by-two error in range markings treewide: Add missing includes masked by cgroup -> bpf dependency tools/resolve_btfids: Skip unresolved symbol warning for empty BTF sets bpf: Fix bpf_check_mod_kfunc_call for built-in modules bpf: Make CONFIG_DEBUG_INFO_BTF depend upon CONFIG_BPF_SYSCALL mips, bpf: Fix reference to non-existing Kconfig symbol bpf: Make sure bpf_disable_instrumentation() is safe vs preemption. Documentation/locking/locktypes: Update migrate_disable() bits. bpf, sockmap: Re-evaluate proto ops when psock is removed from sockmap bpf, sockmap: Attach map progs to psock early for feature probes bpf, x86: Fix "no previous prototype" warning ====================

Jakub Kicinski committed 4 years ago

Commit 6efcdad2 parents 2b29cb9 b560b2129 files · +659 −80Browse files

Showing the changes to include/linux (5 of 29 files). Show all

Unified · Split

5 files
  1. include/linux/bpf.h +3 −14
  2. include/linux/btf.h +10 −4
  3. include/linux/cacheinfo.h +0 −1
  4. include/linux/device/driver.h +1 −0
  5. include/linux/filter.h +1 −4
include/linux/bpf.h+3−14
@@ -732,6 +732,7 @@ int bpf_trampoline_unlink_prog(struct bpf_prog *prog, struct bpf_trampoline *tr) · 731 unmodified lines
732struct bpf_trampoline *bpf_trampoline_get(u64 key,732struct bpf_trampoline *bpf_trampoline_get(u64 key,
733 struct bpf_attach_target_info *tgt_info);733 struct bpf_attach_target_info *tgt_info);
734void bpf_trampoline_put(struct bpf_trampoline *tr);734void bpf_trampoline_put(struct bpf_trampoline *tr);
735int arch_prepare_bpf_dispatcher(void *image, s64 *funcs, int num_funcs);
735#define BPF_DISPATCHER_INIT(_name) { \736#define BPF_DISPATCHER_INIT(_name) { \
736 .mutex = __MUTEX_INITIALIZER(_name.mutex), \737 .mutex = __MUTEX_INITIALIZER(_name.mutex), \
737 .func = &_name##_func, \738 .func = &_name##_func, \
@@ -1352,28 +1353,16 @@ extern struct mutex bpf_stats_enabled_mutex; · 614 unmodified lines
1352 * kprobes, tracepoints) to prevent deadlocks on map operations as any of1353 * kprobes, tracepoints) to prevent deadlocks on map operations as any of
1353 * these events can happen inside a region which holds a map bucket lock1354 * these events can happen inside a region which holds a map bucket lock
1354 * and can deadlock on it.1355 * and can deadlock on it.
1355 *
1356 * Use the preemption safe inc/dec variants on RT because migrate disable
1357 * is preemptible on RT and preemption in the middle of the RMW operation
1358 * might lead to inconsistent state. Use the raw variants for non RT
1359 * kernels as migrate_disable() maps to preempt_disable() so the slightly
1360 * more expensive save operation can be avoided.
1361 */1356 */
1362static inline void bpf_disable_instrumentation(void)1357static inline void bpf_disable_instrumentation(void)
1363{1358{
1364 migrate_disable();1359 migrate_disable();
1365 if (IS_ENABLED(CONFIG_PREEMPT_RT))1360 this_cpu_inc(bpf_prog_active);
1366 this_cpu_inc(bpf_prog_active);
1367 else
1368 __this_cpu_inc(bpf_prog_active);
1369}1361}
1370 1362
1371static inline void bpf_enable_instrumentation(void)1363static inline void bpf_enable_instrumentation(void)
1372{1364{
1373 if (IS_ENABLED(CONFIG_PREEMPT_RT))1365 this_cpu_dec(bpf_prog_active);
1374 this_cpu_dec(bpf_prog_active);
1375 else
1376 __this_cpu_dec(bpf_prog_active);
1377 migrate_enable();1366 migrate_enable();
1378}1367}
1379 1368
include/linux/btf.h+10−4
@@ -245,7 +245,10 @@ struct kfunc_btf_id_set { · 244 unmodified lines
245 struct module *owner;245 struct module *owner;
246};246};
247 247
248struct kfunc_btf_id_list;248struct kfunc_btf_id_list {
249 struct list_head list;
250 struct mutex mutex;
251};
249 252
250#ifdef CONFIG_DEBUG_INFO_BTF_MODULES253#ifdef CONFIG_DEBUG_INFO_BTF_MODULES
251void register_kfunc_btf_id_set(struct kfunc_btf_id_list *l,254void register_kfunc_btf_id_set(struct kfunc_btf_id_list *l,
@@ -254,6 +257,9 @@ void unregister_kfunc_btf_id_set(struct kfunc_btf_id_list *l, · 2 unmodified lines
254 struct kfunc_btf_id_set *s);257 struct kfunc_btf_id_set *s);
255bool bpf_check_mod_kfunc_call(struct kfunc_btf_id_list *klist, u32 kfunc_id,258bool bpf_check_mod_kfunc_call(struct kfunc_btf_id_list *klist, u32 kfunc_id,
256 struct module *owner);259 struct module *owner);
260
261extern struct kfunc_btf_id_list bpf_tcp_ca_kfunc_list;
262extern struct kfunc_btf_id_list prog_test_kfunc_list;
257#else263#else
258static inline void register_kfunc_btf_id_set(struct kfunc_btf_id_list *l,264static inline void register_kfunc_btf_id_set(struct kfunc_btf_id_list *l,
259 struct kfunc_btf_id_set *s)265 struct kfunc_btf_id_set *s)
@@ -268,13 +274,13 @@ static inline bool bpf_check_mod_kfunc_call(struct kfunc_btf_id_list *klist, · 8 unmodified lines
268{274{
269 return false;275 return false;
270}276}
277
278static struct kfunc_btf_id_list bpf_tcp_ca_kfunc_list __maybe_unused;
279static struct kfunc_btf_id_list prog_test_kfunc_list __maybe_unused;
271#endif280#endif
272 281
273#define DEFINE_KFUNC_BTF_ID_SET(set, name) \282#define DEFINE_KFUNC_BTF_ID_SET(set, name) \
274 struct kfunc_btf_id_set name = { LIST_HEAD_INIT(name.list), (set), \283 struct kfunc_btf_id_set name = { LIST_HEAD_INIT(name.list), (set), \
275 THIS_MODULE }284 THIS_MODULE }
276 285
277extern struct kfunc_btf_id_list bpf_tcp_ca_kfunc_list;
278extern struct kfunc_btf_id_list prog_test_kfunc_list;
279
280#endif286#endif
include/linux/cacheinfo.h+0−1
@@ -3,7 +3,6 @@ · 2 unmodified lines
3#define _LINUX_CACHEINFO_H3#define _LINUX_CACHEINFO_H
4 4
5#include <linux/bitops.h>5#include <linux/bitops.h>
6#include <linux/cpu.h>
7#include <linux/cpumask.h>6#include <linux/cpumask.h>
8#include <linux/smp.h>7#include <linux/smp.h>
9 8
include/linux/device/driver.h+1−0
@@ -18,6 +18,7 @@ · 17 unmodified lines
18#include <linux/klist.h>18#include <linux/klist.h>
19#include <linux/pm.h>19#include <linux/pm.h>
20#include <linux/device/bus.h>20#include <linux/device/bus.h>
21#include <linux/module.h>
21 22
22/**23/**
23 * enum probe_type - device driver probe type to try24 * enum probe_type - device driver probe type to try
include/linux/filter.h+1−4
@@ -6,6 +6,7 @@ · 5 unmodified lines
6#define __LINUX_FILTER_H__6#define __LINUX_FILTER_H__
7 7
8#include <linux/atomic.h>8#include <linux/atomic.h>
9#include <linux/bpf.h>
9#include <linux/refcount.h>10#include <linux/refcount.h>
10#include <linux/compat.h>11#include <linux/compat.h>
11#include <linux/skbuff.h>12#include <linux/skbuff.h>
@@ -26,7 +27,6 @@ · 14 unmodified lines
26 27
27#include <asm/byteorder.h>28#include <asm/byteorder.h>
28#include <uapi/linux/filter.h>29#include <uapi/linux/filter.h>
29#include <uapi/linux/bpf.h>
30 30
31struct sk_buff;31struct sk_buff;
32struct sock;32struct sock;
@@ -640,9 +640,6 @@ static __always_inline u32 bpf_prog_run(const struct bpf_prog *prog, const void · 607 unmodified lines
640 * This uses migrate_disable/enable() explicitly to document that the640 * This uses migrate_disable/enable() explicitly to document that the
641 * invocation of a BPF program does not require reentrancy protection641 * invocation of a BPF program does not require reentrancy protection
642 * against a BPF program which is invoked from a preempting task.642 * against a BPF program which is invoked from a preempting task.
643 *
644 * For non RT enabled kernels migrate_disable/enable() maps to
645 * preempt_disable/enable(), i.e. it disables also preemption.
646 */643 */
647static inline u32 bpf_prog_run_pin_on_cpu(const struct bpf_prog *prog,644static inline u32 bpf_prog_run_pin_on_cpu(const struct bpf_prog *prog,
648 const void *ctx)645 const void *ctx)