From nobody Mon Apr 29 03:48:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 151269484627429.316321731331527; Thu, 7 Dec 2017 17:00:46 -0800 (PST) Received: from localhost ([::1]:35058 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN71r-0000QC-Nu for importer@patchew.org; Thu, 07 Dec 2017 20:00:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46536) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN6zs-0006fm-5c for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:58:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eN6zq-0007RI-Ig for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:58:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38102) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eN6zq-0007QS-Ch for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:58:34 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7C361C057FA8 for ; Fri, 8 Dec 2017 00:58:33 +0000 (UTC) Received: from localhost (ovpn-112-20.ams2.redhat.com [10.36.112.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id A87221F8; Fri, 8 Dec 2017 00:58:30 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Fri, 8 Dec 2017 01:58:14 +0100 Message-Id: <20171208005825.14587-2-marcandre.lureau@redhat.com> In-Reply-To: <20171208005825.14587-1-marcandre.lureau@redhat.com> References: <20171208005825.14587-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 08 Dec 2017 00:58:33 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 01/12] build-sys: fix qemu-ga -pthread linking X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When linking qemu-ga under some configuration (when gthread-2.0.pc doesn't have -pthread, as happening atm with meson build), you may have this linking issue: /usr/bin/ld: libqemuutil.a(qemu-thread-posix.o): undefined reference to sym= bol 'pthread_setname_np@@GLIBC_2.12' /usr/lib64/libpthread.so.0: error adding symbols: DSO missing from command = line Make sure qemu-ga links with the pthread library, by adding correct flags to libs_qga. Signed-off-by: Marc-Andr=C3=A9 Lureau --- configure | 1 + 1 file changed, 1 insertion(+) diff --git a/configure b/configure index 0c6e7572db..2b8c71f522 100755 --- a/configure +++ b/configure @@ -3436,6 +3436,7 @@ else done if test "$found" =3D "no"; then LIBS=3D"$pthread_lib $LIBS" + libs_qga=3D"$pthread_lib $libs_qga" fi PTHREAD_LIB=3D"$pthread_lib" break --=20 2.15.1.355.g36791d7216 From nobody Mon Apr 29 03:48:00 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1512694849276687.0258204142704; Thu, 7 Dec 2017 17:00:49 -0800 (PST) Received: from localhost ([::1]:35061 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN71w-0000Wf-PW for importer@patchew.org; Thu, 07 Dec 2017 20:00:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46571) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN6zw-0006ha-Fn for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:58:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eN6zv-0007Tr-MC for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:58:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34732) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eN6zv-0007TZ-Fi for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:58:39 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8B35085542 for ; Fri, 8 Dec 2017 00:58:38 +0000 (UTC) Received: from localhost (ovpn-112-20.ams2.redhat.com [10.36.112.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 48AF2424B; Fri, 8 Dec 2017 00:58:35 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Fri, 8 Dec 2017 01:58:15 +0100 Message-Id: <20171208005825.14587-3-marcandre.lureau@redhat.com> In-Reply-To: <20171208005825.14587-1-marcandre.lureau@redhat.com> References: <20171208005825.14587-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 08 Dec 2017 00:58:38 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 02/12] build-sys: silence make by default X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In particular, do not print anything when there is nothing to do, in particular, after a successful build: $ make make[1]: '/home/elmarco/src/qemu/build/capstone/libcapstone.a' is up to dat= e. Signed-off-by: Marc-Andr=C3=A9 Lureau --- rules.mak | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rules.mak b/rules.mak index 6e943335f3..b760d54908 100644 --- a/rules.mak +++ b/rules.mak @@ -131,6 +131,11 @@ modules: # If called with only a single argument, will print nothing in quiet mode. quiet-command =3D $(if $(V),$1,$(if $(2),@printf " %-7s %s\n" $2 $3 && $1= , @$1)) =20 +makeflags_ =3D $(makeflags_0) +makeflags_0 =3D --no-print-directory -s +makeflags_1 =3D +MAKEFLAGS +=3D $(makeflags_$(V)) + # cc-option # Usage: CFLAGS+=3D$(call cc-option, -falign-functions=3D0, -malign-functi= ons=3D0) =20 --=20 2.15.1.355.g36791d7216 From nobody Mon Apr 29 03:48:00 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1512694926455774.3880177899913; Thu, 7 Dec 2017 17:02:06 -0800 (PST) Received: from localhost ([::1]:35068 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN739-0001RR-3i for importer@patchew.org; Thu, 07 Dec 2017 20:01:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46610) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN6zy-0006kV-TF for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:58:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eN6zx-0007Ww-Rw for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:58:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33912) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eN6zx-0007WH-M2 for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:58:41 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C67AC883B6 for ; Fri, 8 Dec 2017 00:58:40 +0000 (UTC) Received: from localhost (ovpn-112-20.ams2.redhat.com [10.36.112.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47B8D1F8; Fri, 8 Dec 2017 00:58:40 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Fri, 8 Dec 2017 01:58:16 +0100 Message-Id: <20171208005825.14587-4-marcandre.lureau@redhat.com> In-Reply-To: <20171208005825.14587-1-marcandre.lureau@redhat.com> References: <20171208005825.14587-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 08 Dec 2017 00:58:40 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 03/12] build-sys: add a rule to print a variable X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" $ make print-CFLAGS CFLAGS=3D-fsanitize=3Daddress -Og -g Trick from various sources: https://stackoverflow.com/questions/16467718/how-to-print-out-a-variable-in= -makefile https://www.cmcrossroads.com/article/printing-value-makefile-variable Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Eric Blake --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ab0354c153..80683e8c8b 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,10 @@ BUILD_DIR=3D$(CURDIR) # Before including a proper config-host.mak, assume we are in the source t= ree SRC_PATH=3D. =20 -UNCHECKED_GOALS :=3D %clean TAGS cscope ctags docker docker-% help +UNCHECKED_GOALS :=3D %clean TAGS cscope ctags docker docker-% help print-% + +print-%: + @echo '$*=3D$($*)' =20 # All following code might depend on configuration variables ifneq ($(wildcard config-host.mak),) --=20 2.15.1.355.g36791d7216 From nobody Mon Apr 29 03:48:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151269503734231.4208896120723; Thu, 7 Dec 2017 17:03:57 -0800 (PST) Received: from localhost ([::1]:35080 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN751-00048h-UJ for importer@patchew.org; Thu, 07 Dec 2017 20:03:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46638) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN703-0006mc-TO for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:58:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eN700-0007Ze-48 for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:58:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36752) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eN6zz-0007YQ-UE for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:58:44 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 05E6183F43 for ; Fri, 8 Dec 2017 00:58:43 +0000 (UTC) Received: from localhost (ovpn-112-20.ams2.redhat.com [10.36.112.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7ED625EDE8; Fri, 8 Dec 2017 00:58:42 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Fri, 8 Dec 2017 01:58:17 +0100 Message-Id: <20171208005825.14587-5-marcandre.lureau@redhat.com> In-Reply-To: <20171208005825.14587-1-marcandre.lureau@redhat.com> References: <20171208005825.14587-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 08 Dec 2017 00:58:43 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 04/12] build-sys: add AddressSanitizer when --enable-debug if possible X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Enable ASAN by default if the compiler supports it. If necessary, we could consider a seperate configure option, although I like the idea to have it enabled by default with --enable-debug, so other people more actively fix errors/warnings, and having less configure options in general. Signed-off-by: Marc-Andr=C3=A9 Lureau --- configure | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configure b/configure index 2b8c71f522..52d9fd71e5 100755 --- a/configure +++ b/configure @@ -5129,6 +5129,11 @@ elif test "$fortify_source" =3D "yes" ; then CFLAGS=3D"-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3D2 $CFLAGS" elif test "$debug" =3D "no"; then CFLAGS=3D"-O2 $CFLAGS" +elif test "$debug" =3D "yes"; then + write_c_skeleton; + if compile_prog "-fsanitize=3Daddress" ""; then + CFLAGS=3D"-fsanitize=3Daddress $CFLAGS" + fi fi =20 ########################################## --=20 2.15.1.355.g36791d7216 From nobody Mon Apr 29 03:48:00 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1512695031400743.8918137852901; Thu, 7 Dec 2017 17:03:51 -0800 (PST) Received: from localhost ([::1]:35079 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN74w-000452-1a for importer@patchew.org; Thu, 07 Dec 2017 20:03:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46655) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN705-0006oK-Mw for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:58:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eN705-0007bS-0g for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:58:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45820) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eN704-0007b4-R0 for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:58:48 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EB6025D5F4 for ; Fri, 8 Dec 2017 00:58:47 +0000 (UTC) Received: from localhost (ovpn-112-20.ams2.redhat.com [10.36.112.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id C2F4A18ACE; Fri, 8 Dec 2017 00:58:44 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Fri, 8 Dec 2017 01:58:18 +0100 Message-Id: <20171208005825.14587-6-marcandre.lureau@redhat.com> In-Reply-To: <20171208005825.14587-1-marcandre.lureau@redhat.com> References: <20171208005825.14587-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 08 Dec 2017 00:58:47 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 05/12] tests: fix check-qobject leak: X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" /public/qobject_is_equal_conversion: OK =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D14396=3D=3DERROR: LeakSanitizer: detected memory leaks Direct leak of 56 byte(s) in 1 object(s) allocated from: #0 0x7f07682c5850 in malloc (/lib64/libasan.so.4+0xde850) #1 0x7f0767d12f0c in g_malloc ../glib/gmem.c:94 #2 0x7f0767d131cf in g_malloc_n ../glib/gmem.c:331 #3 0x562bd767371f in do_test_equality /home/elmarco/src/qq/tests/check-= qobject.c:49 #4 0x562bd7674a35 in qobject_is_equal_dict_test /home/elmarco/src/qq/te= sts/check-qobject.c:267 #5 0x7f0767d37b04 in test_case_run ../glib/gtestutils.c:2237 #6 0x7f0767d37ec4 in g_test_run_suite_internal ../glib/gtestutils.c:2321 #7 0x7f0767d37f6d in g_test_run_suite_internal ../glib/gtestutils.c:2333 #8 0x7f0767d38184 in g_test_run_suite ../glib/gtestutils.c:2408 #9 0x7f0767d36e0d in g_test_run ../glib/gtestutils.c:1674 #10 0x562bd7674e75 in main /home/elmarco/src/qq/tests/check-qobject.c:3= 27 #11 0x7f0766009039 in __libc_start_main (/lib64/libc.so.6+0x21039) Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster --- tests/check-qobject.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/check-qobject.c b/tests/check-qobject.c index 03e9175113..710f9e6b0a 100644 --- a/tests/check-qobject.c +++ b/tests/check-qobject.c @@ -59,6 +59,8 @@ static void do_test_equality(bool expected, int _, ...) g_assert(qobject_is_equal(args[i], args[j]) =3D=3D expected); } } + + g_free(args); } =20 #define check_equal(...) \ --=20 2.15.1.355.g36791d7216 From nobody Mon Apr 29 03:48:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1512695106354481.5497233516585; Thu, 7 Dec 2017 17:05:06 -0800 (PST) Received: from localhost ([::1]:35081 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN763-00050i-NI for importer@patchew.org; Thu, 07 Dec 2017 20:04:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46684) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN708-0006rD-Pe for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:58:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eN707-0007eM-Sq for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:58:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43384) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eN707-0007dn-MH for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:58:51 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 300D715561 for ; Fri, 8 Dec 2017 00:58:50 +0000 (UTC) Received: from localhost (ovpn-112-20.ams2.redhat.com [10.36.112.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id A7043424B; Fri, 8 Dec 2017 00:58:49 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Fri, 8 Dec 2017 01:58:19 +0100 Message-Id: <20171208005825.14587-7-marcandre.lureau@redhat.com> In-Reply-To: <20171208005825.14587-1-marcandre.lureau@redhat.com> References: <20171208005825.14587-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 08 Dec 2017 00:58:50 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 06/12] vl: fix direct firmware directories leak X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Note that data_dir[] will now point to allocated strings. Fixes: Direct leak of 16 byte(s) in 1 object(s) allocated from: #0 0x7f1448181850 in malloc (/lib64/libasan.so.4+0xde850) #1 0x7f1446ed8f0c in g_malloc ../glib/gmem.c:94 #2 0x7f1446ed91cf in g_malloc_n ../glib/gmem.c:331 #3 0x7f1446ef739a in g_strsplit ../glib/gstrfuncs.c:2364 #4 0x55cf276439d7 in main /home/elmarco/src/qq/vl.c:4311 #5 0x7f143dfad039 in __libc_start_main (/lib64/libc.so.6+0x21039) Signed-off-by: Marc-Andr=C3=A9 Lureau --- vl.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/vl.c b/vl.c index 1ad1c04637..763c2bf6ae 100644 --- a/vl.c +++ b/vl.c @@ -2363,7 +2363,7 @@ static void qemu_add_data_dir(const char *path) return; /* duplicate */ } } - data_dir[data_dir_idx++] =3D path; + data_dir[data_dir_idx++] =3D g_strdup(path); } =20 static inline bool nonempty_str(const char *str) @@ -3124,7 +3124,7 @@ int main(int argc, char **argv, char **envp) Error *main_loop_err =3D NULL; Error *err =3D NULL; bool list_data_dirs =3D false; - char **dirs; + char *dir, **dirs; typedef struct BlockdevOptions_queue { BlockdevOptions *bdo; Location loc; @@ -4312,9 +4312,12 @@ int main(int argc, char **argv, char **envp) for (i =3D 0; dirs[i] !=3D NULL; i++) { qemu_add_data_dir(dirs[i]); } + g_strfreev(dirs); =20 /* try to find datadir relative to the executable path */ - qemu_add_data_dir(os_find_datadir()); + dir =3D os_find_datadir(); + qemu_add_data_dir(dir); + g_free(dir); =20 /* add the datadir specified when building */ qemu_add_data_dir(CONFIG_QEMU_DATADIR); --=20 2.15.1.355.g36791d7216 From nobody Mon Apr 29 03:48:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1512695202361647.4134833690744; Thu, 7 Dec 2017 17:06:42 -0800 (PST) Received: from localhost ([::1]:35096 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN77c-0006QR-NQ for importer@patchew.org; Thu, 07 Dec 2017 20:06:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46696) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN70D-0006uy-QA for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:58:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eN709-0007fp-Qw for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:58:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47038) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eN709-0007fL-Hz for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:58:53 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8B8DB81DE6 for ; Fri, 8 Dec 2017 00:58:52 +0000 (UTC) Received: from localhost (ovpn-112-20.ams2.redhat.com [10.36.112.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id DBAD818ACE; Fri, 8 Dec 2017 00:58:51 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Fri, 8 Dec 2017 01:58:20 +0100 Message-Id: <20171208005825.14587-8-marcandre.lureau@redhat.com> In-Reply-To: <20171208005825.14587-1-marcandre.lureau@redhat.com> References: <20171208005825.14587-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 08 Dec 2017 00:58:52 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 07/12] readline: add a free function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Dr. David Alan Gilbert" , Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Fixes leaks such as: Direct leak of 2 byte(s) in 1 object(s) allocated from: #0 0x7eff58beb850 in malloc (/lib64/libasan.so.4+0xde850) #1 0x7eff57942f0c in g_malloc ../glib/gmem.c:94 #2 0x7eff579431cf in g_malloc_n ../glib/gmem.c:331 #3 0x7eff5795f6eb in g_strdup ../glib/gstrfuncs.c:363 #4 0x55db720f1d46 in readline_hist_add /home/elmarco/src/qq/util/readli= ne.c:258 #5 0x55db720f2d34 in readline_handle_byte /home/elmarco/src/qq/util/rea= dline.c:387 #6 0x55db71539d00 in monitor_read /home/elmarco/src/qq/monitor.c:3896 #7 0x55db71f9be35 in qemu_chr_be_write_impl /home/elmarco/src/qq/charde= v/char.c:167 #8 0x55db71f9bed3 in qemu_chr_be_write /home/elmarco/src/qq/chardev/cha= r.c:179 #9 0x55db71fa013c in fd_chr_read /home/elmarco/src/qq/chardev/char-fd.c= :66 #10 0x55db71fe18a8 in qio_channel_fd_source_dispatch /home/elmarco/src/= qq/io/channel-watch.c:84 #11 0x7eff5793a90b in g_main_dispatch ../glib/gmain.c:3182 #12 0x7eff5793b7ac in g_main_context_dispatch ../glib/gmain.c:3847 #13 0x55db720af3bd in glib_pollfds_poll /home/elmarco/src/qq/util/main-= loop.c:214 #14 0x55db720af505 in os_host_main_loop_wait /home/elmarco/src/qq/util/= main-loop.c:261 #15 0x55db720af6d6 in main_loop_wait /home/elmarco/src/qq/util/main-loo= p.c:515 #16 0x55db7184e0de in main_loop /home/elmarco/src/qq/vl.c:1995 #17 0x55db7185e956 in main /home/elmarco/src/qq/vl.c:4914 #18 0x7eff4ea17039 in __libc_start_main (/lib64/libc.so.6+0x21039) (while at it, use g_new0(ReadLineState), it's a bit easier to read) Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Dr. David Alan Gilbert --- include/qemu/readline.h | 1 + monitor.c | 2 +- util/readline.c | 18 +++++++++++++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/include/qemu/readline.h b/include/qemu/readline.h index c08cf7400e..e81258322b 100644 --- a/include/qemu/readline.h +++ b/include/qemu/readline.h @@ -59,5 +59,6 @@ ReadLineState *readline_init(ReadLinePrintfFunc *printf_f= unc, ReadLineFlushFunc *flush_func, void *opaque, ReadLineCompletionFunc *completion_finder); +void readline_free(ReadLineState *rs); =20 #endif /* READLINE_H */ diff --git a/monitor.c b/monitor.c index e36fb5308d..024dd3d515 100644 --- a/monitor.c +++ b/monitor.c @@ -584,7 +584,7 @@ static void monitor_data_destroy(Monitor *mon) if (monitor_is_qmp(mon)) { json_message_parser_destroy(&mon->qmp.parser); } - g_free(mon->rs); + readline_free(mon->rs); QDECREF(mon->outbuf); qemu_mutex_destroy(&mon->out_lock); } diff --git a/util/readline.c b/util/readline.c index bbdee790b0..24ec839854 100644 --- a/util/readline.c +++ b/util/readline.c @@ -500,12 +500,28 @@ const char *readline_get_history(ReadLineState *rs, u= nsigned int index) return rs->history[index]; } =20 +void readline_free(ReadLineState *rs) +{ + int i; + + if (!rs) { + return; + } + for (i =3D 0; i < READLINE_MAX_CMDS; i++) { + g_free(rs->history[i]); + } + for (i =3D 0; i < READLINE_MAX_COMPLETIONS; i++) { + g_free(rs->completions[i]); + } + g_free(rs); +} + ReadLineState *readline_init(ReadLinePrintfFunc *printf_func, ReadLineFlushFunc *flush_func, void *opaque, ReadLineCompletionFunc *completion_finder) { - ReadLineState *rs =3D g_malloc0(sizeof(*rs)); + ReadLineState *rs =3D g_new0(ReadLineState, 1); =20 rs->hist_entry =3D -1; rs->opaque =3D opaque; --=20 2.15.1.355.g36791d7216 From nobody Mon Apr 29 03:48:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1512695032407698.5424595816088; Thu, 7 Dec 2017 17:03:52 -0800 (PST) Received: from localhost ([::1]:35078 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN74t-000444-OQ for importer@patchew.org; Thu, 07 Dec 2017 20:03:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46711) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN70F-0006vX-43 for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:58:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eN70E-0007jH-Ct for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:58:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45868) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eN70E-0007iV-6G for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:58:58 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 505BA5D5F4 for ; Fri, 8 Dec 2017 00:58:57 +0000 (UTC) Received: from localhost (ovpn-112-20.ams2.redhat.com [10.36.112.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4DE6417D3C; Fri, 8 Dec 2017 00:58:54 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Fri, 8 Dec 2017 01:58:21 +0100 Message-Id: <20171208005825.14587-9-marcandre.lureau@redhat.com> In-Reply-To: <20171208005825.14587-1-marcandre.lureau@redhat.com> References: <20171208005825.14587-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 08 Dec 2017 00:58:57 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 08/12] tests: fix migration-test leak X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Dr. David Alan Gilbert" , Juan Quintela Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Direct leak of 12 byte(s) in 2 object(s) allocated from: #0 0x7f50d403c850 in malloc (/lib64/libasan.so.4+0xde850) #1 0x7f50d1ddf98f in vasprintf (/lib64/libc.so.6+0x8098f) Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Dr. David Alan Gilbert --- tests/migration-test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/migration-test.c b/tests/migration-test.c index be598d3257..799e24ebc6 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -358,13 +358,14 @@ static void migrate_check_parameter(QTestState *who, = const char *parameter, const char *value) { QDict *rsp, *rsp_return; - const char *result; + char *result; =20 rsp =3D wait_command(who, "{ 'execute': 'query-migrate-parameters' }"); rsp_return =3D qdict_get_qdict(rsp, "return"); result =3D g_strdup_printf("%" PRId64, qdict_get_try_int(rsp_return, parameter, -1)= ); g_assert_cmpstr(result, =3D=3D, value); + g_free(result); QDECREF(rsp); } =20 --=20 2.15.1.355.g36791d7216 From nobody Mon Apr 29 03:48:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1512695199539691.0649534154153; Thu, 7 Dec 2017 17:06:39 -0800 (PST) Received: from localhost ([::1]:35095 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN77Y-0006Ni-UX for importer@patchew.org; Thu, 07 Dec 2017 20:06:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46763) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN70P-00075A-IP for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:59:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eN70J-0007nA-Ij for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:59:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51858) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eN70J-0007mi-9s for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:59:03 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 613B44E90A for ; Fri, 8 Dec 2017 00:59:02 +0000 (UTC) Received: from localhost (ovpn-112-20.ams2.redhat.com [10.36.112.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 07145424B; Fri, 8 Dec 2017 00:58:58 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Fri, 8 Dec 2017 01:58:22 +0100 Message-Id: <20171208005825.14587-10-marcandre.lureau@redhat.com> In-Reply-To: <20171208005825.14587-1-marcandre.lureau@redhat.com> References: <20171208005825.14587-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 08 Dec 2017 00:59:02 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 09/12] crypto: fix stack-buffer-overflow error X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" ASAN complains about: =3D=3D8856=3D=3DERROR: AddressSanitizer: stack-buffer-overflow on address 0= x7ffd8a1fe168 at pc 0x561136cb4451 bp 0x7ffd8a1fe130 sp 0x7ffd8a1fd8e0 READ of size 16 at 0x7ffd8a1fe168 thread T0 #0 0x561136cb4450 in __asan_memcpy (/home/elmarco/src/qq/build/tests/te= st-crypto-ivgen+0x110450) #1 0x561136d2a6a7 in qcrypto_ivgen_essiv_calculate /home/elmarco/src/qq= /crypto/ivgen-essiv.c:83:5 #2 0x561136d29af8 in qcrypto_ivgen_calculate /home/elmarco/src/qq/crypt= o/ivgen.c:72:12 #3 0x561136d07c8e in test_ivgen /home/elmarco/src/qq/tests/test-crypto-= ivgen.c:148:5 #4 0x7f77772c3b04 in test_case_run /home/elmarco/src/gnome/glib/builddi= r/../glib/gtestutils.c:2237 #5 0x7f77772c3ec4 in g_test_run_suite_internal /home/elmarco/src/gnome/= glib/builddir/../glib/gtestutils.c:2321 #6 0x7f77772c3f6d in g_test_run_suite_internal /home/elmarco/src/gnome/= glib/builddir/../glib/gtestutils.c:2333 #7 0x7f77772c3f6d in g_test_run_suite_internal /home/elmarco/src/gnome/= glib/builddir/../glib/gtestutils.c:2333 #8 0x7f77772c3f6d in g_test_run_suite_internal /home/elmarco/src/gnome/= glib/builddir/../glib/gtestutils.c:2333 #9 0x7f77772c4184 in g_test_run_suite /home/elmarco/src/gnome/glib/buil= ddir/../glib/gtestutils.c:2408 #10 0x7f77772c2e0d in g_test_run /home/elmarco/src/gnome/glib/builddir/= ../glib/gtestutils.c:1674 #11 0x561136d0799b in main /home/elmarco/src/qq/tests/test-crypto-ivgen= .c:173:12 #12 0x7f77756e6039 in __libc_start_main (/lib64/libc.so.6+0x21039) #13 0x561136c13d89 in _start (/home/elmarco/src/qq/build/tests/test-cry= pto-ivgen+0x6fd89) Address 0x7ffd8a1fe168 is located in stack of thread T0 at offset 40 in fra= me #0 0x561136d2a40f in qcrypto_ivgen_essiv_calculate /home/elmarco/src/qq= /crypto/ivgen-essiv.c:76 This frame has 1 object(s): [32, 40) 'sector.addr' <=3D=3D Memory access at offset 40 overflows thi= s variable HINT: this may be a false positive if your program uses some custom stack u= nwind mechanism or swapcontext (longjmp and C++ exceptions *are* supported) SUMMARY: AddressSanitizer: stack-buffer-overflow (/home/elmarco/src/qq/buil= d/tests/test-crypto-ivgen+0x110450) in __asan_memcpy Shadow bytes around the buggy address: 0x100031437bd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x100031437be0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x100031437bf0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x100031437c00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x100031437c10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 =3D>0x100031437c20: 00 00 00 00 00 00 00 00 f1 f1 f1 f1 00[f3]f3 f3 0x100031437c30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x100031437c40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x100031437c50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x100031437c60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x100031437c70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Shadow byte legend (one shadow byte represents 8 application bytes): Addressable: 00 Partially addressable: 01 02 03 04 05 06 07 Heap left redzone: fa Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 Container overflow: fc Array cookie: ac Intra object redzone: bb ASan internal: fe Left alloca redzone: ca Right alloca redzone: cb It looks like the rest of the code copes with ndata being larger than sizeof(sector), so limit the memcpy() range. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrange --- crypto/ivgen-essiv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/ivgen-essiv.c b/crypto/ivgen-essiv.c index cba20bde6c..ad4d926c19 100644 --- a/crypto/ivgen-essiv.c +++ b/crypto/ivgen-essiv.c @@ -79,7 +79,7 @@ static int qcrypto_ivgen_essiv_calculate(QCryptoIVGen *iv= gen, uint8_t *data =3D g_new(uint8_t, ndata); =20 sector =3D cpu_to_le64(sector); - memcpy(data, (uint8_t *)§or, ndata); + memcpy(data, (uint8_t *)§or, MIN(sizeof(sector), ndata)); if (sizeof(sector) < ndata) { memset(data + sizeof(sector), 0, ndata - sizeof(sector)); } --=20 2.15.1.355.g36791d7216 From nobody Mon Apr 29 03:48:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1512695291498760.5727271248948; Thu, 7 Dec 2017 17:08:11 -0800 (PST) Received: from localhost ([::1]:35102 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN791-00006h-7V for importer@patchew.org; Thu, 07 Dec 2017 20:08:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46775) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN70Q-00075z-GZ for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:59:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eN70M-0007pa-2O for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:59:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34026) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eN70L-0007p1-Pm for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:59:05 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D2DEA883B6 for ; Fri, 8 Dec 2017 00:59:04 +0000 (UTC) Received: from localhost (ovpn-112-20.ams2.redhat.com [10.36.112.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 560FB1814C; Fri, 8 Dec 2017 00:59:04 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Fri, 8 Dec 2017 01:58:23 +0100 Message-Id: <20171208005825.14587-11-marcandre.lureau@redhat.com> In-Reply-To: <20171208005825.14587-1-marcandre.lureau@redhat.com> References: <20171208005825.14587-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 08 Dec 2017 00:59:04 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 10/12] qemu-config: fix leak in query-command-line-options X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Direct leak of 160 byte(s) in 4 object(s) allocated from: #0 0x55ed7678cda8 in calloc (/home/elmarco/src/qq/build/x86_64-softmmu/= qemu-system-x86_64+0x797da8) #1 0x7f3f5e725f75 in g_malloc0 /home/elmarco/src/gnome/glib/builddir/..= /glib/gmem.c:124 #2 0x55ed778aa3a7 in query_option_descs /home/elmarco/src/qq/util/qemu-= config.c:60:16 #3 0x55ed778aa307 in get_drive_infolist /home/elmarco/src/qq/util/qemu-= config.c:140:19 #4 0x55ed778a9f40 in qmp_query_command_line_options /home/elmarco/src/q= q/util/qemu-config.c:254:36 #5 0x55ed76d4868c in qmp_marshal_query_command_line_options /home/elmar= co/src/qq/build/qmp-marshal.c:3078:14 #6 0x55ed77855dd5 in do_qmp_dispatch /home/elmarco/src/qq/qapi/qmp-disp= atch.c:104:5 #7 0x55ed778558cc in qmp_dispatch /home/elmarco/src/qq/qapi/qmp-dispatc= h.c:131:11 #8 0x55ed768b592f in handle_qmp_command /home/elmarco/src/qq/monitor.c:= 3840:11 #9 0x55ed7786ccfe in json_message_process_token /home/elmarco/src/qq/qo= bject/json-streamer.c:105:5 #10 0x55ed778fe37c in json_lexer_feed_char /home/elmarco/src/qq/qobject= /json-lexer.c:323:13 #11 0x55ed778fdde6 in json_lexer_feed /home/elmarco/src/qq/qobject/json= -lexer.c:373:15 #12 0x55ed7786cd83 in json_message_parser_feed /home/elmarco/src/qq/qob= ject/json-streamer.c:124:12 #13 0x55ed768b559e in monitor_qmp_read /home/elmarco/src/qq/monitor.c:3= 882:5 #14 0x55ed77714f29 in qemu_chr_be_write_impl /home/elmarco/src/qq/chard= ev/char.c:167:9 #15 0x55ed77714fde in qemu_chr_be_write /home/elmarco/src/qq/chardev/ch= ar.c:179:9 #16 0x55ed7772ffad in tcp_chr_read /home/elmarco/src/qq/chardev/char-so= cket.c:440:13 #17 0x55ed7777113b in qio_channel_fd_source_dispatch /home/elmarco/src/= qq/io/channel-watch.c:84:12 #18 0x7f3f5e71d90b in g_main_dispatch /home/elmarco/src/gnome/glib/buil= ddir/../glib/gmain.c:3182 #19 0x7f3f5e71e7ac in g_main_context_dispatch /home/elmarco/src/gnome/g= lib/builddir/../glib/gmain.c:3847 #20 0x55ed77886ffc in glib_pollfds_poll /home/elmarco/src/qq/util/main-= loop.c:214:9 #21 0x55ed778865fd in os_host_main_loop_wait /home/elmarco/src/qq/util/= main-loop.c:261:5 #22 0x55ed77886222 in main_loop_wait /home/elmarco/src/qq/util/main-loo= p.c:515:11 #23 0x55ed76d2a4df in main_loop /home/elmarco/src/qq/vl.c:1995:9 #24 0x55ed76d1cb4a in main /home/elmarco/src/qq/vl.c:4914:5 #25 0x7f3f555f6039 in __libc_start_main (/lib64/libc.so.6+0x21039) Signed-off-by: Marc-Andr=C3=A9 Lureau --- util/qemu-config.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/qemu-config.c b/util/qemu-config.c index 99b0e46fa3..029fec53a9 100644 --- a/util/qemu-config.c +++ b/util/qemu-config.c @@ -105,7 +105,8 @@ static void cleanup_infolist(CommandLineParameterInfoLi= st *head) if (!strcmp(pre_entry->value->name, cur->next->value->name)) { del_entry =3D cur->next; cur->next =3D cur->next->next; - g_free(del_entry); + del_entry->next =3D NULL; + qapi_free_CommandLineParameterInfoList(del_entry); break; } pre_entry =3D pre_entry->next; --=20 2.15.1.355.g36791d7216 From nobody Mon Apr 29 03:48:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1512695198302118.83123198675798; Thu, 7 Dec 2017 17:06:38 -0800 (PST) Received: from localhost ([::1]:35094 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN77X-0006Ms-NQ for importer@patchew.org; Thu, 07 Dec 2017 20:06:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46787) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN70R-00076j-6b for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:59:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eN70Q-0007sG-9d for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:59:11 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36978) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eN70Q-0007rj-4C for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:59:10 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 358EC6A7DB for ; Fri, 8 Dec 2017 00:59:09 +0000 (UTC) Received: from localhost (ovpn-112-20.ams2.redhat.com [10.36.112.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id A61FB64446; Fri, 8 Dec 2017 00:59:06 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Fri, 8 Dec 2017 01:58:24 +0100 Message-Id: <20171208005825.14587-12-marcandre.lureau@redhat.com> In-Reply-To: <20171208005825.14587-1-marcandre.lureau@redhat.com> References: <20171208005825.14587-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 08 Dec 2017 00:59:09 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 11/12] tests: fix qmp-test leak X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Direct leak of 913 byte(s) in 43 object(s) allocated from: #0 0x55880a15df60 in __interceptor_malloc (/home/elmarco/src/qq/build/t= ests/qmp-test+0x110f60) #1 0x7f3f20fd098f in _IO_vasprintf (/lib64/libc.so.6+0x8098f) Signed-off-by: Marc-Andr=C3=A9 Lureau --- tests/qmp-test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/qmp-test.c b/tests/qmp-test.c index c5a5c10b41..36feb2204b 100644 --- a/tests/qmp-test.c +++ b/tests/qmp-test.c @@ -271,7 +271,7 @@ static void add_query_tests(QmpSchema *schema) { SchemaInfoList *tail; SchemaInfo *si, *arg_type, *ret_type; - const char *test_name; + char *test_name; =20 /* Test the query-like commands */ for (tail =3D schema->list; tail; tail =3D tail->next) { @@ -297,6 +297,7 @@ static void add_query_tests(QmpSchema *schema) =20 test_name =3D g_strdup_printf("qmp/%s", si->name); qtest_add_data_func(test_name, si->name, test_query); + g_free(test_name); } } =20 --=20 2.15.1.355.g36791d7216 From nobody Mon Apr 29 03:48:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1512695356371362.022417168723; Thu, 7 Dec 2017 17:09:16 -0800 (PST) Received: from localhost ([::1]:35105 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN7A7-0000xR-Sr for importer@patchew.org; Thu, 07 Dec 2017 20:09:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46821) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN70a-0007jN-Iw for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:59:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eN70W-0007x4-My for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:59:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34912) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eN70W-0007wL-EV for qemu-devel@nongnu.org; Thu, 07 Dec 2017 19:59:16 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 868B785546 for ; Fri, 8 Dec 2017 00:59:15 +0000 (UTC) Received: from localhost (ovpn-112-20.ams2.redhat.com [10.36.112.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA4A4922E4; Fri, 8 Dec 2017 00:59:10 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Fri, 8 Dec 2017 01:58:25 +0100 Message-Id: <20171208005825.14587-13-marcandre.lureau@redhat.com> In-Reply-To: <20171208005825.14587-1-marcandre.lureau@redhat.com> References: <20171208005825.14587-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 08 Dec 2017 00:59:15 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 12/12] WIP ucontext: annotate coroutine stack for ASAN X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Not strictly necessary, but it may help ASAN and remove some false positives. Sadly, this annotation produces an ASAN error: $ tests/test-coroutine -p /basic/lifecycle /basic/lifecycle: =3D=3D27655=3D=3DWARNING: ASan doesn't fully support make= context/swapcontext functions and may produce false positives in some cases! =3D=3D27655=3D=3DAddressSanitizer CHECK failed: /builddir/build/BUILD/compi= ler-rt-4.0.1.src/lib/asan/asan_poisoning.cc:38 "((AddrIsAlignedByGranularit= y(addr + size))) !=3D (0)" (0x0, 0x0) #0 0x55d1e4e8a695 in __asan::AsanCheckFailed(char const*, int, char con= st*, unsigned long long, unsigned long long) (/home/elmarco/src/qq/build/te= sts/test-coroutine+0x1c0695) #1 0x55d1e4ea6235 in __sanitizer::CheckFailed(char const*, int, char co= nst*, unsigned long long, unsigned long long) (/home/elmarco/src/qq/build/t= ests/test-coroutine+0x1dc235) #2 0x55d1e4e82ea4 in __asan::PoisonShadow(unsigned long, unsigned long,= unsigned char) (/home/elmarco/src/qq/build/tests/test-coroutine+0x1b8ea4) #3 0x55d1e4dde1e7 in __asan::FakeStack::Destroy(int) (/home/elmarco/src= /qq/build/tests/test-coroutine+0x1141e7) #4 0x55d1e528b775 in qemu_coroutine_switch /home/elmarco/src/qq/util/co= routine-ucontext.c:219:9 #5 0x55d1e528b18d in coroutine_trampoline /home/elmarco/src/qq/util/cor= outine-ucontext.c:114:9 #6 0x7fb3e0087bef (/lib64/libc.so.6+0x50bef) Signed-off-by: Marc-Andr=C3=A9 Lureau --- util/coroutine-ucontext.c | 47 +++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 47 insertions(+) diff --git a/util/coroutine-ucontext.c b/util/coroutine-ucontext.c index 6621f3f692..d200498c38 100644 --- a/util/coroutine-ucontext.c +++ b/util/coroutine-ucontext.c @@ -31,6 +31,25 @@ #include #endif =20 +#if (defined(__has_feature) && __has_feature(address_sanitizer)) || \ + __SANITIZE_ADDRESS__ +#include +#else +/* stub to check correct arguments */ +static inline void +__sanitizer_start_switch_fiber(void **fake_stack_save, + const void *bottom, size_t size) +{ +} + +static inline void +__sanitizer_finish_switch_fiber(void *fake_stack_save, + const void **bottom_old, + size_t *size_old) +{ +} +#endif + typedef struct { Coroutine base; void *stack; @@ -64,6 +83,15 @@ static void coroutine_trampoline(int i0, int i1) union cc_arg arg; CoroutineUContext *self; Coroutine *co; + const void *bottom_old; + size_t size_old; + void *fake_stack_save; + + __sanitizer_finish_switch_fiber(NULL, &bottom_old, &size_old); + if (!leader.stack) { + leader.stack =3D (void *)bottom_old; + leader.stack_size =3D size_old; + } =20 arg.i[0] =3D i0; arg.i[1] =3D i1; @@ -72,9 +100,14 @@ static void coroutine_trampoline(int i0, int i1) =20 /* Initialize longjmp environment and switch back the caller */ if (!sigsetjmp(self->env, 0)) { + __sanitizer_start_switch_fiber(&fake_stack_save, + bottom_old, size_old); siglongjmp(*(sigjmp_buf *)co->entry_arg, 1); } =20 + __sanitizer_finish_switch_fiber(&fake_stack_save, + NULL, NULL); + while (true) { co->entry(co->entry_arg); qemu_coroutine_switch(co, co->caller, COROUTINE_TERMINATE); @@ -87,6 +120,7 @@ Coroutine *qemu_coroutine_new(void) ucontext_t old_uc, uc; sigjmp_buf old_env; union cc_arg arg =3D {0}; + void *fake_stack_save; =20 /* The ucontext functions preserve signal masks which incurs a * system call overhead. sigsetjmp(buf, 0)/siglongjmp() does not @@ -122,8 +156,13 @@ Coroutine *qemu_coroutine_new(void) =20 /* swapcontext() in, siglongjmp() back out */ if (!sigsetjmp(old_env, 0)) { + __sanitizer_start_switch_fiber(&fake_stack_save, + co->stack, co->stack_size); swapcontext(&old_uc, &uc); } + + __sanitizer_finish_switch_fiber(&fake_stack_save, NULL, NULL); + return &co->base; } =20 @@ -169,13 +208,21 @@ qemu_coroutine_switch(Coroutine *from_, Coroutine *to= _, CoroutineUContext *from =3D DO_UPCAST(CoroutineUContext, base, from_); CoroutineUContext *to =3D DO_UPCAST(CoroutineUContext, base, to_); int ret; + void *fake_stack_save; =20 current =3D to_; =20 ret =3D sigsetjmp(from->env, 0); if (ret =3D=3D 0) { + + __sanitizer_start_switch_fiber(action =3D=3D COROUTINE_TERMINATE ? + NULL : &fake_stack_save, + to->stack, to->stack_size); siglongjmp(to->env, action); } + + __sanitizer_finish_switch_fiber(&fake_stack_save, NULL, NULL); + return ret; } =20 --=20 2.15.1.355.g36791d7216