From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (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 45DD633FE33 for ; Sun, 12 Jul 2026 17:06:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783875998; cv=none; b=HrUyAGYVdJ8XlS0qhQ8QT6xPFfy8RI26gqfDitqCx8ku0lHvyTvNvUgmkTnyb0N6AhzFFMkQqHahM9SmLQ8XMBDlh+hzYgK3bf+SWJtIQtMAwekBoF51m3TeQhjzQUC8nuCRacu5ON5nlcZ9hWxL+FUgOCmHeXBHuxDgefcBdZo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783875998; c=relaxed/simple; bh=tQc3GsHvQ2l0tz/sTfSyc6jajgFFUOoFLxxSIunWJ5Q=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=gecgzAcT+NKk637UtPL0/YLZM5XC3vvP0RVOTRD6TbLFHuqrfFqTh74HR2TOs71L8wcoRnl0XWdHm8XEJIZgMlOVHEF5qWS/CX7UFaF8HvYEoAsMrL9TX7kzD+24n+9M/ksql651p5Pqmn2nx6hwATiRYwdwQoGBMM+o6wAQSJw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GpfP7QT9; arc=none smtp.client-ip=209.85.221.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GpfP7QT9" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-4759b4f0897so1238465f8f.1 for ; Sun, 12 Jul 2026 10:06:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783875995; x=1784480795; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=0QQfzxK9tzF0roqEsRb+w+5ov6uEaOi+zluBo1NJdho=; b=GpfP7QT9RRzMkIdTHcKFqATMPtSWKQOvl5Fa/P+x2t0Wx7upUFV6GOqwpf4rEt7xQh H6sCMkuOAicHB1tqsDC7IZq9/UcqXWSXTYUTth2J+DjYeXxiXaF+EpAmGmGs2TBx256d NIgQ521RBjc6EXDLR+VY6JwMNh+/goxoTz9o6WJEgzCP/nX58PYt2vTxZIe9YXk86OIG 2Ee0xUfCwRBCMeCD/auYhM0hwJvck8yQx/y5A9DHYJ7ordojZK6e0wZwDb7jQ6tMH1qq Zfd2lNG7C+th3zuNt6A8yFUuG7hAN08rgvUVG0gQY/2aXF/MrCtDuUFtxS6VYvBPTagY qCWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783875995; x=1784480795; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=0QQfzxK9tzF0roqEsRb+w+5ov6uEaOi+zluBo1NJdho=; b=Pjb0BHwY2Ig0+lEDzHVltKruCJlkJxPZsR9xW4UaaVp3lyG95hmPX+dJzp7uFXPt0D dl0FjWzflVRj/jl7K+1X1pYXsv5vZdpLV4VxR7qY4EpMetvqmMLxo0nzSyIgQqidxU8f Zn8SBAFOcX+c3pvb2XamM5/CLcSqQayUEcim+TXWNwulGtwJZ5bgEGyyKqGjrxooP9Eq GsJ+x86uYoCs3N044vO8/OYAjtj77M/tCY3oKtCgPpxruK5G+RGZ0KyAzfc8NBf3TAEl ZexqYKE5FHdegVKcfMD+OrFuE9ogkmvaecayYpnYlbX8/cbHslOPLFWlGAtb1zRLfnY3 3T5w== X-Forwarded-Encrypted: i=1; AHgh+RrFBvT7kjVQNkqnjpxkl86I+3qymChS+dTJY+0OUbG3ZxkFCMSuCmvnCHKXEb829rM/aLUcGBj5BVtkhlE=@vger.kernel.org X-Gm-Message-State: AOJu0YwnfSKZOzCwnRY4XoIV46tZCZVVB7AnaF5s+CxDIxmoVfy9nw8X TJHI3lRhCYlX6kia3XZpgnqo280aDz1YZYxL1LpwriRXXFcBdGid71Ky X-Gm-Gg: AfdE7ckXZzzQrJJ8LJLV36Q4LNYmCMcXJcCRFKM/yEStYM/qj/V2Y32qu536SPrNfF7 kZAI8M51uAGWPIqVxURl9OgQGsG43Mw+QETrDydXndOBKtF+iIcLkOdAXVPknf5OgHVR3rjjK63 tMdyom79+g0ACfiEH0qlT2fld0YeaRA5Zg3a/EwWRYtWB79DIOEQw+tAwhPAr5UVuTM1NriVkbU 4g37VunkGbgLU8adK99ZTGjlH5EHhp6X56THB9xYn2zBhaFP/B7v0FxM+nVuJrKadFByA1FXbma 7MGDdzyRCZtnrMhwdnXIbbpU8DsUE3FqcPP/l1TyMdVrU/48e6hUg5D81hIMTRWZqp1bkeBKaes dBJ8BA9Iao14gFYBYizkq98RUDR6JiPR3qFO1APAXTfA2Ar6D5WJBTY+HoAANlbaN09MRAT2KWe yXrMccDq1Gx1PP/68G3Q== X-Received: by 2002:a05:6000:4283:b0:47d:dfea:f733 with SMTP id ffacd0b85a97d-47f2dc8d7ffmr6928404f8f.3.1783875995378; Sun, 12 Jul 2026 10:06:35 -0700 (PDT) Received: from maher.. ([105.154.180.73]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47a9e4d8410sm78640357f8f.15.2026.07.12.10.06.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2026 10:06:34 -0700 (PDT) From: Maher Azzouzi To: steffen.klassert@secunet.com, herbert@gondor.apana.org.au, davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, w@1wt.eu, linux-kernel@vger.kernel.org, Maher Azzouzi Subject: [PATCH net] esp: do not unref managed frag pages in esp_ssg_unref() Date: Sun, 12 Jul 2026 18:05:30 +0100 Message-Id: <20260712170530.9807-1-maherazz04@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit esp_ssg_unref() releases the page references held on the source scatterlist after the AEAD operation completes. It calls skb_page_unref() on every frag page for an out-of-place transform (req->src != req->dst), and in the error path of esp_output_tail() (already_unref == true) on the request's own scatterlist. This is wrong when the skb carries managed frags (SKBFL_MANAGED_FRAG_REFS). Managed frags are owned by a zerocopy ubuf and the skb does not hold a per-frag page reference; io_uring SEND_ZC with a registered buffer attaches the bvec pages this way via io_sg_from_iter(). The rest of the stack honours this invariant: skb_release_data() skips the per-frag unref when SKBFL_MANAGED_FRAG_REFS is set, and skb_zcopy_managed() is the guard used at the other unref sites. esp_ssg_unref() is missing that guard, so for a managed-frag skb it drops a page reference the skb never acquired. This can underflow the page reference count and free a page that is still in use. Guard the function with skb_zcopy_managed() so both unref paths are skipped for managed-frag skbs, matching skb_release_data(). Fixes: cac2661c53f3 ("esp4: Avoid skb_cow_data whenever possible") Fixes: 03e2a30f6a27 ("esp6: Avoid skb_cow_data whenever possible") Signed-off-by: Maher Azzouzi --- net/ipv4/esp4.c | 7 +++++++ net/ipv6/esp6.c | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c index dfc81ee..fa1710e 100644 --- a/net/ipv4/esp4.c +++ b/net/ipv4/esp4.c @@ -104,6 +104,13 @@ static void esp_ssg_unref(struct xfrm_state *x, void *tmp, struct sk_buff *skb, struct aead_request *req; struct scatterlist *sg; + /* Managed frags are owned by the zerocopy ubuf; the skb holds no + * per-frag page reference, so we must not drop one here. Mirrors + * the SKBFL_MANAGED_FRAG_REFS handling in skb_release_data(). + */ + if (skb_zcopy_managed(skb)) + return; + if (x->props.flags & XFRM_STATE_ESN) extralen += sizeof(struct esp_output_extra); diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c index 296b579..7d216b9 100644 --- a/net/ipv6/esp6.c +++ b/net/ipv6/esp6.c @@ -121,6 +121,13 @@ static void esp_ssg_unref(struct xfrm_state *x, void *tmp, struct sk_buff *skb, struct aead_request *req; struct scatterlist *sg; + /* Managed frags are owned by the zerocopy ubuf; the skb holds no + * per-frag page reference, so we must not drop one here. Mirrors + * the SKBFL_MANAGED_FRAG_REFS handling in skb_release_data(). + */ + if (skb_zcopy_managed(skb)) + return; + if (x->props.flags & XFRM_STATE_ESN) extralen += sizeof(struct esp_output_extra); -- 2.34.1