valgrind: Adjust suppression for MSG_TRUNC with NULL buffer
valgrind complains if we pass a NULL buffer to recv(), even if we use MSG_TRUNC, in which case it's actually safe. For a long time we've had a valgrind suppression for this. It singles out the recv() in tcp_sock_consume(), the only place we use MSG_TRUNC. However, tcp_sock_consume() only has a single caller, which makes it a prime candidate for inlining. If inlined, it won't appear on the stack and valgrind won't match the correct suppression. It appears that certain compiler versions (for example gcc-13.2.1 in Fedora 39) will inline this function even with the -O0 we use for valgrind builds. This breaks the suppression leading to a spurious failure in the tests. There's not really any way to adjust the suppression itself without making it overly broad (we don't want to match other recv() calls). So, as a hack explicitly prevent inlining of this function when we're making a valgrind build. To accomplish this add an explicit -DVALGRIND when making such a build. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
457ff122e3
commit
f7724647b1
3 changed files with 11 additions and 3 deletions
2
Makefile
2
Makefile
|
@ -128,7 +128,7 @@ qrap: $(QRAP_SRCS) passt.h
|
||||||
valgrind: EXTRA_SYSCALLS += rt_sigprocmask rt_sigtimedwait rt_sigaction \
|
valgrind: EXTRA_SYSCALLS += rt_sigprocmask rt_sigtimedwait rt_sigaction \
|
||||||
getpid gettid kill clock_gettime mmap \
|
getpid gettid kill clock_gettime mmap \
|
||||||
munmap open unlink gettimeofday futex
|
munmap open unlink gettimeofday futex
|
||||||
valgrind: FLAGS:=-g -O0 $(filter-out -O%,$(FLAGS))
|
valgrind: FLAGS:=-g -O0 $(filter-out -O%,$(FLAGS)) -DVALGRIND
|
||||||
valgrind: all
|
valgrind: all
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
|
|
9
tcp.c
9
tcp.c
|
@ -2097,6 +2097,15 @@ static void tcp_conn_from_tap(struct ctx *c,
|
||||||
*
|
*
|
||||||
* Return: 0 on success, negative error code from recv() on failure
|
* Return: 0 on success, negative error code from recv() on failure
|
||||||
*/
|
*/
|
||||||
|
#ifdef VALGRIND
|
||||||
|
/* valgrind doesn't realise that passing a NULL buffer to recv() is ok if using
|
||||||
|
* MSG_TRUNC. We have a suppression for this in the tests, but it relies on
|
||||||
|
* valgrind being able to see the tcp_sock_consume() stack frame, which it won't
|
||||||
|
* if this gets inlined. This has a single caller making it a likely inlining
|
||||||
|
* candidate, and certain compiler versions will do so even at -O0.
|
||||||
|
*/
|
||||||
|
__attribute__((noinline))
|
||||||
|
#endif /* VALGRIND */
|
||||||
static int tcp_sock_consume(const struct tcp_tap_conn *conn, uint32_t ack_seq)
|
static int tcp_sock_consume(const struct tcp_tap_conn *conn, uint32_t ack_seq)
|
||||||
{
|
{
|
||||||
/* Simply ignore out-of-order ACKs: we already consumed the data we
|
/* Simply ignore out-of-order ACKs: we already consumed the data we
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
passt_recv_MSG_TRUNC_into_NULL_buffer
|
passt_recv_MSG_TRUNC_into_NULL_buffer
|
||||||
Memcheck:Param
|
Memcheck:Param
|
||||||
socketcall.recvfrom(buf)
|
socketcall.recvfrom(buf)
|
||||||
fun:recv
|
|
||||||
...
|
...
|
||||||
fun:tcp_sock_consume*
|
fun:tcp_sock_consume
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue