Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795042388; b=SzD7S0MUshmwRVnXDR0rjGF/uWEfhshG31wiIl0PmdxYTqeVSiNaCeIHYn7wPhhL8aWS +6sZbuBlH3x4MykLFX0RPTIcDNDjE84fcEF/McXjuG9nfOfIO+kUgQZbQ3xce48tznb0L AL+wTg6bf1Zi5QJNVpiIlbnSDtHB5s5j8LwxAHpOJw0p30D5f6jD8F5zB3PZawCzovcJT Gqht+atXaa31BoNoy6Khs3Bz8h8s09W0DvNlyWFr6aRoeuVmmghwt8we8qPd7mf86iiMH 4SHLfFape4exbpLRlfC+6GYIvLVtbaNKJiyUwxvs0bGXUNg7tkTGtMThPuQmAc21pUA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795042388; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=1vD+vgo5ybdr4mfu2a0pnxmTD+/q+jhyNINznjLW9P8=; b=0wFRsrRREDwA+yjLWGc2166RbFyNQCZGQgK/q8sHp/Jf0rLDRXog595E7REyGYVHCTu5 BKqW2vj3LG98jlcugGuEv2/319YAFgwG+zuxxVDfauhKG8E9hEk6CUBkc0bSSMNxMzCcE lvfsu8Sf8rAXNhlamW3PY9zDc0XmKrpLsLIwBosXghO7iEK9CgR/kVuQqRyLhEy0AjOwA LIGTI1v31QF8JXECoRa3dd7srQVADNDQUlAIFKVknGMamSr3DQTsin+Frvo6uxvVQWvmX uZXqn2Aj/HhAcNU5fW1Nxoce+FduZqOy9vAi+94zAJHuWTzDysqVxxPf/jo3EeHgVlw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=ABJVDSYq; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 74CD1606A320; Wed, 18 Nov 2026 22:53:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=ABJVDSYq Received: by smtp.kernel.org (Postfix) with ESMTPSA id 739DF1F000C4; Wed, 18 Nov 2026 22:53:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795042388; bh=1vD+vgo5ybdr4mfu2a0pnxmTD+/q+jhyNINznjLW9P8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ABJVDSYq+wl5MYEzdJoxADj5yy6q6sDSF31hYLkKbyqkd6vdo5fSHbAzc/zDshkre c1HHhi9SskTm9mxdzKpgtn0Bf+TuSVOjQrajxPct9nIbbEh5U4dVSEgKlzPjKD9xPo FgDZbfOJo7zwHpHmwY4WPP0RSPwGINeCQkKpLEus= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Nandor Kracser , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.6 3151/3318] tls: avoid field-spanning write when copying crypto info Date: Wed, 18 Nov 2026 16:02:53 +0100 Message-ID: <20261118150454.394121929@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150313.527275416@linuxfoundation.org> References: <20261118150313.527275416@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Nandor Kracser [ Upstream commit c43c1c24f3cdc0d2d3f59e5686573ac3129637aa ] do_tls_setsockopt_conf() copies the cipher-specific part of the crypto info to crypto_info + 1, where crypto_info points at the 4-byte info member of union tls_crypto_context. When optval is a kernel sockptr, copy_from_sockptr_offset() is a memcpy(), and FORTIFY_SOURCE bounds the destination by that member: [ 6.948348] memcpy: detected field-spanning write (size 52) of single field "dst" at include/linux/sockptr.h:49 (size 0) [ 6.948480] WARNING: include/linux/sockptr.h:49 at tls_setsockopt+0x9b2/0xa30, CPU#1: init/1 [ 7.001355] Call Trace: [ 7.003146] do_sock_setsockopt+0xb0/0x190 [ 7.003975] __sys_setsockopt+0x76/0xc0 [ 7.005368] do_syscall_64+0xda/0x4b0 tls_setsockopt() gets a kernel sockptr whenever a cgroup setsockopt BPF program is attached, even one that leaves the option alone, because __cgroup_bpf_run_filter_setsockopt() passes optval on in a kernel buffer. With a no-op program on the root cgroup, a plain TLS_TX setsockopt() with AES-GCM-256 triggers the warning above on an x86_64 build with CONFIG_FORTIFY_SOURCE. Copy into the union at offset sizeof(struct tls_crypto_info) instead. crypto_ctx already points at the right union for both the first set and the TLS 1.3 rekey (tmp) case, and the address is unchanged. Fixes: a7b75c5a8c41 ("net: pass a sockptr_t into ->setsockopt") Signed-off-by: Nandor Kracser Link: https://patch.msgid.link/20261021073233.16720-1-nandor@riptides.io Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/tls/tls_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c index 9d5c99f1e4e7c..4e022059dab0e 100644 --- a/net/tls/tls_main.c +++ b/net/tls/tls_main.c @@ -664,8 +664,8 @@ static int do_tls_setsockopt_conf(struct sock *sk, sockptr_t optval, goto err_crypto_info; } - rc = copy_from_sockptr_offset(crypto_info + 1, optval, - sizeof(*crypto_info), + rc = copy_from_sockptr_offset((u8 *)crypto_ctx + sizeof(*crypto_info), + optval, sizeof(*crypto_info), optlen - sizeof(*crypto_info)); if (rc) { rc = -EFAULT; -- 2.53.0