From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=182.48.54.220 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796356902; b=H3KeZdzmIOfaX8kus0+SmNHmICGGOM2b1MyrpJlIO4pa+r4MGXhfVmHs1BAwF78AFQVs mE613xLvnerDB7LGyxO9viGnngmuYgdiuUPfJjJ064ADqVzyj8/tAuoEu/NHL1vRwTn/B ghw1z7VUQE+OrzJRrTZKTI6qfgCfsTSgNF852H3fi4CMUptkVkxpeWjGNAPspdGwqCOyR LdQENpVYvCHf7ZNO7BjngGU4L3npP+E+WgTgqs/3Qa+e1ZeefxFRtyWz3k89TPRwZlWIo HCNaNyE1KcRxEf2tq1157RROcZYmX/quo1wvPWQOgFioEKIw/crHVTQQEZmWQBelLRA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796356902; h=DMARC-Filter:Received:From:To:Cc:Subject:Date:Message-ID:In-Reply-To: References:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=oMH2qyDlUTDFdNpXd9VdB/jN7L51B92pLjaAlx20g40=; b=JvHA63RisRoMcrliumTum0CLxhGsKNR2qCoMqSVj0KqVlTUylMpNjfdFZI8gEuSYXSA9 6qr4CTo/DwZLhWDnytBfNXoazXHGvvVGp8hwOPsm4MPZggOUz9gTrL/aYuF4lFa+0qk1o FLlEoV46ujEO2UhvlYqXlgG3V2yS5yyRun9YMpdiAWqo/cY5dqy0WrrnkRGYJBnct2h7W BD5TubgIBdJ+6JWi727+buxTPRLu6BxCMDhIY7jpzHiDcLBDsOhcKoFRFBuVX4qgU1XTb QYFZyHVexJgBu0whkGijmMzXelmklkDIgFUvzB6HtIg2opDk2zHxM/hnZy5axcB3Y8g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=snowrabbit.org; spf=pass smtp.mailfrom=snowrabbit.org; arc=none smtp.remote-ip=182.48.54.220 Received: from bambi.snowrabbit.org (bambi.snowrabbit.org [182.48.54.220]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 16465606A32D; Fri, 4 Dec 2026 04:01:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 16465606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=snowrabbit.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=snowrabbit.org Received: by bambi.snowrabbit.org (Postfix, from userid 3001) id 17D04C9331; Fri, 4 Dec 2026 13:01:40 +0900 (JST) From: Showta Ishizaki To: Michael S. Tsirkin , Willem de Bruijn , Jason Wang , netdev@vger.kernel.org Cc: Eric Dumazet , Jakub Kicinski , Paolo Abeni , David S. Miller , Andrew Lunn , Simon Horman , Eugenio Pérez , Xuan Zhuo , Richard Weinberger , Anton Ivanov , Johannes Berg , Jonathan Corbet , Shuah Khan , Randy Dunlap , Chris Arges , Paulos Yibelo , Björn Töpel , virtualization@lists.linux.dev, linux-um@lists.infradead.org, linux-doc@vger.kernel.org, Showta Ishizaki Subject: [PATCH RFC net v11 2/6] um: vector: trim skbs before verifying the header Date: Fri, 04 Dec 2026 13:01:23 +0900 Message-ID: <20261204.rfcv11.99731.2.zakinko@snowrabbit.org> In-Reply-To: <20261204.rfcv11.99731.0.zakinko@snowrabbit.org> References: <20261204.rfcv11.99731.0.zakinko@snowrabbit.org> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: Michael S. Tsirkin The vector receive path over-allocates the skb and only trims it to the received length after the transport header is verified. A follow up patch will complete the packet checksum in software within virtio_net_hdr_to_skb so we need the packet trimmed (otherwise the checksum would be computed incorrectly over the unreceived tail of the buffer). Trim first, so the import sees the packet as it was received. Reviewed-by: Willem de Bruijn Signed-off-by: Michael S. Tsirkin Signed-off-by: Showta Ishizaki --- arch/um/drivers/vector_kern.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c index e902e78c5ff6..828bd61995b8 100644 --- a/arch/um/drivers/vector_kern.c +++ b/arch/um/drivers/vector_kern.c @@ -873,6 +873,7 @@ static int vector_legacy_rx(struct vector_private *vp) if (skb != NULL) { if (pkt_len > vp->header_size) { + pskb_trim(skb, pkt_len - vp->rx_header_size); if (vp->header_size > 0) { header_check = vp->verify_header( vp->header_rxbuffer, skb, vp); @@ -887,7 +888,6 @@ static int vector_legacy_rx(struct vector_private *vp) skb->ip_summed = CHECKSUM_UNNECESSARY; } } - pskb_trim(skb, pkt_len - vp->rx_header_size); skb->protocol = eth_type_trans(skb, skb->dev); vp->dev->stats.rx_bytes += skb->len; vp->dev->stats.rx_packets++; @@ -989,6 +989,8 @@ static int vector_mmsg_rx(struct vector_private *vp, int budget) for (i = 0; i < packet_count; i++) { skb = (*skbuff_vector); if (mmsg_vector->msg_len > vp->header_size) { + pskb_trim(skb, + mmsg_vector->msg_len - vp->rx_header_size); if (vp->header_size > 0) { header_check = vp->verify_header( mmsg_vector->msg_hdr.msg_iov->iov_base, @@ -1013,8 +1015,6 @@ static int vector_mmsg_rx(struct vector_private *vp, int budget) skb->ip_summed = CHECKSUM_UNNECESSARY; } } - pskb_trim(skb, - mmsg_vector->msg_len - vp->rx_header_size); skb->protocol = eth_type_trans(skb, skb->dev); /* * We do not need to lock on updating stats here -- 2.54.0 (Apple Git-157)