From: Zhiling Zou <zhil…@nebusec.ai>
ipcomp_post_acomp() allocates order-0 pages for decompressed skb
fragments, but on input charges truesize by the decompressed byte count.
When the output ends partway through a page, the unused tail of its final
page is not accounted to the receiving socket. Repeated IPComp packets
can therefore retain more memory than the socket receive-memory limits
charge.
Round the decompressed length up to page size when charging input skb
truesize, matching the pages attached to the skb. Leave output accounting
unchanged.
Fixes: 7d7e5a60c62e ("ipsec: ipcomp - Decompress into frags if necessary")
Cc: stab…@vger.kernel.org
Reported-by: Vega <ve…@nebusec.ai>
Link: https://bugtracker.nebusec.ai/f/13830
Assisted-by: LLM
Signed-off-by: Zhiling Zou <zhil…@nebusec.ai>
Signed-off-by: Steffen Klassert <stef…@secunet.com>
---
net/xfrm/xfrm_ipcomp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/xfrm/xfrm_ipcomp.c b/net/xfrm/xfrm_ipcomp.c
index 671d48f8c937..c2cc88c8c360 100644
--- a/net/xfrm/xfrm_ipcomp.c
+++ b/net/xfrm/xfrm_ipcomp.c
@@ -67,7 +67,7 @@ static int ipcomp_post_acomp(struct sk_buff *skb, int err, int hlen)
/* Only update truesize on input. */
if (!hlen)
- skb->truesize += dlen;
+ skb->truesize += PAGE_ALIGN(dlen);
skb->data_len = dlen;
skb->len += dlen;
--
2.53.0