diff options
Diffstat (limited to 'kernel/bpf/core.c')
| -rw-r--r-- | kernel/bpf/core.c | 33 | 
1 files changed, 25 insertions, 8 deletions
| diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index d6b7dfdd8066..327e3996eadb 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c @@ -32,6 +32,7 @@  #include <linux/perf_event.h>  #include <linux/extable.h>  #include <linux/log2.h> +#include <linux/bpf_verifier.h>  #include <asm/barrier.h>  #include <asm/unaligned.h> @@ -524,6 +525,7 @@ int bpf_jit_enable   __read_mostly = IS_BUILTIN(CONFIG_BPF_JIT_DEFAULT_ON);  int bpf_jit_kallsyms __read_mostly = IS_BUILTIN(CONFIG_BPF_JIT_DEFAULT_ON);  int bpf_jit_harden   __read_mostly;  long bpf_jit_limit   __read_mostly; +long bpf_jit_limit_max __read_mostly;  static void  bpf_prog_ksym_set_addr(struct bpf_prog *prog) @@ -817,7 +819,8 @@ u64 __weak bpf_jit_alloc_exec_limit(void)  static int __init bpf_jit_charge_init(void)  {  	/* Only used as heuristic here to derive limit. */ -	bpf_jit_limit = min_t(u64, round_up(bpf_jit_alloc_exec_limit() >> 2, +	bpf_jit_limit_max = bpf_jit_alloc_exec_limit(); +	bpf_jit_limit = min_t(u64, round_up(bpf_jit_limit_max >> 2,  					    PAGE_SIZE), LONG_MAX);  	return 0;  } @@ -1821,20 +1824,26 @@ static unsigned int __bpf_prog_ret0_warn(const void *ctx,  bool bpf_prog_array_compatible(struct bpf_array *array,  			       const struct bpf_prog *fp)  { +	bool ret; +  	if (fp->kprobe_override)  		return false; -	if (!array->aux->type) { +	spin_lock(&array->aux->owner.lock); + +	if (!array->aux->owner.type) {  		/* There's no owner yet where we could check for  		 * compatibility.  		 */ -		array->aux->type  = fp->type; -		array->aux->jited = fp->jited; -		return true; +		array->aux->owner.type  = fp->type; +		array->aux->owner.jited = fp->jited; +		ret = true; +	} else { +		ret = array->aux->owner.type  == fp->type && +		      array->aux->owner.jited == fp->jited;  	} - -	return array->aux->type  == fp->type && -	       array->aux->jited == fp->jited; +	spin_unlock(&array->aux->owner.lock); +	return ret;  }  static int bpf_check_tail_call(const struct bpf_prog *fp) @@ -2255,6 +2264,9 @@ static void bpf_prog_free_deferred(struct work_struct *work)  	int i;  	aux = container_of(work, struct bpf_prog_aux, work); +#ifdef CONFIG_BPF_SYSCALL +	bpf_free_kfunc_btf_tab(aux->kfunc_btf_tab); +#endif  	bpf_free_used_maps(aux);  	bpf_free_used_btfs(aux);  	if (bpf_prog_is_dev_bound(aux)) @@ -2357,6 +2369,11 @@ const struct bpf_func_proto * __weak bpf_get_trace_printk_proto(void)  	return NULL;  } +const struct bpf_func_proto * __weak bpf_get_trace_vprintk_proto(void) +{ +	return NULL; +} +  u64 __weak  bpf_event_output(struct bpf_map *map, u64 flags, void *meta, u64 meta_size,  		 void *ctx, u64 ctx_size, bpf_ctx_copy_t ctx_copy) |