Skip to content

Conversation

@kernel-patches-daemon-bpf-rc
Copy link

Pull request for series with
subject: Fix bpf_strnstr len error
version: 4
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=996726

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 98857d1
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=996726
version: 4

Rtoax added 2 commits August 28, 2025 19:25
strnstr should not treat the ending '\0' of s2 as a matching character
if the parameter 'len' equal to s2 string length, for example:

    1. bpf_strnstr("openat", "open", 4) = -ENOENT
    2. bpf_strnstr("openat", "open", 5) = 0

This patch makes (1) return 0, indicating a successful match.

Fixes: e913705 ("bpf: Add kfuncs for read-only string operations")
Signed-off-by: Rong Tao <[email protected]>
Add tests for bpf_strnstr():

    bpf_strnstr("", "", 0) = 0
    bpf_strnstr("hello world", "hello", 5) = 0
    bpf_strnstr(str, "hello", 4) = -ENOENT
    bpf_strnstr("", "a", 0) = -ENOENT

Signed-off-by: Rong Tao <[email protected]>
@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 98857d1
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=996726
version: 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants