Re: [PATCH ipsec] xfrm: iptfs: make room before copying a continuation in reassembly

From: Andrii Tereshchenko

Date: Fri Nov 20 2026 - 11:21:06 EST


On Fri, 20 Nov 2026 12:18:09 +0100, Fernando Fernandez Mancera wrote:
> This commit message is too verbose IMHO. It is quite hard to read and
> understand.

Agreed - I will shorten it.

> Manually accounting room and need allow us to perform a single
> allocation but I do wonder, is it necessary? This is a very specific
> case.. maybe we can just call skb_linearize() first and then check the
> if there is enough tailroom and perform pskb_expand_head() if needed.

Agreed. In my tests regular traffic (HTTP, ssh, scp, ping, UDP on six
NIC drivers) never took the second allocation; only packets arranged
for it do. There it costs one more reallocation and copy, but the code
reads better. The first version of this fix did what you describe. For
v2:

--- a/net/xfrm/xfrm_iptfs.c
+++ b/net/xfrm/xfrm_iptfs.c
@@ -909,7 +909,15 @@ static u32 iptfs_reassem_cont(struct xfrm_iptfs_data *xtfs, u64 seq,
iptfs_skb_can_add_frags(newskb, fragwalk, data, copylen)) {
iptfs_skb_add_frags(newskb, fragwalk, data, copylen);
} else {
- if (skb_linearize(newskb)) {
+ /* A newskb started by iptfs_pskb_add_frags() has little
+ * tailroom after linearizing. Make room for the rest of
+ * the inner packet before copying.
+ */
+ if (skb_linearize(newskb) ||
+ (skb_tailroom(newskb) < ipremain &&
+ pskb_expand_head(newskb, 0,
+ ipremain - skb_tailroom(newskb),
+ GFP_ATOMIC | __GFP_NOWARN))) {
XFRM_INC_STATS(xs_net(xtfs->x),
LINUX_MIB_XFRMINBUFFERERROR);
goto abandon;

Thanks for the review.