summaryrefslogtreecommitdiffstats
path: root/tools/bpf
diff options
context:
space:
mode:
authorToke Høiland-Jørgensen <toke@redhat.com>2022-02-12 00:48:19 +0100
committerAndrii Nakryiko <andrii@kernel.org>2022-02-12 07:57:44 -0800
commit9c3de619e13ee6693ec5ac74f50b7aa89056a70e (patch)
treec0830fc53155a8c1ae9730332305fd31ea94c39c /tools/bpf
parentd130e954a002b901391037c33b9ae11bae5aaa91 (diff)
downloadlinux-stable-9c3de619e13ee6693ec5ac74f50b7aa89056a70e.tar.gz
linux-stable-9c3de619e13ee6693ec5ac74f50b7aa89056a70e.tar.bz2
linux-stable-9c3de619e13ee6693ec5ac74f50b7aa89056a70e.zip
libbpf: Use dynamically allocated buffer when receiving netlink messages
When receiving netlink messages, libbpf was using a statically allocated stack buffer of 4k bytes. This happened to work fine on systems with a 4k page size, but on systems with larger page sizes it can lead to truncated messages. The user-visible impact of this was that libbpf would insist no XDP program was attached to some interfaces because that bit of the netlink message got chopped off. Fix this by switching to a dynamically allocated buffer; we borrow the approach from iproute2 of using recvmsg() with MSG_PEEK|MSG_TRUNC to get the actual size of the pending message before receiving it, adjusting the buffer as necessary. While we're at it, also add retries on interrupted system calls around the recvmsg() call. v2: - Move peek logic to libbpf_netlink_recv(), don't double free on ENOMEM. Fixes: 8bbb77b7c7a2 ("libbpf: Add various netlink helpers") Reported-by: Zhiqian Guan <zhguan@redhat.com> Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Link: https://lore.kernel.org/bpf/20220211234819.612288-1-toke@redhat.com
Diffstat (limited to 'tools/bpf')
0 files changed, 0 insertions, 0 deletions