Commit 6efcdadc authored by Jakub Kicinski's avatar Jakub Kicinski

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
====================

Link: https://lore.kernel.org/r/20211208155125.11826-1-daniel@iogearbox.netSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 2b29cb9e b560b21f
...@@ -439,11 +439,9 @@ preemption. The following substitution works on both kernels:: ...@@ -439,11 +439,9 @@ preemption. The following substitution works on both kernels::
spin_lock(&p->lock); spin_lock(&p->lock);
p->count += this_cpu_read(var2); p->count += this_cpu_read(var2);
On a non-PREEMPT_RT kernel migrate_disable() maps to preempt_disable()
which makes the above code fully equivalent. On a PREEMPT_RT kernel
migrate_disable() ensures that the task is pinned on the current CPU which migrate_disable() ensures that the task is pinned on the current CPU which
in turn guarantees that the per-CPU access to var1 and var2 are staying on in turn guarantees that the per-CPU access to var1 and var2 are staying on
the same CPU. the same CPU while the task remains preemptible.
The migrate_disable() substitution is not valid for the following The migrate_disable() substitution is not valid for the following
scenario:: scenario::
...@@ -456,9 +454,8 @@ scenario:: ...@@ -456,9 +454,8 @@ scenario::
p = this_cpu_ptr(&var1); p = this_cpu_ptr(&var1);
p->val = func2(); p->val = func2();
While correct on a non-PREEMPT_RT kernel, this breaks on PREEMPT_RT because This breaks because migrate_disable() does not protect against reentrancy from
here migrate_disable() does not protect against reentrancy from a a preempting task. A correct substitution for this case is::
preempting task. A correct substitution for this case is::
func() func()
{ {
......
...@@ -98,7 +98,7 @@ do { \ ...@@ -98,7 +98,7 @@ do { \
#define emit(...) __emit(__VA_ARGS__) #define emit(...) __emit(__VA_ARGS__)
/* Workaround for R10000 ll/sc errata */ /* Workaround for R10000 ll/sc errata */
#ifdef CONFIG_WAR_R10000 #ifdef CONFIG_WAR_R10000_LLSC
#define LLSC_beqz beqzl #define LLSC_beqz beqzl
#else #else
#define LLSC_beqz beqz #define LLSC_beqz beqz
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/falloc.h> #include <linux/falloc.h>
#include <linux/suspend.h> #include <linux/suspend.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/module.h>
#include "blk.h" #include "blk.h"
static inline struct inode *bdev_file_inode(struct file *file) static inline struct inode *bdev_file_inode(struct file *file)
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <linux/shmem_fs.h> #include <linux/shmem_fs.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/module.h>
#ifdef CONFIG_X86 #ifdef CONFIG_X86
#include <asm/set_memory.h> #include <asm/set_memory.h>
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <linux/slab.h> /* fault-inject.h is not standalone! */ #include <linux/slab.h> /* fault-inject.h is not standalone! */
#include <linux/fault-inject.h> #include <linux/fault-inject.h>
#include <linux/sched/mm.h>
#include "gem/i915_gem_lmem.h" #include "gem/i915_gem_lmem.h"
#include "i915_trace.h" #include "i915_trace.h"
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/sched/clock.h> #include <linux/sched/clock.h>
#include <linux/sched/signal.h> #include <linux/sched/signal.h>
#include <linux/sched/mm.h>
#include "gem/i915_gem_context.h" #include "gem/i915_gem_context.h"
#include "gt/intel_breadcrumbs.h" #include "gt/intel_breadcrumbs.h"
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
#include <linux/reset.h> #include <linux/reset.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/slab.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
*/ */
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/sched/mm.h>
#include "msm_drv.h" #include "msm_drv.h"
#include "msm_gem.h" #include "msm_gem.h"
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/shmem_fs.h> #include <linux/shmem_fs.h>
#include <linux/file.h> #include <linux/file.h>
#include <linux/module.h>
#include <drm/drm_cache.h> #include <drm/drm_cache.h>
#include <drm/ttm/ttm_bo_driver.h> #include <drm/ttm/ttm_bo_driver.h>
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/module.h>
#include "hinic_hw_dev.h" #include "hinic_hw_dev.h"
#include "hinic_dev.h" #include "hinic_dev.h"
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
* *
*/ */
#include <linux/module.h>
#include "otx2_common.h" #include "otx2_common.h"
#include "otx2_ptp.h" #include "otx2_ptp.h"
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/phy/phy.h> #include <linux/phy/phy.h>
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
#include <linux/module.h>
#include "pcie-designware.h" #include "pcie-designware.h"
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/pm_domain.h> #include <linux/pm_domain.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/reset.h> #include <linux/reset.h>
#include <linux/module.h>
#include "pcie-designware.h" #include "pcie-designware.h"
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
*/ */
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/slab.h>
#include "core.h" #include "core.h"
#include "drd.h" #include "drd.h"
#include "host-export.h" #include "host-export.h"
......
...@@ -732,6 +732,7 @@ int bpf_trampoline_unlink_prog(struct bpf_prog *prog, struct bpf_trampoline *tr) ...@@ -732,6 +732,7 @@ int bpf_trampoline_unlink_prog(struct bpf_prog *prog, struct bpf_trampoline *tr)
struct bpf_trampoline *bpf_trampoline_get(u64 key, struct bpf_trampoline *bpf_trampoline_get(u64 key,
struct bpf_attach_target_info *tgt_info); struct bpf_attach_target_info *tgt_info);
void bpf_trampoline_put(struct bpf_trampoline *tr); void bpf_trampoline_put(struct bpf_trampoline *tr);
int arch_prepare_bpf_dispatcher(void *image, s64 *funcs, int num_funcs);
#define BPF_DISPATCHER_INIT(_name) { \ #define BPF_DISPATCHER_INIT(_name) { \
.mutex = __MUTEX_INITIALIZER(_name.mutex), \ .mutex = __MUTEX_INITIALIZER(_name.mutex), \
.func = &_name##_func, \ .func = &_name##_func, \
...@@ -1352,28 +1353,16 @@ extern struct mutex bpf_stats_enabled_mutex; ...@@ -1352,28 +1353,16 @@ extern struct mutex bpf_stats_enabled_mutex;
* kprobes, tracepoints) to prevent deadlocks on map operations as any of * kprobes, tracepoints) to prevent deadlocks on map operations as any of
* these events can happen inside a region which holds a map bucket lock * these events can happen inside a region which holds a map bucket lock
* and can deadlock on it. * and can deadlock on it.
*
* Use the preemption safe inc/dec variants on RT because migrate disable
* is preemptible on RT and preemption in the middle of the RMW operation
* might lead to inconsistent state. Use the raw variants for non RT
* kernels as migrate_disable() maps to preempt_disable() so the slightly
* more expensive save operation can be avoided.
*/ */
static inline void bpf_disable_instrumentation(void) static inline void bpf_disable_instrumentation(void)
{ {
migrate_disable(); migrate_disable();
if (IS_ENABLED(CONFIG_PREEMPT_RT)) this_cpu_inc(bpf_prog_active);
this_cpu_inc(bpf_prog_active);
else
__this_cpu_inc(bpf_prog_active);
} }
static inline void bpf_enable_instrumentation(void) static inline void bpf_enable_instrumentation(void)
{ {
if (IS_ENABLED(CONFIG_PREEMPT_RT)) this_cpu_dec(bpf_prog_active);
this_cpu_dec(bpf_prog_active);
else
__this_cpu_dec(bpf_prog_active);
migrate_enable(); migrate_enable();
} }
......
...@@ -245,7 +245,10 @@ struct kfunc_btf_id_set { ...@@ -245,7 +245,10 @@ struct kfunc_btf_id_set {
struct module *owner; struct module *owner;
}; };
struct kfunc_btf_id_list; struct kfunc_btf_id_list {
struct list_head list;
struct mutex mutex;
};
#ifdef CONFIG_DEBUG_INFO_BTF_MODULES #ifdef CONFIG_DEBUG_INFO_BTF_MODULES
void register_kfunc_btf_id_set(struct kfunc_btf_id_list *l, void 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, ...@@ -254,6 +257,9 @@ void unregister_kfunc_btf_id_set(struct kfunc_btf_id_list *l,
struct kfunc_btf_id_set *s); struct kfunc_btf_id_set *s);
bool bpf_check_mod_kfunc_call(struct kfunc_btf_id_list *klist, u32 kfunc_id, bool bpf_check_mod_kfunc_call(struct kfunc_btf_id_list *klist, u32 kfunc_id,
struct module *owner); struct module *owner);
extern struct kfunc_btf_id_list bpf_tcp_ca_kfunc_list;
extern struct kfunc_btf_id_list prog_test_kfunc_list;
#else #else
static inline void register_kfunc_btf_id_set(struct kfunc_btf_id_list *l, static inline void register_kfunc_btf_id_set(struct kfunc_btf_id_list *l,
struct kfunc_btf_id_set *s) struct kfunc_btf_id_set *s)
...@@ -268,13 +274,13 @@ static inline bool bpf_check_mod_kfunc_call(struct kfunc_btf_id_list *klist, ...@@ -268,13 +274,13 @@ static inline bool bpf_check_mod_kfunc_call(struct kfunc_btf_id_list *klist,
{ {
return false; return false;
} }
static struct kfunc_btf_id_list bpf_tcp_ca_kfunc_list __maybe_unused;
static struct kfunc_btf_id_list prog_test_kfunc_list __maybe_unused;
#endif #endif
#define DEFINE_KFUNC_BTF_ID_SET(set, name) \ #define DEFINE_KFUNC_BTF_ID_SET(set, name) \
struct kfunc_btf_id_set name = { LIST_HEAD_INIT(name.list), (set), \ struct kfunc_btf_id_set name = { LIST_HEAD_INIT(name.list), (set), \
THIS_MODULE } THIS_MODULE }
extern struct kfunc_btf_id_list bpf_tcp_ca_kfunc_list;
extern struct kfunc_btf_id_list prog_test_kfunc_list;
#endif #endif
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#define _LINUX_CACHEINFO_H #define _LINUX_CACHEINFO_H
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/cpu.h>
#include <linux/cpumask.h> #include <linux/cpumask.h>
#include <linux/smp.h> #include <linux/smp.h>
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/klist.h> #include <linux/klist.h>
#include <linux/pm.h> #include <linux/pm.h>
#include <linux/device/bus.h> #include <linux/device/bus.h>
#include <linux/module.h>
/** /**
* enum probe_type - device driver probe type to try * enum probe_type - device driver probe type to try
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define __LINUX_FILTER_H__ #define __LINUX_FILTER_H__
#include <linux/atomic.h> #include <linux/atomic.h>
#include <linux/bpf.h>
#include <linux/refcount.h> #include <linux/refcount.h>
#include <linux/compat.h> #include <linux/compat.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
...@@ -26,7 +27,6 @@ ...@@ -26,7 +27,6 @@
#include <asm/byteorder.h> #include <asm/byteorder.h>
#include <uapi/linux/filter.h> #include <uapi/linux/filter.h>
#include <uapi/linux/bpf.h>
struct sk_buff; struct sk_buff;
struct sock; struct sock;
...@@ -640,9 +640,6 @@ static __always_inline u32 bpf_prog_run(const struct bpf_prog *prog, const void ...@@ -640,9 +640,6 @@ static __always_inline u32 bpf_prog_run(const struct bpf_prog *prog, const void
* This uses migrate_disable/enable() explicitly to document that the * This uses migrate_disable/enable() explicitly to document that the
* invocation of a BPF program does not require reentrancy protection * invocation of a BPF program does not require reentrancy protection
* against a BPF program which is invoked from a preempting task. * against a BPF program which is invoked from a preempting task.
*
* For non RT enabled kernels migrate_disable/enable() maps to
* preempt_disable/enable(), i.e. it disables also preemption.
*/ */
static inline u32 bpf_prog_run_pin_on_cpu(const struct bpf_prog *prog, static inline u32 bpf_prog_run_pin_on_cpu(const struct bpf_prog *prog,
const void *ctx) const void *ctx)
......
...@@ -6346,11 +6346,6 @@ BTF_ID_LIST_GLOBAL_SINGLE(btf_task_struct_ids, struct, task_struct) ...@@ -6346,11 +6346,6 @@ BTF_ID_LIST_GLOBAL_SINGLE(btf_task_struct_ids, struct, task_struct)
/* BTF ID set registration API for modules */ /* BTF ID set registration API for modules */
struct kfunc_btf_id_list {
struct list_head list;
struct mutex mutex;
};
#ifdef CONFIG_DEBUG_INFO_BTF_MODULES #ifdef CONFIG_DEBUG_INFO_BTF_MODULES
void register_kfunc_btf_id_set(struct kfunc_btf_id_list *l, void register_kfunc_btf_id_set(struct kfunc_btf_id_list *l,
...@@ -6376,8 +6371,6 @@ bool bpf_check_mod_kfunc_call(struct kfunc_btf_id_list *klist, u32 kfunc_id, ...@@ -6376,8 +6371,6 @@ bool bpf_check_mod_kfunc_call(struct kfunc_btf_id_list *klist, u32 kfunc_id,
{ {
struct kfunc_btf_id_set *s; struct kfunc_btf_id_set *s;
if (!owner)
return false;
mutex_lock(&klist->mutex); mutex_lock(&klist->mutex);
list_for_each_entry(s, &klist->list, list) { list_for_each_entry(s, &klist->list, list) {
if (s->owner == owner && btf_id_set_contains(s->set, kfunc_id)) { if (s->owner == owner && btf_id_set_contains(s->set, kfunc_id)) {
...@@ -6389,8 +6382,6 @@ bool bpf_check_mod_kfunc_call(struct kfunc_btf_id_list *klist, u32 kfunc_id, ...@@ -6389,8 +6382,6 @@ bool bpf_check_mod_kfunc_call(struct kfunc_btf_id_list *klist, u32 kfunc_id,
return false; return false;
} }
#endif
#define DEFINE_KFUNC_BTF_ID_LIST(name) \ #define DEFINE_KFUNC_BTF_ID_LIST(name) \
struct kfunc_btf_id_list name = { LIST_HEAD_INIT(name.list), \ struct kfunc_btf_id_list name = { LIST_HEAD_INIT(name.list), \
__MUTEX_INITIALIZER(name.mutex) }; \ __MUTEX_INITIALIZER(name.mutex) }; \
...@@ -6398,3 +6389,5 @@ bool bpf_check_mod_kfunc_call(struct kfunc_btf_id_list *klist, u32 kfunc_id, ...@@ -6398,3 +6389,5 @@ bool bpf_check_mod_kfunc_call(struct kfunc_btf_id_list *klist, u32 kfunc_id,
DEFINE_KFUNC_BTF_ID_LIST(bpf_tcp_ca_kfunc_list); DEFINE_KFUNC_BTF_ID_LIST(bpf_tcp_ca_kfunc_list);
DEFINE_KFUNC_BTF_ID_LIST(prog_test_kfunc_list); DEFINE_KFUNC_BTF_ID_LIST(prog_test_kfunc_list);
#endif
...@@ -8422,7 +8422,7 @@ static void find_good_pkt_pointers(struct bpf_verifier_state *vstate, ...@@ -8422,7 +8422,7 @@ static void find_good_pkt_pointers(struct bpf_verifier_state *vstate,
new_range = dst_reg->off; new_range = dst_reg->off;
if (range_right_open) if (range_right_open)
new_range--; new_range++;
/* Examples for register markings: /* Examples for register markings:
* *
......
...@@ -316,6 +316,7 @@ config DEBUG_INFO_BTF ...@@ -316,6 +316,7 @@ config DEBUG_INFO_BTF
bool "Generate BTF typeinfo" bool "Generate BTF typeinfo"
depends on !DEBUG_INFO_SPLIT && !DEBUG_INFO_REDUCED depends on !DEBUG_INFO_SPLIT && !DEBUG_INFO_REDUCED
depends on !GCC_PLUGIN_RANDSTRUCT || COMPILE_TEST depends on !GCC_PLUGIN_RANDSTRUCT || COMPILE_TEST
depends on BPF_SYSCALL
help help
Generate deduplicated BTF type information from DWARF debug info. Generate deduplicated BTF type information from DWARF debug info.
Turning this on expects presence of pahole tool, which will convert Turning this on expects presence of pahole tool, which will convert
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/mmu_notifier.h> #include <linux/mmu_notifier.h>
#include <linux/page_idle.h> #include <linux/page_idle.h>
#include <linux/pagewalk.h> #include <linux/pagewalk.h>
#include <linux/sched/mm.h>
#include "prmtv-common.h" #include "prmtv-common.h"
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <linux/memblock.h> #include <linux/memblock.h>
#include <linux/compaction.h> #include <linux/compaction.h>
#include <linux/rmap.h> #include <linux/rmap.h>
#include <linux/module.h>
#include <asm/tlbflush.h> #include <asm/tlbflush.h>
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <linux/swap_slots.h> #include <linux/swap_slots.h>
#include <linux/cpu.h> #include <linux/cpu.h>
#include <linux/cpumask.h> #include <linux/cpumask.h>
#include <linux/slab.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/mm.h> #include <linux/mm.h>
......
...@@ -1124,6 +1124,8 @@ void sk_psock_start_strp(struct sock *sk, struct sk_psock *psock) ...@@ -1124,6 +1124,8 @@ void sk_psock_start_strp(struct sock *sk, struct sk_psock *psock)
void sk_psock_stop_strp(struct sock *sk, struct sk_psock *psock) void sk_psock_stop_strp(struct sock *sk, struct sk_psock *psock)
{ {
psock_set_prog(&psock->progs.stream_parser, NULL);
if (!psock->saved_data_ready) if (!psock->saved_data_ready)
return; return;
...@@ -1212,6 +1214,9 @@ void sk_psock_start_verdict(struct sock *sk, struct sk_psock *psock) ...@@ -1212,6 +1214,9 @@ void sk_psock_start_verdict(struct sock *sk, struct sk_psock *psock)
void sk_psock_stop_verdict(struct sock *sk, struct sk_psock *psock) void sk_psock_stop_verdict(struct sock *sk, struct sk_psock *psock)
{ {
psock_set_prog(&psock->progs.stream_verdict, NULL);
psock_set_prog(&psock->progs.skb_verdict, NULL);
if (!psock->saved_data_ready) if (!psock->saved_data_ready)
return; return;
......
...@@ -167,8 +167,11 @@ static void sock_map_del_link(struct sock *sk, ...@@ -167,8 +167,11 @@ static void sock_map_del_link(struct sock *sk,
write_lock_bh(&sk->sk_callback_lock); write_lock_bh(&sk->sk_callback_lock);
if (strp_stop) if (strp_stop)
sk_psock_stop_strp(sk, psock); sk_psock_stop_strp(sk, psock);
else if (verdict_stop)
sk_psock_stop_verdict(sk, psock); sk_psock_stop_verdict(sk, psock);
if (psock->psock_update_sk_prot)
psock->psock_update_sk_prot(sk, psock, false);
write_unlock_bh(&sk->sk_callback_lock); write_unlock_bh(&sk->sk_callback_lock);
} }
} }
...@@ -282,6 +285,12 @@ static int sock_map_link(struct bpf_map *map, struct sock *sk) ...@@ -282,6 +285,12 @@ static int sock_map_link(struct bpf_map *map, struct sock *sk)
if (msg_parser) if (msg_parser)
psock_set_prog(&psock->progs.msg_parser, msg_parser); psock_set_prog(&psock->progs.msg_parser, msg_parser);
if (stream_parser)
psock_set_prog(&psock->progs.stream_parser, stream_parser);
if (stream_verdict)
psock_set_prog(&psock->progs.stream_verdict, stream_verdict);
if (skb_verdict)
psock_set_prog(&psock->progs.skb_verdict, skb_verdict);
ret = sock_map_init_proto(sk, psock); ret = sock_map_init_proto(sk, psock);
if (ret < 0) if (ret < 0)
...@@ -292,14 +301,10 @@ static int sock_map_link(struct bpf_map *map, struct sock *sk) ...@@ -292,14 +301,10 @@ static int sock_map_link(struct bpf_map *map, struct sock *sk)
ret = sk_psock_init_strp(sk, psock); ret = sk_psock_init_strp(sk, psock);
if (ret) if (ret)
goto out_unlock_drop; goto out_unlock_drop;
psock_set_prog(&psock->progs.stream_verdict, stream_verdict);
psock_set_prog(&psock->progs.stream_parser, stream_parser);
sk_psock_start_strp(sk, psock); sk_psock_start_strp(sk, psock);
} else if (!stream_parser && stream_verdict && !psock->saved_data_ready) { } else if (!stream_parser && stream_verdict && !psock->saved_data_ready) {
psock_set_prog(&psock->progs.stream_verdict, stream_verdict);
sk_psock_start_verdict(sk,psock); sk_psock_start_verdict(sk,psock);
} else if (!stream_verdict && skb_verdict && !psock->saved_data_ready) { } else if (!stream_verdict && skb_verdict && !psock->saved_data_ready) {
psock_set_prog(&psock->progs.skb_verdict, skb_verdict);
sk_psock_start_verdict(sk, psock); sk_psock_start_verdict(sk, psock);
} }
write_unlock_bh(&sk->sk_callback_lock); write_unlock_bh(&sk->sk_callback_lock);
......
...@@ -83,6 +83,7 @@ struct btf_id { ...@@ -83,6 +83,7 @@ struct btf_id {
int cnt; int cnt;
}; };
int addr_cnt; int addr_cnt;
bool is_set;
Elf64_Addr addr[ADDR_CNT]; Elf64_Addr addr[ADDR_CNT];
}; };
...@@ -451,8 +452,10 @@ static int symbols_collect(struct object *obj) ...@@ -451,8 +452,10 @@ static int symbols_collect(struct object *obj)
* in symbol's size, together with 'cnt' field hence * in symbol's size, together with 'cnt' field hence
* that - 1. * that - 1.
*/ */
if (id) if (id) {
id->cnt = sym.st_size / sizeof(int) - 1; id->cnt = sym.st_size / sizeof(int) - 1;
id->is_set = true;
}
} else { } else {
pr_err("FAILED unsupported prefix %s\n", prefix); pr_err("FAILED unsupported prefix %s\n", prefix);
return -1; return -1;
...@@ -568,9 +571,8 @@ static int id_patch(struct object *obj, struct btf_id *id) ...@@ -568,9 +571,8 @@ static int id_patch(struct object *obj, struct btf_id *id)
int *ptr = data->d_buf; int *ptr = data->d_buf;
int i; int i;
if (!id->id) { if (!id->id && !id->is_set)
pr_err("WARN: resolve_btfids: unresolved symbol %s\n", id->name); pr_err("WARN: resolve_btfids: unresolved symbol %s\n", id->name);
}
for (i = 0; i < id->addr_cnt; i++) { for (i = 0; i < id->addr_cnt; i++) {
unsigned long addr = id->addr[i]; unsigned long addr = id->addr[i];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment