From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 383505A026F for ; Thu, 16 Nov 2023 10:16:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1700126214; bh=MtDpogFSY69eYSFpF/t7YIZEcU19OnuBoUSwwE//3ks=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jgNLu52gUK6TgiG3nRDxKMlMbUP31bN9uDgJLqJ63sCZZC3m/g7lEfXnuxpF6YPUO 2JbYk9ZGohxS5QNJEWXVjT7aysW8Q62I6DgKO0o/oS4FptCHdWJl1b2yFEjj8KPVNx k83+E8n/in1UXhr/Bq7y147YCgq/YwjUYGTFoRkU= Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4SWDtt0Hx9z4wcK; Thu, 16 Nov 2023 20:16:54 +1100 (AEDT) Date: Thu, 16 Nov 2023 20:16:44 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH v2 1/2] valgrind: Adjust suppression for MSG_TRUNC with NULL buffer Message-ID: References: <20231116054350.3255485-1-david@gibson.dropbear.id.au> <20231116054350.3255485-2-david@gibson.dropbear.id.au> <20231116082134.378f74c1@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="mtx+yU9p2kgZEfAQ" Content-Disposition: inline In-Reply-To: <20231116082134.378f74c1@elisabeth> Message-ID-Hash: BB75DSUXKOHHEUIAX72F7VD6HEYNTL7O X-Message-ID-Hash: BB75DSUXKOHHEUIAX72F7VD6HEYNTL7O X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --mtx+yU9p2kgZEfAQ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Nov 16, 2023 at 08:21:34AM +0100, Stefano Brivio wrote: > On Thu, 16 Nov 2023 16:43:49 +1100 > David Gibson wrote: >=20 > > 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. > >=20 > > 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. > >=20 > > 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 valgr= ind > > builds. This breaks the suppression leading to a spurious failure in t= he > > tests. > >=20 > > There's not really any way to adjust the suppression itself without mak= ing > > 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 valgri= nd > > build. To accomplish this add an explicit -DVALGRIND when making such a > > build. > >=20 > > Signed-off-by: David Gibson > > --- > > Makefile | 2 +- > > tcp.c | 9 +++++++++ > > test/valgrind.supp | 3 +-- > > 3 files changed, 11 insertions(+), 3 deletions(-) > >=20 > > diff --git a/Makefile b/Makefile > > index ff21459..57b2544 100644 > > --- a/Makefile > > +++ b/Makefile > > @@ -128,7 +128,7 @@ qrap: $(QRAP_SRCS) passt.h > > valgrind: EXTRA_SYSCALLS +=3D rt_sigprocmask rt_sigtimedwait rt_sigact= ion \ > > getpid gettid kill clock_gettime mmap \ > > munmap open unlink gettimeofday futex > > -valgrind: FLAGS:=3D-g -O0 $(filter-out -O%,$(FLAGS)) > > +valgrind: FLAGS:=3D-g -O0 $(filter-out -O%,$(FLAGS)) -DVALGRIND > > valgrind: all > > =20 > > .PHONY: clean > > diff --git a/tcp.c b/tcp.c > > index cfcd40a..b86d433 100644 > > --- a/tcp.c > > +++ b/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 > > */ > > +#ifdef VALGRIND > > +/* valgrind doesn't realise that passing a NULL buffer to recv() is ok= if using > > + * MSG_TRUNC. We have a supression for this in the tests, but it reli= es on > ^ pp >=20 > (I can fix it up on merge but I guess you prefer to repost). Rest of the > series looks good to me. Oops, yes. Resent. --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --mtx+yU9p2kgZEfAQ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmVV3fIACgkQzQJF27ox 2GdM5w/9GnW25+X3kD2BYpDK8BahWfHnCuE9YH5JkvAz66bwv191iQfZ2v6BpNDP q3UG082tQPhIX/UPoxWhJWPTG/946Rw5tF500x1JRRXStTwHv4/tkIxlyO6n5z4l FdABIckD+pGv/W1VaM3JbEddjU6jJCiNKxvEKGnEA/nmh3/BZGbKmtkDDgoVCakk 1+L3SvNUkkNruR6bSEKgOqQB0GlYjs5zWvGodq5xQwsTNccUiT3RdQdquOKUmcom klc8jOuR/h+lxCZZVsppzVd84tqAX0U5L5qNxlDbjP7S7FhJTVZyy52mVJ1zA+FW UBB+rwQLHODkPnP9HijieQYlwKFujf2VOaJcs+nVj19cxzfHsUMNXHoiu5A55bM9 yfCNhnsBwRC8C814td+2NqdVs00bjhA+YuFIQNDlUQ/un5FeYjsUyH/LU4OGwJh2 FozZA/8FNUqexz+UBY9Is1bF49dOtfB4WR51Jg4IIEmAADx8xB/BgtRoM7C7SJ3G WBnz57zNPGBguLO1Tx55A5tzznLNPrmgSBkA86I9U6Qjmj+CnLpxty8SUM9ZMVy4 6+Unhfl0ce4BmrOe1R39Vxny/ZfTK7J9cOAwm8FpdkEe+sVKVf29mRaPyQI0JNnF ubGUs39bzkMyhaIY1dAmLYdtvhtqlETdSmt1mTS6dNBSpiSZ3tg= =jRJc -----END PGP SIGNATURE----- --mtx+yU9p2kgZEfAQ--