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 1FF5945D5D; Thu, 21 Nov 2024 00:06:48 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3DBC6402E7; Thu, 21 Nov 2024 00:06:47 +0100 (CET) Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by mails.dpdk.org (Postfix) with ESMTP id 40BCB40296 for ; Thu, 21 Nov 2024 00:06:46 +0100 (CET) Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2128383b86eso2252255ad.2 for ; Wed, 20 Nov 2024 15:06:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1732144005; x=1732748805; darn=dpdk.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=CGGheR+LvlJBzTceiiZla45ZTeAOrl8fH6b8WKSG/A8=; b=leB/izkE07U1aT6c8B2NPtGu85YQQti1NKDD+l/eGr7eC/K6DBr8SIiYME2mw9BRhw hdI+2tfAhQUZHoHUKosjr+kyk8t2GdBp/xtOYyCEHkwxYuAw7TXz4Gf6+68enAwSK1S4 OxYjdx9JBXW1RcudN/HgPNtCQezewBN1iAHoR+g0gOGr5Cl7BpY4BCTP8mVAlz8rrK/P QN6dNLHqBMmDVbHNnrFrOvLiJU7YZlr4H8oftclLrRZyFUpKOGhSv0LPMADZMKrJlS+Y 1bIDS8Bfw1NWHHdSjx7K6Zp4durbxSAURFcH1sMqi9fR7JZB6gnlPOnX6f5ZToJA/y4Q H7kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732144005; x=1732748805; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=CGGheR+LvlJBzTceiiZla45ZTeAOrl8fH6b8WKSG/A8=; b=qZCqFbS/WsTXxi4rRXnRkoEsXJ5CVznTLlsSUDMenPTT5yl42Ix7W2oww05woHntSU Bi9euoGpw/3/Ckmsw2K+XgRWg6IuRU15AsX6poGgksCm5Z+RFtHvGv81xNeqvMg5gllp XWhxaE13plmGWklAGF2VKgk1/hTw5EnTJaNVvaX8jipn+b2pm+E5SwxaMnF0yX9XPqP1 nbrRYDnWw9TMIlYDXs49dfd4WJf+bD1ymJuMPFyR8nJA396fnYc7AwxAzuKGCrTK63yP GXn/YYF3qOwE4bmrkOMYg1zHxOMPH3IH8lgh0tP01z86QPemkGZ08ANsPtH1YU0TdX+E pCVw== X-Gm-Message-State: AOJu0YweoUM7lmidOBBLmeh0cawLwdmeXSz3JKI1lxx2ZPfyVaDNTKFt mKHBX1VUfVAbPeOXrb8IlspKHlGDJ8PxoRaBUYu+Vb+eeyIDRYC50jt2drxJ8jNbKOly5xnaKnT X X-Gm-Gg: ASbGnct33eqmwthno6h4Se4bQJpB7Q4NeVqx1X5Puebp55CX1mVldzbvyZrxULFLid+ N+W4GvuJHYtqzR8o1w48ogPs50lVd1te5JLllXU34vrf1luaAPIDhUnHkVmXaSyKwrIkdjGxBSb bYTb+SoFTnRPGnkVHtM8JgAsEJA10U4/6AU9MRS0MHNK6PmaEMmvEcksti1C71PXzZ5jn5oY1j8 TaEBGw/E5F4jROx0GnuptqyN8nVktIV9++MPwqr7pRJ1w67ntILeqWlChcQ1UNgpfN4PzDkkUAw 0LrqNVhoHrdcGJy18ovQ8vSTfTo= X-Google-Smtp-Source: AGHT+IGojbhLTakd1GFcdujhqrw+DQ5/ydGWe6R6lPReoXqE+8oCql1KFz0LuXYBhQIgV5t+/5tiaw== X-Received: by 2002:a17:902:e842:b0:20c:e6e4:9daf with SMTP id d9443c01a7336-2126c0e07b7mr51183545ad.13.1732144005304; Wed, 20 Nov 2024 15:06:45 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21287ee3925sm898495ad.115.2024.11.20.15.06.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2024 15:06:44 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH] pcapng: avoid potential unaligned data Date: Wed, 20 Nov 2024 15:06:35 -0800 Message-ID: <20241120230635.217981-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 The buffer used to construct headers (which contain 32 bit values) was declared as uint8_t which can lead to unaligned access. Change to declare buffer as uint32_t. Signed-off-by: Stephen Hemminger --- lib/pcapng/rte_pcapng.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/pcapng/rte_pcapng.c b/lib/pcapng/rte_pcapng.c index e5326c1d38..16485b27cb 100644 --- a/lib/pcapng/rte_pcapng.c +++ b/lib/pcapng/rte_pcapng.c @@ -33,8 +33,8 @@ /* conversion from DPDK speed to PCAPNG */ #define PCAPNG_MBPS_SPEED 1000000ull -/* upper bound for section, stats and interface blocks */ -#define PCAPNG_BLKSIZ 2048 +/* upper bound for section, stats and interface blocks (in uint32_t) */ +#define PCAPNG_BLKSIZ (2048 / sizeof(uint32_t)) /* Format of the capture file handle */ struct rte_pcapng { @@ -144,7 +144,7 @@ pcapng_section_block(rte_pcapng_t *self, { struct pcapng_section_header *hdr; struct pcapng_option *opt; - uint8_t buf[PCAPNG_BLKSIZ]; + uint32_t buf[PCAPNG_BLKSIZ]; uint32_t len; len = sizeof(*hdr); @@ -212,7 +212,7 @@ rte_pcapng_add_interface(rte_pcapng_t *self, uint16_t port, struct pcapng_option *opt; const uint8_t tsresol = 9; /* nanosecond resolution */ uint32_t len; - uint8_t buf[PCAPNG_BLKSIZ]; + uint32_t buf[PCAPNG_BLKSIZ]; char ifname_buf[IF_NAMESIZE]; char ifhw[256]; uint64_t speed = 0; @@ -330,7 +330,7 @@ rte_pcapng_write_stats(rte_pcapng_t *self, uint16_t port_id, uint64_t start_time = self->offset_ns; uint64_t sample_time; uint32_t optlen, len; - uint8_t buf[PCAPNG_BLKSIZ]; + uint32_t buf[PCAPNG_BLKSIZ]; RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL); -- 2.45.2