diff mbox series

[bpf] bpf: fix a task_iter bug caused by a merge conflict resolution

Message ID 20201231052418.577024-1-yhs@fb.com (mailing list archive)
State Accepted
Commit 04901aab40ea3779f6fc6383ef74d8e130e817bf
Delegated to: BPF
Headers show
Series [bpf] bpf: fix a task_iter bug caused by a merge conflict resolution | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for bpf
netdev/subject_prefix success Link
netdev/cc_maintainers warning 7 maintainers not CCed: kpsingh@kernel.org andrii@kernel.org davem@davemloft.net netdev@vger.kernel.org songliubraving@fb.com kafai@fb.com john.fastabend@gmail.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 1 this patch: 1
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 7 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 1 this patch: 1
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Yonghong Song Dec. 31, 2020, 5:24 a.m. UTC
Latest bpf tree has a bug for bpf_iter selftest.
  $ ./test_progs -n 4/25
  test_bpf_sk_storage_get:PASS:bpf_iter_bpf_sk_storage_helpers__open_and_load 0 nsec
  test_bpf_sk_storage_get:PASS:socket 0 nsec
  ...
  do_dummy_read:PASS:read 0 nsec
  test_bpf_sk_storage_get:FAIL:bpf_map_lookup_elem map value wasn't set correctly
                          (expected 1792, got -1, err=0)
  #4/25 bpf_sk_storage_get:FAIL
  #4 bpf_iter:FAIL
  Summary: 0/0 PASSED, 0 SKIPPED, 2 FAILED

When doing merge conflict resolution, Commit 4bfc4714849d missed to
save curr_task to seq_file private data. The task pointer in seq_file
private data is passed to bpf program. This caused
NULL-pointer task passed to bpf program which will immediately return
upon checking whether task pointer is NULL.

This patch added back the assignment of curr_task to seq_file private data
and fixed the issue.

Fixes: 4bfc4714849d ("Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf")
Signed-off-by: Yonghong Song <yhs@fb.com>
---
 kernel/bpf/task_iter.c | 1 +
 1 file changed, 1 insertion(+)

Comments

John Fastabend Dec. 31, 2020, 3:44 p.m. UTC | #1
Yonghong Song wrote:
> Latest bpf tree has a bug for bpf_iter selftest.
>   $ ./test_progs -n 4/25
>   test_bpf_sk_storage_get:PASS:bpf_iter_bpf_sk_storage_helpers__open_and_load 0 nsec
>   test_bpf_sk_storage_get:PASS:socket 0 nsec
>   ...
>   do_dummy_read:PASS:read 0 nsec
>   test_bpf_sk_storage_get:FAIL:bpf_map_lookup_elem map value wasn't set correctly
>                           (expected 1792, got -1, err=0)
>   #4/25 bpf_sk_storage_get:FAIL
>   #4 bpf_iter:FAIL
>   Summary: 0/0 PASSED, 0 SKIPPED, 2 FAILED
> 
> When doing merge conflict resolution, Commit 4bfc4714849d missed to
> save curr_task to seq_file private data. The task pointer in seq_file
> private data is passed to bpf program. This caused
> NULL-pointer task passed to bpf program which will immediately return
> upon checking whether task pointer is NULL.
> 
> This patch added back the assignment of curr_task to seq_file private data
> and fixed the issue.
> 
> Fixes: 4bfc4714849d ("Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf")
> Signed-off-by: Yonghong Song <yhs@fb.com>
> ---
>  kernel/bpf/task_iter.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/kernel/bpf/task_iter.c b/kernel/bpf/task_iter.c
> index 3efe38191d1c..175b7b42bfc4 100644
> --- a/kernel/bpf/task_iter.c
> +++ b/kernel/bpf/task_iter.c
> @@ -159,6 +159,7 @@ task_file_seq_get_next(struct bpf_iter_seq_task_file_info *info)
>                  }
>  
>                  /* set info->task and info->tid */
> +		info->task = curr_task;
>  		if (curr_tid == info->tid) {
>  			curr_fd = info->fd;
>  		} else {
> -- 
> 2.24.1
> 

Acked-by: John Fastabend <john.fastabend@gmail.com>
patchwork-bot+netdevbpf@kernel.org Jan. 3, 2021, 12:50 a.m. UTC | #2
Hello:

This patch was applied to bpf/bpf.git (refs/heads/master):

On Wed, 30 Dec 2020 21:24:18 -0800 you wrote:
> Latest bpf tree has a bug for bpf_iter selftest.
>   $ ./test_progs -n 4/25
>   test_bpf_sk_storage_get:PASS:bpf_iter_bpf_sk_storage_helpers__open_and_load 0 nsec
>   test_bpf_sk_storage_get:PASS:socket 0 nsec
>   ...
>   do_dummy_read:PASS:read 0 nsec
>   test_bpf_sk_storage_get:FAIL:bpf_map_lookup_elem map value wasn't set correctly
>                           (expected 1792, got -1, err=0)
>   #4/25 bpf_sk_storage_get:FAIL
>   #4 bpf_iter:FAIL
>   Summary: 0/0 PASSED, 0 SKIPPED, 2 FAILED
> 
> [...]

Here is the summary with links:
  - [bpf] bpf: fix a task_iter bug caused by a merge conflict resolution
    https://git.kernel.org/bpf/bpf/c/04901aab40ea

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
diff mbox series

Patch

diff --git a/kernel/bpf/task_iter.c b/kernel/bpf/task_iter.c
index 3efe38191d1c..175b7b42bfc4 100644
--- a/kernel/bpf/task_iter.c
+++ b/kernel/bpf/task_iter.c
@@ -159,6 +159,7 @@  task_file_seq_get_next(struct bpf_iter_seq_task_file_info *info)
                 }
 
                 /* set info->task and info->tid */
+		info->task = curr_task;
 		if (curr_tid == info->tid) {
 			curr_fd = info->fd;
 		} else {