@@ -4,6 +4,7 @@
#include <linux/err.h>
#include <netinet/tcp.h>
#include <test_progs.h>
+#include <bpf/libbpf_internal.h>
#include "network_helpers.h"
#include "bpf_dctcp.skel.h"
#include "bpf_cubic.skel.h"
@@ -39,6 +40,8 @@ static void *server(void *arg)
ssize_t nr_sent = 0, bytes = 0;
char batch[1500];
+ libbpf_mark_mem_written(batch, sizeof(batch));
+
fd = accept(lfd, NULL, NULL);
while (fd == -1) {
if (errno == EINTR)
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include <test_progs.h>
+#include <bpf/libbpf_internal.h>
#include <sys/time.h>
#include <sys/resource.h>
#include "test_send_signal_kern.skel.h"
@@ -58,6 +59,7 @@ static void test_send_signal_common(struct perf_event_attr *attr,
ASSERT_OK(setpriority(PRIO_PROCESS, 0, -20), "setpriority");
/* notify parent signal handler is installed */
+ libbpf_mark_mem_written(buf, 1);
ASSERT_EQ(write(pipe_c2p[1], buf, 1), 1, "pipe_write");
/* make sure parent enabled bpf program to send_signal */
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include <test_progs.h>
+#include <bpf/libbpf_internal.h>
void serial_test_tp_attach_query(void)
{
@@ -66,6 +67,7 @@ void serial_test_tp_attach_query(void)
if (i == 0) {
/* check NULL prog array query */
query->ids_len = num_progs;
+ libbpf_mark_var_written(query->prog_cnt);
err = ioctl(pmu_fd[i], PERF_EVENT_IOC_QUERY_BPF, query);
if (CHECK(err || query->prog_cnt != 0,
"perf_event_ioc_query_bpf",
@@ -115,6 +117,8 @@ void serial_test_tp_attach_query(void)
"err %d errno %d query->prog_cnt %u\n",
err, errno, query->prog_cnt))
goto cleanup3;
+ libbpf_mark_mem_written(query->ids,
+ query->ids_len * sizeof(__u32));
for (j = 0; j < i + 1; j++)
if (CHECK(saved_prog_ids[j] != query->ids[j],
"perf_event_ioc_query_bpf",
@@ -14,6 +14,7 @@
#include <net/if.h>
#include <linux/if_link.h>
#include "test_progs.h"
+#include "bpf/libbpf_internal.h"
#include "network_helpers.h"
#include <linux/if_bonding.h>
#include <linux/limits.h>
@@ -224,6 +225,8 @@ static int send_udp_packets(int vary_dst_ip)
int i, s = -1;
int ifindex;
+ libbpf_mark_mem_written(buf, sizeof(buf));
+
s = socket(AF_PACKET, SOCK_RAW, IPPROTO_RAW);
if (!ASSERT_GE(s, 0, "socket"))
goto err;
eBPF selftests produce a few false positives with MSan. 3 of them have to do with sending uninitalized data via a socket. Another one is PERF_EVENT_IOC_QUERY_BPF, which is not known to MSan. Silence all of them using libbpf_mark_mem_written(). Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> --- tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c | 3 +++ tools/testing/selftests/bpf/prog_tests/send_signal.c | 2 ++ tools/testing/selftests/bpf/prog_tests/tp_attach_query.c | 4 ++++ tools/testing/selftests/bpf/prog_tests/xdp_bonding.c | 3 +++ 4 files changed, 12 insertions(+)