From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A5093F0A94 for ; Mon, 25 May 2026 15:28:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779722930; cv=none; b=nbTdqh3YrHaBK/gmerTCjqy6rDvQjXX+0cb0RUJYOc+9brJAOaCns4r/MOB5LdJYVJjRkFfhFytgSNheQQKPZTgiMLkne66HaXxOT1QgASKQ3hLfKY2Je93MRbdEXvDbcVs9e4MWngTQbOrpw6fClqfdvlkDiid2CxCmGrcUASs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779722930; c=relaxed/simple; bh=GOVP3GMXI6e3nmcvhFapqkltBbBYJYx9rhPAYRvjY/E=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=BfEBGFk4SsW3+7vOjjqzgEoPiGtuz0FaTddW9Qd5xc46eQbYNh4QUa/Sa5RHF0gQLJ3x7yTRg/HONO1jozdL4mnXNe7v1wLukszmYPm+DMnJ5mvM/acdUcKQRPtZALccAG8v5EFVhMBdUcVTaIeo2JlrjK1xGQH5koYpYNEmpUQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-49041fb8c23so26178975e9.0 for ; Mon, 25 May 2026 08:28:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779722926; x=1780327726; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9DXGt1MHlBlB682MDc2YdgnoSfbUc4QharEAHt1q++E=; b=XMiZZoR+EhM8RPEmRgS0vTMaOTWIhkbQYhojoSxMVKIHOzOP/Iy60wZi2yYPBdfCh5 HskBip9I3URUdTSrrwJHSwyhcbAFxpKM8Uovu84BNqmZrNesrPOjiJx0tqTvbQNNt/DJ iUu7ZhgGmVFfMBnaLCYnk0i7hT5ApBwmDGJE2m4OPOY1wAY3Ye8ksNraRuDIQnoTPXtT bQY3h2LP+9ZaJ1FgPikLkc1b6GESmEODqxx5xsUDnRp3f/oUMu2TLvPU+AiHV/wWNAKu mk6UPsLwQ2kUuTElwicZ2tV5wAtYHCzZeXyYFcX1enGJfqajh12Hlbwf49sWHrvhO+B+ k9qA== X-Forwarded-Encrypted: i=1; AFNElJ8lO4ld9NIaX+r4zpltMDn+goFn9S5KZECZxD+pu2sE5UFQMdbYnPCiGqrSGH8ipurdKDDGYwYjNb3h4P8=@vger.kernel.org X-Gm-Message-State: AOJu0YwLWkULTc+JYSfMZ8KvXO71vssAtCpOLgXJkPmDGp0k/Q66u1K/ hxSbGPRenOiMxSbXFQ13cc679FOImp+Piaa0iOUruiakSEUkd9rmIJNRjus2YxdS X-Gm-Gg: Acq92OGz+5aeyVU/dqcQ1rlybzH7jmQzJqW3Ae3wdERe+SuzNWiNRqkPz0t9ctlj0ff yDIWpWsdRM752onW/6NuQIKFIGGmNDLCF0GqYK8v2+wvQ3jgdqDt82ptJP/8h2BEJbBK41lVwct 8eLJB2aV0jA02dFgf1fv776cT4QakFB3g/OVeUhswn31M5RaYg0aycAqzWTUFQQXtDtCR5/CiGF adNwhjBxJ9E5VQfjI0//mQKySsg/pAYyeuosoOuHgzZXU7+li0lRUeo+Oa56I96xu5YHnSxy5PG VUgmfHXhk7+663yKgZBPFavpJGxpdKqQYAjX6FCd62y4Evo+H2YC31kbp4NGBnr91QNQMXP0teg UGsDwse7Psgp2KgOYMVfMe7A40jlsQNVSlHiYuSOge0yAFahKXmmpYwCGMOpl2MNLL598WKiGKv KFk3U0zEO1nk/43/fH5ohIh5SEXMJWoJE= X-Received: by 2002:a05:600c:8599:b0:48a:525b:e148 with SMTP id 5b1f17b1804b1-490424ac7ccmr180474405e9.4.1779722926359; Mon, 25 May 2026 08:28:46 -0700 (PDT) Received: from gmail.com ([62.197.47.167]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49042cebaaasm89265365e9.36.2026.05.25.08.28.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 May 2026 08:28:45 -0700 (PDT) Date: Mon, 25 May 2026 16:28:44 +0100 From: Breno Leitao To: =?utf-8?B?QmrDtnJuIFTDtnBlbA==?= Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Mina Almasry , Willem de Bruijn , Kaiyuan Zhang , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net] net: Avoid checksumming unreadable skb tail on trim Message-ID: References: <20260522120643.242974-1-bjorn@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Mon, May 25, 2026 at 01:18:51PM +0000, Björn Töpel wrote: > On Fri, 22 May 2026 at 17:39, Breno Leitao wrote: > > > > On Fri, May 22, 2026 at 02:06:40PM +0200, Björn Töpel wrote: > > > pskb_trim_rcsum_slow() keeps CHECKSUM_COMPLETE valid by subtracting > > > the checksum of the bytes removed from the skb tail. That assumes the > > > removed bytes can be read. > > > > > > io_uring zcrx skbs may contain unreadable net_iov frags. With fbnic > > > header/data split, small TCP/IPv4 packets can carry Ethernet padding > > > in such a frag. ip_rcv_core() trims the skb to iph->tot_len before TCP > > > sees it, and the CHECKSUM_COMPLETE adjustment then calls > > > skb_checksum() on the padding. > > > > > > This is exposed by IPv4 because small TCP/IPv4 frames can be shorter > > > than the Ethernet minimum payload. TCP/IPv6 frames are large enough in > > > the normal zcrx path, so they do not hit the same padding trim. > > > > > > Keep the existing checksum adjustment for readable skbs. If the > > > remaining packet is fully linear, drop CHECKSUM_COMPLETE and let the > > > stack validate the packet after trimming. If unreadable payload would > > > remain, fail the trim; the checksum cannot be adjusted without reading > > > the trimmed tail. > > > > > > Also clear skb->unreadable when trimming removes all frags. > > > > > > Fixes: 65249feb6b3d ("net: add support for skbs with unreadable frags") > > > Signed-off-by: Björn Töpel > > > > Reviewed-by: Breno Leitao > > Thanks, Breno! > > > > +static int pskb_trim_rcsum_complete(struct sk_buff *skb, unsigned int len) > > > +{ > > > + int delta = skb->len - len; > > > > I suppose this is not unsigned/size_t because csum_block_sub() requires > > an 'int', is this right? > > Yup, both skb_checksum() length and csum_block_sub() offset are int, > and it also keeps the existing parent function's local type unchanged > after the move. > > > > /* Note : use pskb_trim_rcsum() instead of calling this directly > > > */ > > > > I think you can make this a one-line comment, or just a proper kdoc. > > Yes, but note that this was not an addition from me. I can fix it up > if there are more changes required! oh, nevermind. I misread it. Thanks