From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E11B7A04FF for ; Thu, 5 May 2022 11:30:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BB6D142831; Thu, 5 May 2022 11:30:19 +0200 (CEST) Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [170.10.133.74]) by mails.dpdk.org (Postfix) with ESMTP id BD1B14281A for ; Thu, 5 May 2022 11:30:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651743016; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EeFPcH+tMPiIQZlBA7ASG/o6s+hqfs4EkR7j3JUxsYI=; b=bk1wc6aGAHZvWwO2OiH1U2brA4oUYVOXQsw0yJwtwYRG8UIh9KW+OLq6ObZG53zea8kOPi aC1xlx7/9P9gcxu+3W2sbZ1XOfGW2PTurQZOg79+zLq+/UzB/cOJjIVEznP/EYwggdZvzK MFcKvfCeHgfjwtO5ZHb+oRDfdgLy+8w= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-568-J2ZN3YkpNAWBlF7kViFT-w-1; Thu, 05 May 2022 05:30:11 -0400 X-MC-Unique: J2ZN3YkpNAWBlF7kViFT-w-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B2615397968C; Thu, 5 May 2022 09:30:10 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.193.200]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6BCE954F40A; Thu, 5 May 2022 09:30:09 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: john.mcnamara@intel.com, stable@dpdk.org, Anatoly Burakov , Xueqin Lin , Zhihong Peng Subject: [PATCH v2 1/2] test/mem: disable ASan when accessing unallocated mem Date: Thu, 5 May 2022 11:29:51 +0200 Message-Id: <20220505092952.11818-2-david.marchand@redhat.com> In-Reply-To: <20220505092952.11818-1-david.marchand@redhat.com> References: <20220415173127.3838-1-david.marchand@redhat.com> <20220505092952.11818-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org As described in bugzilla, ASan reports accesses to all memory segment as invalid, since those parts have not been allocated. Move __rte_no_asan to rte_common.h and disable ASan on a part of the test. Bugzilla ID: 880 Fixes: 6cc51b1293ce ("mem: instrument allocator for ASan") Cc: stable@dpdk.org Signed-off-by: David Marchand Acked-by: Anatoly Burakov --- app/test/test_memory.c | 5 +++++ lib/eal/common/malloc_elem.h | 10 ++-------- lib/eal/include/rte_common.h | 13 +++++++++++++ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/app/test/test_memory.c b/app/test/test_memory.c index 140ac3f3cf..440e5ef838 100644 --- a/app/test/test_memory.c +++ b/app/test/test_memory.c @@ -25,6 +25,11 @@ * - Try to read all memory; it should not segfault. */ +/* + * ASan complains about accessing unallocated memory. + * See: https://bugs.dpdk.org/show_bug.cgi?id=880 + */ +__rte_no_asan static int check_mem(const struct rte_memseg_list *msl __rte_unused, const struct rte_memseg *ms, void *arg __rte_unused) diff --git a/lib/eal/common/malloc_elem.h b/lib/eal/common/malloc_elem.h index c5f65895e1..952ce7343b 100644 --- a/lib/eal/common/malloc_elem.h +++ b/lib/eal/common/malloc_elem.h @@ -7,6 +7,8 @@ #include +#include + #define MIN_DATA_SIZE (RTE_CACHE_LINE_SIZE) /* dummy definition of struct so we can use pointers to it in malloc_elem struct */ @@ -131,12 +133,6 @@ malloc_elem_cookies_ok(const struct malloc_elem *elem) #define ASAN_MEM_TO_SHADOW(mem) \ RTE_PTR_ADD(ASAN_MEM_SHIFT(mem), ASAN_SHADOW_OFFSET) -#if defined(__clang__) -#define __rte_no_asan __attribute__((no_sanitize("address", "hwaddress"))) -#else -#define __rte_no_asan __attribute__((no_sanitize_address)) -#endif - __rte_no_asan static inline void asan_set_shadow(void *addr, char val) @@ -276,8 +272,6 @@ old_malloc_size(struct malloc_elem *elem) #else /* !RTE_MALLOC_ASAN */ -#define __rte_no_asan - static inline void asan_set_zone(void *ptr __rte_unused, size_t len __rte_unused, uint32_t val __rte_unused) { } diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h index 67587025ab..d56a7570c0 100644 --- a/lib/eal/include/rte_common.h +++ b/lib/eal/include/rte_common.h @@ -267,6 +267,19 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void) */ #define __rte_cold __attribute__((cold)) +/** + * Disable AddressSanitizer on some code + */ +#ifdef RTE_MALLOC_ASAN +#ifdef RTE_CC_CLANG +#define __rte_no_asan __attribute__((no_sanitize("address", "hwaddress"))) +#else +#define __rte_no_asan __attribute__((no_sanitize_address)) +#endif +#else /* ! RTE_MALLOC_ASAN */ +#define __rte_no_asan +#endif + /*********** Macros for pointer arithmetic ********/ /** -- 2.23.0