diff options
author | Jesper Dangaard Brouer <brouer@redhat.com> | 2023-02-01 18:32:05 +0100 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2023-02-02 00:49:04 +0100 |
commit | e8a3c8bd687068bafb640ca524905f0bec716a13 (patch) | |
tree | 4faa481a16c8018b24e3a1c33619457b0147761b /tools/testing/selftests/bpf/prog_tests/xdp_metadata.c | |
parent | 7bd4224deecd2d917fcbb52f9d13ab1453be219a (diff) |
selftests/bpf: xdp_hw_metadata use strncpy for ifname
The ifname char pointer is taken directly from the command line
as input and the string is copied directly into struct ifreq
via strcpy. This makes it easy to corrupt other members of ifreq
and generally do stack overflows.
Most often the ioctl will fail with:
./xdp_hw_metadata: ioctl(SIOCETHTOOL): Bad address
As people will likely copy-paste code for getting NIC queue
channels (rxq_num) and enabling HW timestamping (hwtstamp_ioctl)
lets make this code a bit more secure by using strncpy.
Fixes: 297a3f124155 ("selftests/bpf: Simple program to dump XDP RX metadata")
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Stanislav Fomichev <sdf@google.com>
Link: https://lore.kernel.org/bpf/167527272543.937063.16993147790832546209.stgit@firesoul
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/xdp_metadata.c')
0 files changed, 0 insertions, 0 deletions