samples/bpf: Fix Segmentation fault for xdp_redirect command
Subsystems (4)
PATCH 1/1 samples/bpf: Fix Segmentation fault for xdp_redirect command
A Segmentation fault error is caused when the following command is executed.
$ sudo ./samples/bpf/xdp_redirect lo Segmentation fault
This command is missing a device <IFNAME|IFINDEX> as an argument, resulting in out-of-bounds access from argv.
If the number of devices for the xdp_redirect parameter is not 2, we should report an error and exit.
--- samples/bpf/xdp_redirect_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
samples/bpf/xdp_redirect_user.c +1 -1
@@ -130,7 +130,7 @@ int main(int argc, char **argv)if (!(xdp_flags &XDP_FLAGS_SKB_MODE )) xdp_flags |=XDP_FLAGS_DRV_MODE ; -if (optind == argc) { +if (optind +2 != argc) {printf ("usage: %s <IFNAME|IFINDEX>_IN <IFNAME|IFINDEX>_OUT\n" , argv[0 ]);return 1 ; }
Signature · 1 line
2.17.1
This patch was applied to bpf/bpf-next.git (refs/heads/master):
Hello:
This patch was applied to bpf/bpf-next.git (refs/heads/master):
Quoted 10 lines · On Wed, 16 Jun 2021 12:23:24 +0800 you wrote:
A Segmentation fault error is caused when the following command is executed.
$ sudo ./samples/bpf/xdp_redirect lo Segmentation faultThis command is missing a device <IFNAME|IFINDEX> as an argument, resulting in out-of-bounds access from argv.
[...]
Here is the summary with links:
- [bpf] samples/bpf: Fix Segmentation fault for xdp_redirect command
https://git.kernel.org/bpf/bpf-next/c/85102ba58b41
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html