Commit 0ad379ff authored by Daniel Borkmann's avatar Daniel Borkmann

Merge branch 'bpf-fix-kptr-checks'

Martin KaFai Lau says:

====================
This patch set removes the bpf_dump_raw_ok() guard for the func_info
and line_info during bpf_prog_get_info_by_fd().
====================
Acked-by: default avatarYonghong Song <yhs@fb.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
parents 00842be5 177e7716
......@@ -2272,7 +2272,6 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
ulen = info.nr_func_info;
info.nr_func_info = prog->aux->func_info_cnt;
if (info.nr_func_info && ulen) {
if (bpf_dump_raw_ok()) {
char __user *user_finfo;
user_finfo = u64_to_user_ptr(info.func_info);
......@@ -2280,15 +2279,11 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
if (copy_to_user(user_finfo, prog->aux->func_info,
info.func_info_rec_size * ulen))
return -EFAULT;
} else {
info.func_info = 0;
}
}
ulen = info.nr_line_info;
info.nr_line_info = prog->aux->nr_linfo;
if (info.nr_line_info && ulen) {
if (bpf_dump_raw_ok()) {
__u8 __user *user_linfo;
user_linfo = u64_to_user_ptr(info.line_info);
......@@ -2296,9 +2291,6 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
if (copy_to_user(user_linfo, prog->aux->linfo,
info.line_info_rec_size * ulen))
return -EFAULT;
} else {
info.line_info = 0;
}
}
ulen = info.nr_jited_line_info;
......
......@@ -596,13 +596,6 @@ static int do_dump(int argc, char **argv)
goto err_free;
}
if (func_info && !info.func_info) {
/* kernel.kptr_restrict is set. No func_info available. */
free(func_info);
func_info = NULL;
nr_finfo = 0;
}
if (linfo && info.nr_line_info != nr_linfo) {
p_err("incorrect nr_line_info %u vs. expected %u",
info.nr_line_info, nr_linfo);
......
......@@ -107,11 +107,7 @@ struct bpf_prog_linfo *bpf_prog_linfo__new(const struct bpf_prog_info *info)
nr_linfo = info->nr_line_info;
/*
* Test !info->line_info because the kernel may NULL
* the ptr if kernel.kptr_restrict is set.
*/
if (!nr_linfo || !info->line_info)
if (!nr_linfo)
return NULL;
/*
......
......@@ -3948,12 +3948,6 @@ static int test_get_finfo(const struct prog_info_raw_test *test,
goto done;
}
if (CHECK(!info.func_info,
"info.func_info == 0. kernel.kptr_restrict is set?")) {
err = -1;
goto done;
}
finfo = func_info;
for (i = 0; i < test->func_info_cnt; i++) {
if (CHECK(finfo->type_id != test->func_info[i][1],
......@@ -4077,7 +4071,6 @@ static int test_get_linfo(const struct prog_info_raw_test *test,
* Other fields are not the concern of this test.
*/
if (CHECK(err == -1 ||
!info.line_info ||
info.nr_line_info != cnt ||
(jited_cnt && !info.jited_line_info) ||
info.nr_jited_line_info != jited_cnt ||
......
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