Commit de1b5ea7 authored by Geliang Tang's avatar Geliang Tang Committed by Daniel Borkmann

selftests/bpf: Check length of recv in test_sockmap

The value of recv in msg_loop may be negative, like EWOULDBLOCK, so it's
necessary to check if it is positive before accumulating it to bytes_recvd.

Fixes: 16962b24 ("bpf: sockmap, add selftests")
Signed-off-by: default avatarGeliang Tang <tanggeliang@kylinos.cn>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Tested-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/5172563f7c7b2a2e953cef02e89fc34664a7b190.1716446893.git.tanggeliang@kylinos.cn
parent dcb681b6
...@@ -681,7 +681,8 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt, ...@@ -681,7 +681,8 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt,
} }
} }
s->bytes_recvd += recv; if (recv > 0)
s->bytes_recvd += recv;
if (opt->check_recved_len && s->bytes_recvd > total_bytes) { if (opt->check_recved_len && s->bytes_recvd > total_bytes) {
errno = EMSGSIZE; errno = EMSGSIZE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment