From nobody Mon May 25 08:11:31 2026 Received: from mail-qv1-f50.google.com (mail-qv1-f50.google.com [209.85.219.50]) (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 A9D443E00A2 for ; Fri, 15 May 2026 15:45:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778859947; cv=none; b=GWkRUI0xubrYsGGa7xeIKLKIn8RUdSp90aYZLto+EtyUrrIJnH28fo/7+DrOyfjSwgHabC8VDZaguaXsdU9e6oLczxWJ9F7V5H1vbxhPd8l0rW2WmOas2cjXw3165bhKNiXtHnRGawIj4f7iUmOiNSsU7EE83z7yVPQ5Xlb6aNw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778859947; c=relaxed/simple; bh=iThSfm4s67Ja6SUjf+5sNa7Pxnv8T1K1Ykg9BGBvQ9w=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=V0h6Ev3cp1UNLirreVGQ+XtjF2fRoVtf3mO7Fu1K3pQClKeO2yIZyM9iUGu3f63d1DogSd8plGACbP9BOaa1Knd1f5VR/U5ZRJibvx8K9DOl+nEQ2kjQORqvFRvcxXzYJqFVlwrrCKxUOfwlfd0xY4gQ6CUl2qRNCSrIxmI9Rb0= 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=mqVo+vXW; arc=none smtp.client-ip=209.85.219.50 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="mqVo+vXW" Received: by mail-qv1-f50.google.com with SMTP id 6a1803df08f44-8bb4e8a5240so102836996d6.1 for ; Fri, 15 May 2026 08:45:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778859945; x=1779464745; 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; bh=CeihbjahaamDWkZJ8szFGyTV5a8HEDtn6uzHSf+RP9Q=; b=mqVo+vXWbavbHFjdeiKM0lAEC1XftkCw354ai4jusQ9IScKj5sxpber3ra4/FZv7wL RuDd50nBRG6uDQrZJZkwuQVy0xcsLREUtyWWIOFJ9mNfwMB4hRUz0Vk1dW0gwCDgHgLu C3Mj0o6Y/PvgHgwfdLMNFVk6EP5qb7JD565Hzcz5va8lMIqNy8I2QqGa7aUwOJPaEQ95 ma3UWDMaVK+Fa0/A8cNG2uEh1YbswUfjF5DzmwWpx7d4XODx8KZ6S2DLmS/zzYFtMcnM GsmYpQn/szMmHdSFBIhmcccTuPS5QL59aGUJvLIjOAYRdS1ZOnzV+I1IOBfXgJX9npYT Pwng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778859945; x=1779464745; 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; bh=CeihbjahaamDWkZJ8szFGyTV5a8HEDtn6uzHSf+RP9Q=; b=nDtoWlACM3DSix5rZN/au/DOWW++xbWLf1VjT15sXzTGgbleG9FHYfB4Vc2kZ1/N26 DrReaZ+kND7/8nC1fnu/phzGUNjy7+eM0AHjX3pleiqRbZKQRwtlXkSbirSmfCZcYNzh xDZvpN5FMQ2kyyEXt7ebDCd/Bg6IouU+A33KtqkqBbw1PXyH2MfceParoiECBa9IOhTX KDMprN0NNLolOxM4YIq7TFT4xPlOnUuKX8F/r3jVFmm2X+bIN/+8KDxkrAY/lOAXkNLa FHP7rDtu4gnl6HZkRdBjobklfCkE8zk30cb3/+N1ew2Dm8MTD7AqqZMNVded8VOt4ULB wxOQ== X-Forwarded-Encrypted: i=1; AFNElJ9jF/gVO7EUPBlrEEZrpzBNkM6P72pSq342wPf4aunAYUeAP14D3CAf7CK6HgXaE69tnP70pUYublDc2K0=@vger.kernel.org X-Gm-Message-State: AOJu0YwEFtu6EDbb60NoArPXntey8hsyZn7JEW5M4blBLY3x+0XlN3c4 3P5lsQG4cE0CkSxJosFp9Po7zh049Vi4ZRMx2IPjm8hsnCxc0T7i8Oxk X-Gm-Gg: Acq92OH2ps02//WrbmJGehJiY59yGRN5tFQWftciHQFL4woC7VL46QFWs03cyehhv4K +1LpMdlQeQnTMO1CZFoRgll6oCfVT0QCQdKE6DCXeUJrJBlCQbIiyYRNX8zPmSha7tYKSe0dMDm w7JTXaex2hCRzcx20e9s1gw8d5zXg1jEjQVvmriJEpTvgLZgPlWl/yAqJHUNDzAKeQd7KRAEzC1 /170+MV9dPv+8mDcO1bMVUJUgY3wv0v+8ewzHZeNQrLXcDfU9cN2ybtIu42TwTEA5zj+6PKD/oD AJ45Jt2dlNgpxEzgvuzQwFXAsuqpj/fS66f2qB2kufdwTROmEGkyoCux44n6XOdIH3ygfvyNf+i 1ehAmUAXIXdXH2kD+rL0qUjluA41dLzNGyRKhFfrMGsh3BBgd9b+JXRLlQ3PDtydYt4AkQmqm+/ 1fxArltuz1E/o0IUNkOuJBKtLsunXoZm+B4Z527GrK7fiBj8Bibj8yfpnAHkJyVGro+mUeU5Xq/ WiK39wXp9PLuZ4rmd8gRjOzEtKBHcJ3kVDtgcXO9kA= X-Received: by 2002:a05:620a:2685:b0:8cf:ed8d:20a3 with SMTP id af79cd13be357-911cef0365amr728861885a.42.1778859944579; Fri, 15 May 2026 08:45:44 -0700 (PDT) Received: from server0.tail6e7dd.ts.net (c-68-48-65-54.hsd1.mi.comcast.net. [68.48.65.54]) by smtp.gmail.com with ESMTPSA id af79cd13be357-910bc8408f1sm573577885a.24.2026.05.15.08.45.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2026 08:45:44 -0700 (PDT) From: Michael Bommarito To: Steffen Klassert , Herbert Xu Cc: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Evan Nimmo , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net] xfrm: ah: use skb_to_full_sk in async output callbacks Date: Fri, 15 May 2026 11:45:31 -0400 Message-ID: <20260515154531.1386683-1-michael.bommarito@gmail.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When AH output is offloaded to an asynchronous crypto provider (hardware accelerators such as AMD CCP, or a forced-async software shim used for testing), the digest completion fires ah_output_done() / ah6_output_done() on a workqueue. The egress skb at that point may have been originated by a TCP listener sending a SYN-ACK, which sets skb->sk to a request_sock via skb_set_owner_edemux(); it may also have been originated by an inet_timewait_sock retransmit. Neither is a full struct sock, and passing the raw skb->sk to xfrm_output_resume() then forwards a non-full socket through the rest of the xfrm output chain. xfrm_output_resume() and its downstream consumers expect a full sk where they dereference at all. The natural egress path through ah_output_done() does not crash today because the consumers that read past sock_common are either gated by sk_fullsock() or short-circuit on flags that are clear on a fresh request_sock; an exhaustive walk of the 50 most plausible consumers under sch_fq, dev_queue_xmit, netfilter, tc-egress and cgroup-egress BPF found no current unguarded deref. The bug is still a real type confusion that future consumer changes could turn into a memory-corruption primitive. This is the same bug class fixed for ESP in commit 1620c88887b1 ("xfrm: Fix the usage of skb->sk"). Apply the analogous fix to AH: convert skb->sk to a full socket pointer (or NULL) via skb_to_full_sk() before handing it to xfrm_output_resume(). The same async AH callbacks were touched recently for an independent ESN-related ICV layout bug in commit ec54093e6a8f ("xfrm: ah: account for ESN high bits in async callbacks"); the sk type-confusion addressed here is orthogonal. This patch is part of an ongoing audit of the AH callback paths; an ah_output ihl-validation hardening series is also currently under review on netdev. Reproduced under UML + KASAN + lockdep with a forced-async hmac(sha1) shim that registers at priority 9999 and wraps the sync in-tree hmac-sha1-lib. With the shim loaded, ah_output_done runs on every SYN-ACK egress through a transport-mode AH SA and skb->sk arrives as a request_sock (TCP_NEW_SYN_RECV); after this patch, xfrm_output_resume() receives the listener (the result of sk_to_full_sk()) and consumer derefs land on full-sock fields as intended. Fixes: 9ab1265d5231 ("xfrm: Use actual socket sk instead of skb socket for = xfrm_output_resume") Cc: stable@vger.kernel.org Assisted-by: Claude:claude-opus-4-7 Signed-off-by: Michael Bommarito --- net/ipv4/ah4.c | 2 +- net/ipv6/ah6.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c index 5fb812443a08f..ab8fa851ab4d9 100644 --- a/net/ipv4/ah4.c +++ b/net/ipv4/ah4.c @@ -138,7 +138,7 @@ static void ah_output_done(void *data, int err) } =20 kfree(AH_SKB_CB(skb)->tmp); - xfrm_output_resume(skb->sk, skb, err); + xfrm_output_resume(skb_to_full_sk(skb), skb, err); } =20 static int ah_output(struct xfrm_state *x, struct sk_buff *skb) diff --git a/net/ipv6/ah6.c b/net/ipv6/ah6.c index cb26beea43982..62794355d4d79 100644 --- a/net/ipv6/ah6.c +++ b/net/ipv6/ah6.c @@ -332,7 +332,7 @@ static void ah6_output_done(void *data, int err) ah6_restore_hdrs(top_iph, iph_ext, extlen); =20 kfree(AH_SKB_CB(skb)->tmp); - xfrm_output_resume(skb->sk, skb, err); + xfrm_output_resume(skb_to_full_sk(skb), skb, err); } =20 static int ah6_output(struct xfrm_state *x, struct sk_buff *skb) --=20 2.53.0