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 123EA464DE for ; Wed, 2 Apr 2025 01:48:43 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 040CA40651; Wed, 2 Apr 2025 01:48:43 +0200 (CEST) Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by mails.dpdk.org (Postfix) with ESMTP id 4F3A6402B5 for ; Wed, 2 Apr 2025 01:48:40 +0200 (CEST) Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-2260c915749so86386135ad.3 for ; Tue, 01 Apr 2025 16:48:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1743551319; x=1744156119; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lvYRdNiBbR12G/7uful7iL+qWZL+0e30grQmwl2tgHw=; b=Hp/yHcxJkvdg0860s+94T6/YGnkExadDsj7ysORH14cDdfwtZYMYJRIAOJkAjW5fqx uurLfPkFi6vsBwW8rP4+XFuWDZXT4toG/eQZ1BxgM1rKLEsxglIf9lbatubjraEDyMxD unhkMBUgnXuPGMQJWYHNqudSzpRC3S29u4/LUFieU0VirlxRZM36Sr8bGzhBxPFUO7qa 1cgMV/cH5s0iqgoADYtOZIAHy9noaPIaOrysErvpbTIFCR8hrc9ssvTD4QmodPCu2I7L OSS03JqwVIiFYTwal0drysPoyy0/P5GJY1jTZZ1lPzQJqjyVjnUl0rf/33GDvVQDfWH3 FrWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743551319; x=1744156119; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from: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q16qcmK X-Google-Smtp-Source: AGHT+IF6ZAljT5+0hWTrECefpGiRqpLYaGSUFXSIz7hg3NqAwjt4DdqIrdgvUm8u/9FyG7QWouZK8g== X-Received: by 2002:a17:902:e549:b0:223:fbc7:25f4 with SMTP id d9443c01a7336-2292f95d954mr205009615ad.14.1743551319321; Tue, 01 Apr 2025 16:48:39 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2291f1f8bc5sm95135175ad.250.2025.04.01.16.48.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 16:48:38 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , mukawa@igel.co.jp, stable@dpdk.org, Tetsuya Mukawa , Bernard Iremonger Subject: [PATCH v2 1/4] net/null: fix packet copy Date: Tue, 1 Apr 2025 16:47:26 -0700 Message-ID: <20250401234828.10888-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250401234828.10888-1-stephen@networkplumber.org> References: <20250326213608.581345-1-stephen@networkplumber.org> <20250401234828.10888-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 If doing copy on transmit, can potentially copy past the data in the mbuf. Change to only copy data from that segment. Fixes: c743e50c475f ("null: new poll mode driver") Cc: mukawa@igel.co.jp Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger --- drivers/net/null/rte_eth_null.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c index 6764cf2ec1..966748689f 100644 --- a/drivers/net/null/rte_eth_null.c +++ b/drivers/net/null/rte_eth_null.c @@ -35,7 +35,7 @@ struct null_queue { struct pmd_internals *internals; struct rte_mempool *mb_pool; - struct rte_mbuf *dummy_packet; + void *dummy_packet; RTE_ATOMIC(uint64_t) rx_pkts; RTE_ATOMIC(uint64_t) tx_pkts; @@ -163,17 +163,17 @@ eth_null_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) static uint16_t eth_null_copy_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) { - int i; struct null_queue *h = q; - unsigned int packet_size; + unsigned int i; if ((q == NULL) || (bufs == NULL)) return 0; - packet_size = h->internals->packet_size; for (i = 0; i < nb_bufs; i++) { - rte_memcpy(h->dummy_packet, rte_pktmbuf_mtod(bufs[i], void *), - packet_size); + struct rte_mbuf *m = bufs[i]; + size_t len = RTE_MIN(h->internals->packet_size, m->data_len); + + rte_memcpy(h->dummy_packet, rte_pktmbuf_mtod(m, void *), len); rte_pktmbuf_free(bufs[i]); } -- 2.47.2