-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge tag 'for-netdev' of https://git.kernel.org/pub/scm/linux/kernel…
…/git/bpf/bpf Daniel Borkmann says: ==================== pull-request: bpf 2024-02-22 The following pull-request contains BPF updates for your *net* tree. We've added 11 non-merge commits during the last 24 day(s) which contain a total of 15 files changed, 217 insertions(+), 17 deletions(-). The main changes are: 1) Fix a syzkaller-triggered oops when attempting to read the vsyscall page through bpf_probe_read_kernel and friends, from Hou Tao. 2) Fix a kernel panic due to uninitialized iter position pointer in bpf_iter_task, from Yafang Shao. 3) Fix a race between bpf_timer_cancel_and_free and bpf_timer_cancel, from Martin KaFai Lau. 4) Fix a xsk warning in skb_add_rx_frag() (under CONFIG_DEBUG_NET) due to incorrect truesize accounting, from Sebastian Andrzej Siewior. 5) Fix a NULL pointer dereference in sk_psock_verdict_data_ready, from Shigeru Yoshida. 6) Fix a resolve_btfids warning when bpf_cpumask symbol cannot be resolved, from Hari Bathini. bpf-for-netdev * tag 'for-netdev' of https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf: bpf, sockmap: Fix NULL pointer dereference in sk_psock_verdict_data_ready() selftests/bpf: Add negtive test cases for task iter bpf: Fix an issue due to uninitialized bpf_iter_task selftests/bpf: Test racing between bpf_timer_cancel_and_free and bpf_timer_cancel bpf: Fix racing between bpf_timer_cancel_and_free and bpf_timer_cancel selftest/bpf: Test the read of vsyscall page under x86-64 x86/mm: Disallow vsyscall page read for copy_from_kernel_nofault() x86/mm: Move is_vsyscall_vaddr() into asm/vsyscall.h bpf, scripts: Correct GPL license name xsk: Add truesize to skb_add_rx_frag(). bpf: Fix warning for bpf_cpumask in verifier ==================== Link: https://lore.kernel.org/r/20240221231826.1404-1-daniel@iogearbox.net Signed-off-by: Paolo Abeni <pabeni@redhat.com>
- Loading branch information
Showing
15 changed files
with
217 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* Copyright (C) 2024. Huawei Technologies Co., Ltd */ | ||
#include "test_progs.h" | ||
#include "read_vsyscall.skel.h" | ||
|
||
#if defined(__x86_64__) | ||
/* For VSYSCALL_ADDR */ | ||
#include <asm/vsyscall.h> | ||
#else | ||
/* To prevent build failure on non-x86 arch */ | ||
#define VSYSCALL_ADDR 0UL | ||
#endif | ||
|
||
struct read_ret_desc { | ||
const char *name; | ||
int ret; | ||
} all_read[] = { | ||
{ .name = "probe_read_kernel", .ret = -ERANGE }, | ||
{ .name = "probe_read_kernel_str", .ret = -ERANGE }, | ||
{ .name = "probe_read", .ret = -ERANGE }, | ||
{ .name = "probe_read_str", .ret = -ERANGE }, | ||
{ .name = "probe_read_user", .ret = -EFAULT }, | ||
{ .name = "probe_read_user_str", .ret = -EFAULT }, | ||
{ .name = "copy_from_user", .ret = -EFAULT }, | ||
{ .name = "copy_from_user_task", .ret = -EFAULT }, | ||
}; | ||
|
||
void test_read_vsyscall(void) | ||
{ | ||
struct read_vsyscall *skel; | ||
unsigned int i; | ||
int err; | ||
|
||
#if !defined(__x86_64__) | ||
test__skip(); | ||
return; | ||
#endif | ||
skel = read_vsyscall__open_and_load(); | ||
if (!ASSERT_OK_PTR(skel, "read_vsyscall open_load")) | ||
return; | ||
|
||
skel->bss->target_pid = getpid(); | ||
err = read_vsyscall__attach(skel); | ||
if (!ASSERT_EQ(err, 0, "read_vsyscall attach")) | ||
goto out; | ||
|
||
/* userspace may don't have vsyscall page due to LEGACY_VSYSCALL_NONE, | ||
* but it doesn't affect the returned error codes. | ||
*/ | ||
skel->bss->user_ptr = (void *)VSYSCALL_ADDR; | ||
usleep(1); | ||
|
||
for (i = 0; i < ARRAY_SIZE(all_read); i++) | ||
ASSERT_EQ(skel->bss->read_ret[i], all_read[i].ret, all_read[i].name); | ||
out: | ||
read_vsyscall__destroy(skel); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* Copyright (C) 2024. Huawei Technologies Co., Ltd */ | ||
#include <linux/types.h> | ||
#include <bpf/bpf_helpers.h> | ||
|
||
#include "bpf_misc.h" | ||
|
||
int target_pid = 0; | ||
void *user_ptr = 0; | ||
int read_ret[8]; | ||
|
||
char _license[] SEC("license") = "GPL"; | ||
|
||
SEC("fentry/" SYS_PREFIX "sys_nanosleep") | ||
int do_probe_read(void *ctx) | ||
{ | ||
char buf[8]; | ||
|
||
if ((bpf_get_current_pid_tgid() >> 32) != target_pid) | ||
return 0; | ||
|
||
read_ret[0] = bpf_probe_read_kernel(buf, sizeof(buf), user_ptr); | ||
read_ret[1] = bpf_probe_read_kernel_str(buf, sizeof(buf), user_ptr); | ||
read_ret[2] = bpf_probe_read(buf, sizeof(buf), user_ptr); | ||
read_ret[3] = bpf_probe_read_str(buf, sizeof(buf), user_ptr); | ||
read_ret[4] = bpf_probe_read_user(buf, sizeof(buf), user_ptr); | ||
read_ret[5] = bpf_probe_read_user_str(buf, sizeof(buf), user_ptr); | ||
|
||
return 0; | ||
} | ||
|
||
SEC("fentry.s/" SYS_PREFIX "sys_nanosleep") | ||
int do_copy_from_user(void *ctx) | ||
{ | ||
char buf[8]; | ||
|
||
if ((bpf_get_current_pid_tgid() >> 32) != target_pid) | ||
return 0; | ||
|
||
read_ret[6] = bpf_copy_from_user(buf, sizeof(buf), user_ptr); | ||
read_ret[7] = bpf_copy_from_user_task(buf, sizeof(buf), user_ptr, | ||
bpf_get_current_task_btf(), 0); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters