From nobody Thu May 2 23:01:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1496357953619514.1671417089497; Thu, 1 Jun 2017 15:59:13 -0700 (PDT) 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 3DD2FC049D59; Thu, 1 Jun 2017 22:59:10 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D3AE67D55D; Thu, 1 Jun 2017 22:59:06 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C45371800C88; Thu, 1 Jun 2017 22:59:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v51Mx0JP010159 for ; Thu, 1 Jun 2017 18:59:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 667DA7DEFC; Thu, 1 Jun 2017 22:59:00 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5F7967DEE8 for ; Thu, 1 Jun 2017 22:58:58 +0000 (UTC) Received: from mail-qt0-f169.google.com (mail-qt0-f169.google.com [209.85.216.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0174B83F42 for ; Thu, 1 Jun 2017 22:58:57 +0000 (UTC) Received: by mail-qt0-f169.google.com with SMTP id c13so48088343qtc.1 for ; Thu, 01 Jun 2017 15:58:56 -0700 (PDT) Received: from localhost.localdomain ([189.103.224.91]) by smtp.gmail.com with ESMTPSA id x49sm14065865qth.5.2017.06.01.15.58.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Jun 2017 15:58:55 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3DD2FC049D59 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3DD2FC049D59 Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="oaUSZncA" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0174B83F42 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=claudioandre.br@gmail.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0174B83F42 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ZIS7kS0PL1EbVhJDt+ZyjJzICJQoT64Y5fUR4mlChQA=; b=oaUSZncALj17MJXC0tkI7nbDTyUdPFi8T008IkGo8bG4YYveHn+Kh+DDsWDbcXmB8U RMOZ6iR9DTDLQFTa3gpMMEUPYhfjnXAUJQlvv7cOo3vhnriojzxXFe57D4HOwFs21F7T gXLqIJw+XcEOxUVHXCiB5KT0iZ5IJr8BPKtwp96Pq+Xj7Gf8jzaLLST2sYofZ3n/EfNK 2JxrmDpyHYG/XYJn176W8E8CxukuvF7AVL2DJ5HbL/ajcV5C5n/qXoES0AzYMqDoXPul 1mZ79YevOACjG/MLm0WF1YFf6wncGXMWWLP+siKn/FpcgtCpZb+TaH2k27Ufqj/Tmi1w ixIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ZIS7kS0PL1EbVhJDt+ZyjJzICJQoT64Y5fUR4mlChQA=; b=CmM3TOQiHpj2v0W1mqTo0bX+4awY7Tt2pr1rVL76fUfIMl5gcnHYwV5yFLkGqWYeuk ciXavp+1ofJALnq2ZpM6fsN3FF5n77jZltDozEHFr9RYDsFLWaFUCpV9QZ7SfMVqNTQ/ ipyHEQUrYPZxTzPfXV7RcKbeiij5RQsUMM8ZZ83pRTcUuo7F4lDj6D0q0wyedJ0jhqPX FaYECixW8T2tX88eUMER7YkY0w9gEW3DYJorh09CXdh/zs8LSJV1avDjzIvg0sSDzWlI VupsADGccHVQPLkw2/knt+E1TMqAo533zhyCsCFf5dS1BezMjqKSpB/Es1ZeGRHAyB9P xxgA== X-Gm-Message-State: AODbwcCFUPnAJDBTewToJXn5K9Vrtpt4V6cVnQwgwgilP4o1RjBHmEVV l79sx90OjWsxxXEg X-Received: by 10.237.36.154 with SMTP id t26mr4951587qtc.180.1496357936127; Thu, 01 Jun 2017 15:58:56 -0700 (PDT) From: claudioandre.br@gmail.com To: libvir-list@redhat.com Date: Thu, 1 Jun 2017 19:58:07 -0300 Message-Id: <20170601225807.22256-1-claudioandre.br@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 01 Jun 2017 22:58:57 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 01 Jun 2017 22:58:57 +0000 (UTC) for IP:'209.85.216.169' DOMAIN:'mail-qt0-f169.google.com' HELO:'mail-qt0-f169.google.com' FROM:'claudioandre.br@gmail.com' RCPT:'' X-RedHat-Spam-Score: 2.27 ** (BAYES_50, DCC_REPUT_00_12, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_SPAM, RCVD_IN_SORBS_WEB, SPF_PASS) 209.85.216.169 mail-qt0-f169.google.com 209.85.216.169 mail-qt0-f169.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?Claudio=20Andr=C3=A9?= Subject: [libvirt] [PATCH V2] maint: add sanitizers to the build process X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com 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.31]); Thu, 01 Jun 2017 22:59:11 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Claudio Andr=C3=A9 Sanitizers are based on compile-time instrumentation. They are available in gcc and clang for a range of supported operation systems and platforms. More info at: https://github.com/google/sanitizers The address sanitizer finds bugs related to addressing memory: use after free, heap buffer overflow, stack buffer overflow, memory leaks, ... The undefined behavior sanitizer detects situations not prescribed by the language specification: bound violations, data overflows, ... The llvm.org states that Sanitizers have found thousands of bugs everywhere. Sanitizers running during CI can prevent bugs from taking up residence. They are helper tools to maintain bugs out. --- * Harmless (the new flags are disabled by default) * Real example of it working: Direct leak of 1432 byte(s) in 1 object(s) allocated from: #0 0x4cea00 in calloc /home/ben/development/llvm/3.5/final/llvm.src/pro= jects/compiler-rt/lib/asan/asan_malloc_linux.cc:56:3 #1 0x2b0459e834a6 in virAlloc /home/travis/build/claudioandre/libvirt/s= rc/util/viralloc.c:144:24 #2 0x2b045a010af4 in virDomainDefNew /home/travis/build/claudioandre/li= bvirt/src/conf/domain_conf.c:2923:9 #3 0x2b045a010af4 in virDomainDefParseXML /home/travis/build/claudioand= re/libvirt/src/conf/domain_conf.c:16923 #4 0x2b045a0106a1 in virDomainDefParseNode /home/travis/build/claudioan= dre/libvirt/src/conf/domain_conf.c:18764:11 #5 0x2b045a0105ba in virDomainDefParse /home/travis/build/claudioandre/= libvirt/src/conf/domain_conf.c:18708:15 #6 0x4ec396 in testCompareMemLock /home/travis/build/claudioandre/libvi= rt/tests/qemumemlocktest.c:45:17 #7 0x4ede56 in virTestRun /home/travis/build/claudioandre/libvirt/tests= /testutils.c:180:11 #8 0x4ec194 in mymain /home/travis/build/claudioandre/libvirt/tests/qem= umemlocktest.c:119:5 #9 0x4f0f9c in virTestMain /home/travis/build/claudioandre/libvirt/test= s/testutils.c:1019:11 #10 0x2b045b221f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.= 6+0x21f44) m4/virt-compile-warnings.m4 | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4 index 768a5c8..269f14d 100644 --- a/m4/virt-compile-warnings.m4 +++ b/m4/virt-compile-warnings.m4 @@ -166,12 +166,6 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[ wantwarn=3D"$wantwarn -Wno-format" fi =20 - # This should be < 256 really. Currently we're down to 4096, - # but using 1024 bytes sized buffers (mostly for virStrerror) - # stops us from going down further - gl_WARN_ADD(["-Wframe-larger-than=3D4096"], [STRICT_FRAME_LIMIT_CFLAGS= ]) - gl_WARN_ADD(["-Wframe-larger-than=3D25600"], [RELAXED_FRAME_LIMIT_CFLA= GS]) - # Extra special flags dnl -fstack-protector stuff passes gl_WARN_ADD with gcc dnl on Mingw32, but fails when actually used @@ -259,4 +253,33 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[ AC_DEFINE_UNQUOTED([BROKEN_GCC_WLOGICALOP_EQUAL_EXPR], 1, [Define to 1 if gcc -Wlogical-op reports false positive 'or' equal= expr]) fi + + dnl Check for support for Sanitizers + dnl Check for -fsanitize=3Daddress and -fsanitize=3Dundefined support + LIBVIRT_ARG_ENABLE([ASAN], [build with address sanitizer support], [no= ]) + SAN_CFLAGS=3D + + AS_IF([test "x$enable_asan" =3D "xyes"], [ + gl_COMPILER_OPTION_IF([-fsanitize=3Daddress -fno-omit-frame-pointe= r], [ + SAN_CFLAGS=3D"-fsanitize=3Daddress" + ]) + ]) + + LIBVIRT_ARG_ENABLE([UBSAN], [build with undefined behavior sanitizer s= upport], [no]) + AS_IF([test "x$enable_ubsan" =3D "xyes"], [ + gl_COMPILER_OPTION_IF([-fsanitize=3Dundefined -fno-omit-frame-poin= ter], [ + SAN_CFLAGS=3D"$SAN_CFLAGS -fsanitize=3Dundefined" + ]) + ]) + + AS_IF([ test -n "${SAN_CFLAGS}"], [ + gl_AS_VAR_APPEND([WARN_CFLAGS], [" $SAN_CFLAGS -fno-omit-frame-poi= nter"]) + gl_AS_VAR_APPEND([LDFLAGS], [" $SAN_CFLAGS -ldl"]) + ],[ + # This should be < 256 really. Currently we're down to 4096, + # but using 1024 bytes sized buffers (mostly for virStrerror) + # stops us from going down further + gl_WARN_ADD(["-Wframe-larger-than=3D4096"], [STRICT_FRAME_LIMIT_CF= LAGS]) + gl_WARN_ADD(["-Wframe-larger-than=3D25600"], [RELAXED_FRAME_LIMIT_= CFLAGS]) + ]) ]) --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list