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 48DE8A00C2 for ; Thu, 3 Feb 2022 10:39:44 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4432340140; Thu, 3 Feb 2022 10:39:44 +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 3863F40140 for ; Thu, 3 Feb 2022 10:39:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643881181; 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=OqzPiDukebT7QbHDzZTRNZ0eQSTtDJnmlp736/qBoJ6adApt/zuDxTw72c3NRkI1tzOn6G G8vzTmVP4C/NDxmdS7MVU1xZBSmO1qDQ/sFAnPHY+9WKL6YilLmX+/gOe+RSru7TOdCQfH JbktImSKJj1mmamHENSBtFW+1tk32ZY= 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 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" 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 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 --- 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); -- 2.23.0