From patchwork Thu Feb 3 09:39:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 106835 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8CF7AA00C2; Thu, 3 Feb 2022 10:39:46 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 60DA740151; Thu, 3 Feb 2022 10:39:46 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 5EA3D40151 for ; Thu, 3 Feb 2022 10:39:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643881183; 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; bh=WRo1A82PQtE2RM2Ee+KyCJF7u1YYp5/G/3dDnycIAcQ=; b=DrnaQxTBs7O0JgxUPtSZVXtFU0UK6PmMdHP03GKrL/G2+dDk5Sp5Omiio6PGskrzW5QEc/ Kl0KPrF3JqcvZC5pacS5UBsyNLwgjru9CdRINgkje8BNMEaVcI3Al0xizlp4TLvCB0tgwE YBec6czBhAget2Ghpv8Wc7NWKSHqkuU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-639-AFxiryY_MZGPUqZQQ5mtRQ-1; Thu, 03 Feb 2022 04:39:40 -0500 X-MC-Unique: AFxiryY_MZGPUqZQQ5mtRQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 27BD8100CD02; Thu, 3 Feb 2022 09:39:39 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.193.133]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A2E5106A026; Thu, 3 Feb 2022 09:39:37 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: dkozlyuk@nvidia.com, stable@dpdk.org, Olivier Matz , Lavanya Govindarajan , Reshma Pattan Subject: [PATCH] test/mbuf: fix mbuf data content check Date: Thu, 3 Feb 2022 10:39:12 +0100 Message-Id: <20220203093912.25032-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org When allocating a mbuf, its data content is most of the time zero'd but nothing ensures this. This is especially wrong when building with RTE_MALLOC_DEBUG, where data is poisoned to 0x6b on free. This test reserves MBUF_TEST_DATA_LEN2 bytes in the mbuf data segment, and sets this data to 0xcc. Calling strlen(), the test may try to read more than MBUF_TEST_DATA_LEN2 which has been noticed when memory had been poisoned. The mbuf data content is checked right after, so we can simply remove strlen(). Fixes: 7b295dceea07 ("test/mbuf: add unit test cases") Cc: stable@dpdk.org Signed-off-by: David Marchand Acked-by: Olivier Matz --- app/test/test_mbuf.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c index f54d1d7c00..2a037a12da 100644 --- a/app/test/test_mbuf.c +++ b/app/test/test_mbuf.c @@ -2031,8 +2031,6 @@ test_pktmbuf_read_from_offset(struct rte_mempool *pktmbuf_pool) NULL); if (data_copy == NULL) GOTO_FAIL("%s: Error in reading packet data!\n", __func__); - if (strlen(data_copy) != MBUF_TEST_DATA_LEN2 - 5) - GOTO_FAIL("%s: Incorrect data length!\n", __func__); for (off = 0; off < MBUF_TEST_DATA_LEN2 - 5; off++) { if (data_copy[off] != (char)0xcc) GOTO_FAIL("Data corrupted at offset %u", off); @@ -2054,8 +2052,6 @@ test_pktmbuf_read_from_offset(struct rte_mempool *pktmbuf_pool) data_copy = rte_pktmbuf_read(m, hdr_len, 0, NULL); if (data_copy == NULL) GOTO_FAIL("%s: Error in reading packet data!\n", __func__); - if (strlen(data_copy) != MBUF_TEST_DATA_LEN2) - GOTO_FAIL("%s: Corrupted data content!\n", __func__); for (off = 0; off < MBUF_TEST_DATA_LEN2; off++) { if (data_copy[off] != (char)0xcc) GOTO_FAIL("Data corrupted at offset %u", off);