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 3733F45DA5; Mon, 25 Nov 2024 18:45:11 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DC1A840B90; Mon, 25 Nov 2024 18:45:10 +0100 (CET) Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by mails.dpdk.org (Postfix) with ESMTP id CEFDF40A72 for ; Mon, 25 Nov 2024 18:45:09 +0100 (CET) Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-724e5fb3f9dso2678492b3a.3 for ; Mon, 25 Nov 2024 09:45:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1732556709; x=1733161509; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=EUUQIrj7jlzLK7liZ5+8b1/4ba62rSoRkjcBS5CQTKk=; b=OP3czyEyks9Iysd2BT9VakEgtgk4uXfErkmNQ7Ax2MoOMBGIYADdTZAcJr/qbkTb+7 ohU08pPX2n+PwlPafrlF5xMJSDXGe6xh41kIDzzz/ZYGHBt/aJmPgB/8gpT/zjV4Vv7B 3eo5csipVns2PKzWkqK6B4JS1+1Ebo2JaGpVBjFdQEhkyeJYg6alMrPXI9hmI0JTbYuM IeZlsBIkxII7JHcOLSHRMuvgT0tPgV96K3fI0KuywcPcqOcpXHZpRbKS6yHc1K6C31dJ iaABRM/Pga2aNMS7kHTvDnagaC3psz574oTSK5uHvKxGylCWdlOq6W6oxvnOFfy+V10e LYUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732556709; x=1733161509; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EUUQIrj7jlzLK7liZ5+8b1/4ba62rSoRkjcBS5CQTKk=; b=EbcSynh6kkZE1UBazizQqeK7wifz1ujvpyYq3XlrDW3rY4lv+dhLo5wEUJW9KXRza3 WXy7aEXSIzeKClZ4bMafQ7jCnmOJR/IA9PZpjJhrTv+vI1GCsmA3Ri+R9pFU2Yeexrpy +hyBLZYb4Zxvl62eh+mZ4vHHDbmbD7d17nw08OqmiJWmbFo/R7nb0+yIzqY0eLpG2igC fNYir1f5Oz0P9NPOs2XHcxXpbuepLoKvv0DSiUb3/XO4qwfVEzBukUTsuoCR5V9eGx5R GPAZJkc53Ixn15kKQRrnJ3i5rOziSaq5EZYnnryWIGW8KAhMR2lBdOgf9fkVWvOUvdEl 0hwA== X-Gm-Message-State: AOJu0YwQWUr5e2qcxL+4NDy/h+ei8nWqzmYqTprE3+eHLo8k29IMNkBl 7rnTalS3sI3OvyZHyobful/nc08w6Zb7oe1kKyHIaA1wZRfAgLVcxwatNpWQpxs= X-Gm-Gg: ASbGnctOt6Q/BjU/Vz/c+qQ5+GMSKFTdxTl+i/7yr+UVDIBG+S5Jf2N26tGSxTnXbaE guxlTbqELQYGHirkJlxHNVo5491sdMikvMq5CQdNAwVvInMLFwGSluHOse/R38S9vJHobKZVx5E /AooTk1se46WY7ey63mzBRSfZL+t0t12ePF5qrY15TKJyHdfwhBH0p6elBARPKK5ynw1m0bDC52 Q9jjj7pq0vD8TFA+bjNXjq5e/ulPNB6oiw2UHmQmCDLMFqd4O4Pcij++wuEcY1tdthnDQghM9jO xOY0mqjI2bdhaYRhuLTZ2RggM7I= X-Google-Smtp-Source: AGHT+IE0Fag+j+cccDm3EgGHym6DopouR3NhM2c+7XojUL7BTfxdOtnIm50wy430dukVtktiGJxKmQ== X-Received: by 2002:a05:6a00:3ccc:b0:71e:e4f:3e58 with SMTP id d2e1a72fcca58-724df6845d3mr20018341b3a.17.1732556708832; Mon, 25 Nov 2024 09:45:08 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-724f408e917sm4574456b3a.1.2024.11.25.09.45.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Nov 2024 09:45:08 -0800 (PST) Date: Mon, 25 Nov 2024 09:45:03 -0800 From: Stephen Hemminger To: Jie Hai Cc: , , , , Yisen Zhuang , "Wei Hu (Xavier)" , "Min Hu (Connor)" , , , Subject: Re: [PATCH v3 3/3] net/hns3: fix Rx packet without CRC data Message-ID: <20241125094503.2890b603@hermes.local> In-Reply-To: <20240719090415.1513301-4-haijie1@huawei.com> References: <20240206011030.2007689-1-haijie1@huawei.com> <20240719090415.1513301-1-haijie1@huawei.com> <20240719090415.1513301-4-haijie1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 On Fri, 19 Jul 2024 17:04:15 +0800 Jie Hai wrote: > +static inline void > +hns3_recalculate_crc(struct rte_mbuf *m) > +{ > + char *append_data; > + uint32_t crc; > + > + crc = rte_net_crc_calc(rte_pktmbuf_mtod(m, void *), > + m->data_len, RTE_NET_CRC32_ETH); > + > + /* > + * The hns3 driver requires that mbuf size must be at least 512B. > + * When CRC is stripped by hardware, the pkt_len must be less than > + * or equal to 60B. Therefore, the space of the mbuf is enough > + * to insert the CRC. > + * > + * In addition, after CRC is stripped by hardware, pkt_len and data_len > + * do not contain the CRC length. Therefore, after CRC data is appended > + * by PMD again, both pkt_len and data_len add the CRC length. > + */ > + append_data = rte_pktmbuf_append(m, RTE_NET_CRC32_ETH); > + /* The CRC data is binary data and does not care about the byte order. */ > + rte_memcpy(append_data, (void *)&crc, RTE_NET_CRC32_ETH); > +} > + There is a bug here. If there is no space at end of mbuf (tailroom) then rte_pktmbuf_append will return NULL. This would only happen if mbuf pool was sized such that there was space of a full size packet without CRC and then the code to add kept CRC was executed. You need to check for NULL return and figure out some kind of unwind path such as making it a receive error and dropping the packet.