Unverified Commit 9c5bb8c5 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!10550 backport serveral bugfixes from upstream

Merge Pull Request from: @ci-robot 
 
PR sync from: Tengda Wu <wutengda2@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/MJJR5QGWUBOP5VGP6GSEN4RJORAN6XZJ/ 
The following bugfixes are going to backport from upstream:

  bpf: ensure main program has an extable
  bpf: Take return from set_memory_ro() into account with bpf_prog_lock_ro()
  bpf, perf: Use subprog name when reporting subprog ksymbol
  bpf, events: Use prog to emit ksymbol event for main program

Christophe Leroy (1):
  bpf: Take return from set_memory_ro() into account with
    bpf_prog_lock_ro()

Hou Tao (2):
  bpf, perf: Use subprog name when reporting subprog ksymbol
  bpf, events: Use prog to emit ksymbol event for main program

Krister Johansen (1):
  bpf: ensure main program has an extable


-- 
2.34.1
 
https://gitee.com/src-openeuler/kernel/issues/IAGEOM
https://gitee.com/openeuler/kernel/issues/IAHA5K 
 
Link:https://gitee.com/openeuler/kernel/pulls/10550

 

Reviewed-by: default avatarYe Weihua <yeweihua4@huawei.com>
Reviewed-by: default avatarXu Kuohai <xukuohai@huawei.com>
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
parents 1f849b90 9ef40511
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -824,14 +824,15 @@ bpf_ctx_narrow_access_offset(u32 off, u32 size, u32 size_default)

#define bpf_classic_proglen(fprog) (fprog->len * sizeof(fprog->filter[0]))

static inline void bpf_prog_lock_ro(struct bpf_prog *fp)
static inline int __must_check bpf_prog_lock_ro(struct bpf_prog *fp)
{
#ifndef CONFIG_BPF_JIT_ALWAYS_ON
	if (!fp->jited) {
		set_vm_flush_reset_perms(fp);
		set_memory_ro((unsigned long)fp, fp->pages);
		return set_memory_ro((unsigned long)fp, fp->pages);
	}
#endif
	return 0;
}

static inline void bpf_jit_binary_lock_ro(struct bpf_binary_header *hdr)
+3 −1
Original line number Diff line number Diff line
@@ -1878,7 +1878,9 @@ struct bpf_prog *bpf_prog_select_runtime(struct bpf_prog *fp, int *err)
	}

finalize:
	bpf_prog_lock_ro(fp);
	*err = bpf_prog_lock_ro(fp);
	if (*err)
		return fp;

	/* The tail call compatibility check can only be done at
	 * this late stage as we need to determine, if we deal
+11 −4
Original line number Diff line number Diff line
@@ -11298,13 +11298,18 @@ static int jit_subprogs(struct bpf_verifier_env *env)
	}

	/* finally lock prog and jit images for all functions and
	 * populate kallsysm
	 * populate kallsysm. Begin at the first subprogram, since
	 * bpf_prog_load will add the kallsyms for the main program.
	 */
	for (i = 0; i < env->subprog_cnt; i++) {
		bpf_prog_lock_ro(func[i]);
		bpf_prog_kallsyms_add(func[i]);
	for (i = 1; i < env->subprog_cnt; i++) {
		err = bpf_prog_lock_ro(func[i]);
		if (err)
			goto out_free;
	}

	for (i = 1; i < env->subprog_cnt; i++)
		bpf_prog_kallsyms_add(func[i]);

	/* Last step: make now unused interpreter insns from main
	 * prog consistent for later dump requests, so they can
	 * later look the same as if they were interpreted only.
@@ -11320,6 +11325,8 @@ static int jit_subprogs(struct bpf_verifier_env *env)

	prog->jited = 1;
	prog->bpf_func = func[0]->bpf_func;
	prog->aux->extable = func[0]->aux->extable;
	prog->aux->num_exentries = func[0]->aux->num_exentries;
	prog->aux->func = func;
	prog->aux->func_cnt = env->subprog_cnt;
	bpf_prog_free_unused_jited_linfo(prog);
+13 −15
Original line number Diff line number Diff line
@@ -8733,21 +8733,19 @@ static void perf_event_bpf_emit_ksymbols(struct bpf_prog *prog,
	bool unregister = type == PERF_BPF_EVENT_PROG_UNLOAD;
	int i;

	if (prog->aux->func_cnt == 0) {
	perf_event_ksymbol(PERF_RECORD_KSYMBOL_TYPE_BPF,
			   (u64)(unsigned long)prog->bpf_func,
			   prog->jited_len, unregister,
			   prog->aux->ksym.name);
	} else {
		for (i = 0; i < prog->aux->func_cnt; i++) {

	for (i = 1; i < prog->aux->func_cnt; i++) {
		struct bpf_prog *subprog = prog->aux->func[i];

		perf_event_ksymbol(
			PERF_RECORD_KSYMBOL_TYPE_BPF,
			(u64)(unsigned long)subprog->bpf_func,
			subprog->jited_len, unregister,
				prog->aux->ksym.name);
		}
			subprog->aux->ksym.name);
	}
}