From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (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 68AC63A784A for ; Mon, 17 Aug 2026 09:03:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786957440; cv=none; b=Q7sjqU5QYimWNKWPtD9GgkQUnCHRDpV1F1XA7FbAbBCT558Or9fi9gfIaZhxkrC1Xqs/vIb43vjuyzVmYz7m4HGIuCFa+0yxr1l3c75TVpcCcDVEYFul8nU7dN5hiN3T7+Z/jas37LSHL9j7w0RUnVwE2eCztrQAyHw02JhpHsg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786957440; c=relaxed/simple; bh=jmcCgsbGNKvQsGopZdfhbfD93w4f5WcJJOrmkdyxHBo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Nrl/q/YEmgDa4Z1VATR+r6fQs6Hfpfir3yQZDgelu0mumUhDQbONIf/tt30nZt4gMiVG25EI0/MLkdRpqRGELRtUwJGdTyA92qsURSKoMIbTZUk7q81o2tKAU4JZn/bNQDxcJpzhr37+izmw224OVtAB6d1pBunHbAjPWd761jw= 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=ofGRpFb6; arc=none smtp.client-ip=209.85.210.170 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="ofGRpFb6" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-84862b0d5aeso2419799b3a.2 for ; Mon, 17 Aug 2026 02:03:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786957439; x=1787562239; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=g951Y30fAYIITqf5Upt52gggx1O3bnI71YidBFSIjvY=; b=ofGRpFb6GrgWajH1QI6mzY5/MnDc/WDM0j2JtyWu0RD63CSgYSfE5DwEGAXl2abj85 d47ZbsEJz7M8FCBNC1QIP+oi8EP8ynOxt2ddyhLv2QGUJgqUPa5oGZwytkrabdNZB/qG Fwe5LoTPRilnTW0HVEaK1k8p1N8xSEezjCD8BbsPEhlGDn/HReFOWOsj8w1h8rUHsKML +PuSidRixyZCh5snW7Dj/ABjv8fKaZ64aWkbf79vVBDomlm7H6QPsor1nlVpkrbRK1y6 X3KinlDYRZsl68+Ty5ocEB0Twr56vvVSs1mdudVSPy/fEibuApkNUd0TUtKMe3+d3lzE 9KbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786957439; x=1787562239; h=content-transfer-encoding:mime-version:references:in-reply-to :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=g951Y30fAYIITqf5Upt52gggx1O3bnI71YidBFSIjvY=; b=WSjHIZUXo6dD/oICX/i5wrQ4l+dAYNaidLvOmoDnnsiIaG2W/xkbkP0YFy/Kb0E6Kh /R6FXYyWtB1E7yL42NGCDp6GB5LaeMDWEa410k2oEwISm36YCyRlT8U24su90vzdS261 EJod+ini8KTWeH6sY2PBHiRR9s01yntg9J4Z7tTOpIW16em88bNnNYElMPFiGYgifZC0 f/D15q9Kcty/QNbFYKULWqB4XTM2ZTNbkoVl5Ji+YmZQCPt+Mp5CoyOnSZvi0+rRXn9E +yhw7nXk+01kWrcDY6FJDXBSPmL17FzSb2jcuUhfJFVITatOpDKm2VKIkkoHlwaGCknw 3Rkw== X-Gm-Message-State: AOJu0YyWAfUw/lgRNkOMD7okD+ikunMQADTrLr9yXF/IUJsDMhCHBBOe WVZ9Nre8wLt85WfMSBgHjfrhciPgYXXYfsOZhtYLjqiqSXRpI7FeOp1F X-Gm-Gg: AR+sD12sM28/I4mAQtAaQr8YozPXJV64BkHJ1hnB7pkQNiH+X66Ueik0p5XZ+kALSct ygxkm1Si1uBoIKCby2MXiBGs1Hy4RT/e2QPHN8+ureD3qm4lgjf3qt2AjgzeIKZz4i5NVQjIz/8 UGhLaqjo9iitl1Z70S09pjpRtVIuIYKbOFGHr933hiIMSbv8aFCLatMudW6ff/Vri+R11AGE3Dh 8yywlLT1jYiK66ANXpidFJbpyrTz8I4xyVzhSB26sD24KoZTcwBook0KHBxZI0yDviNY9x2oor4 IdCs3RgnP17EkAtC2Tcsqb7VBIUmuW6trnZpey424DP1lAJiFBr615OEDBMMiK6mOxR0uWin8p1 mNGhG9NayxfHecCJTb07FYaXbrCxxYinnkhyGO7sPVCzncW/vp594tnV9Hh+XSBLGB1ijK1lR1m PfQiosDEYOCffteENN4TcNR5J68kZ0/IGKuh//URQCewSxWQT7WxrZjkHdjpoloFXdrwTzdWID6 Rf6bjk2/uI= X-Received: by 2002:a05:6a00:1895:b0:845:4928:8655 with SMTP id d2e1a72fcca58-84fde33319bmr22306634b3a.39.1786957438516; Mon, 17 Aug 2026 02:03:58 -0700 (PDT) Received: from v4bel.. ([58.123.110.97]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8517d2476easm2342517b3a.42.2026.08.17.02.03.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 02:03:58 -0700 (PDT) From: Hyunwoo Kim To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org, ncardwell@google.com, kuniyu@google.com, horms@kernel.org, willemb@google.com, andrew+netdev@lunn.ch Cc: netdev@vger.kernel.org, imv4bel@gmail.com, stable@vger.kernel.org Subject: [PATCH net 2/3] net: fix out-of-bounds write in sk_clone() racing with IPV6_ADDRFORM Date: Mon, 17 Aug 2026 18:03:16 +0900 Message-ID: <20260817090319.3897799-3-imv4bel@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260817090319.3897799-1-imv4bel@gmail.com> References: <20260817090319.3897799-1-imv4bel@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit sk_clone() allocates the child from sk->sk_prot, and IPV6_ADDRFORM can change sk_prot under it. The conversion requires the socket to be established, and a listener gets there with connect(AF_UNSPEC) followed by connect(). tcp_check_req() completes a request without the listener lock, so it can run while the conversion is in progress. IPV6_ADDRFORM stores sk_prot before icsk_af_ops, so tcp_check_req() can still call tcp_v6_syn_recv_sock() once sk_prot is tcp_prot. The child then comes from tcp_prot's slab while the AF_INET6 code treats it as a tcp6_sock. tcp_inet6_sk() is a fixed offset into tcp6_sock, and in a child sized by tcp_prot that offset is the end of the object. The ipv6_pinfo copy is therefore a slab out-of-bounds write of sizeof(struct ipv6_pinfo) bytes past the child. The out-of-bounds address is also stored in the child's pinet6, so everything that reaches the socket through inet6_sk() keeps writing there. A request that arrived over IPv4 takes the same copy in tcp_v6_mapped_child_init(). Checking sk_prot before the clone does not help. It can change between that check and the read inside sk_clone(). Use sk_prot_creator instead. It is set once in sk_alloc() and never changes, and the socket is already freed back through it. No caller that replaces sk_prot installs a proto with a larger obj_size than the creator, so the child gets the size the parent object actually has. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Signed-off-by: Hyunwoo Kim --- net/core/sock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/sock.c b/net/core/sock.c index 1ad41904db25b4..098e58b40f304b 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -2479,7 +2479,7 @@ static void sk_init_common(struct sock *sk) struct sock *sk_clone(const struct sock *sk, const gfp_t priority, bool lock) { - struct proto *prot = READ_ONCE(sk->sk_prot); + struct proto *prot = sk->sk_prot_creator; struct sk_filter *filter; bool is_charged = true; struct sock *newsk; -- 2.43.0