From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25B0D3812F1; Wed, 30 Sep 2026 15:58:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790783897; cv=none; b=o30sDNKXXc2yCoPGQNo9G4kW8Q1hDYUBBydjOWk6Og54QcGeYYmeEFnz+xjCb2ou4ywq8sY6XVTKjet7u4hP7YhAlNUcZL7w3uai8vBeIsbR0CKZClcNt/l7aGIH+V/x81j2+hZBRl9J44/8D1O+sSUDex2NMXWflTx11vymz70= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790783897; c=relaxed/simple; bh=eFw0mC3xoQfRxxMFHWVDmshDR3lfzLZKjchMBOVBxqs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WnEZnBkt37jv89kTJRz1+x3PHFkUPnct3TPYpYlOzpLQqq+eRatIN3icGHlp+gL6T+UhSC0rIqGEikPFWdnmQDgh0Jt91830A1Kn/+y0nEXwqKe3HRwetg9bvjhLo6O0Nhl6VodHKEb9JZ5PnbO5TLopYPfq36VRj3+72HoKxak= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=O6EoQRKB; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="O6EoQRKB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EAA2A1F000FF; Wed, 30 Sep 2026 15:58:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790783889; bh=WD+pV3DcHYkSQdTYLZCaT01ePtnYUA6SC6PKm9kKUCE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=O6EoQRKB58yRWkac2mLRF96ZpkWCplM6b8+jzJzoyylMzSgbJimUV4D/6An8mBe0q 7/YMEn+1BxwVvQw5vI9/HetS9GXzQy1pd3MlUVjrQlbRuQFrT7RP9weVw5Aer+YZ/9 O3I1YrR+Z4pT3F4gJ+070RyC5SfQkoD7BWoEa/Fs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Hui Peng , Hangbin Liu , Justin Iurman , Andrea Mayer , Jakub Kicinski Subject: [PATCH 5.10 559/595] ipv6: sr: enforce exact attribute length for SEG6_ATTR_DST Date: Wed, 30 Sep 2026 17:27:32 +0200 Message-ID: <20260930152359.743460621@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152347.700140858@linuxfoundation.org> References: <20260930152347.700140858@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hui Peng commit 2d959c75c27f90e9ec489d18ce5ee6b852ad4741 upstream. In seg6_genl_policy, SEG6_ATTR_DST is defined with .type = NLA_BINARY and .len = sizeof(struct in6_addr). For NLA_BINARY, .len only enforces the maximum payload length and permits shorter payloads (e.g., 0 bytes). When seg6_genl_set_tunsrc() copies sizeof(struct in6_addr) bytes via kmemdup(val, sizeof(*val), GFP_KERNEL), a short SEG6_ATTR_DST attribute triggers a 16-byte out-of-bounds read past skb->tail into uninitialized skb->head memory, which is stored in sdata->tun_src and leaked back to userspace via SEG6_CMD_GET_TUNSRC. Switch SEG6_ATTR_DST in seg6_genl_policy to NLA_POLICY_EXACT_LEN(sizeof(struct in6_addr)) so that generic netlink validation rejects any attribute whose length is not exactly sizeof(struct in6_addr) with -ERANGE. Tested in QEMU against Linux 7.3.0-rc3 by sending a SEG6_CMD_SET_TUNSRC Generic Netlink message with a 0-byte SEG6_ATTR_DST attribute followed by SEG6_CMD_GET_TUNSRC. On the unfixed kernel, SEG6_CMD_SET_TUNSRC succeeds (err = 0) and SEG6_CMD_GET_TUNSRC leaks 16 bytes of uninitialized kernel heap memory (tun_src = 836a61ecc4d25a1042a8d60411cfb378); with this patch applied, SEG6_CMD_SET_TUNSRC is rejected by netlink policy validation with -ERANGE (-34) and tun_src remains zeroed. Fixes: 915d7e5e5930 ("ipv6: sr: add code base for control plane support of SR-IPv6") Cc: stable@vger.kernel.org Signed-off-by: Hui Peng Reviewed-by: Hangbin Liu Reviewed-by: Justin Iurman Reviewed-by: Andrea Mayer Link: https://patch.msgid.link/20260921044025.1535982-1-benquike@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/ipv6/seg6.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/net/ipv6/seg6.c +++ b/net/ipv6/seg6.c @@ -81,8 +81,8 @@ bool seg6_validate_srh(struct ipv6_sr_hd static struct genl_family seg6_genl_family; static const struct nla_policy seg6_genl_policy[SEG6_ATTR_MAX + 1] = { - [SEG6_ATTR_DST] = { .type = NLA_BINARY, - .len = sizeof(struct in6_addr) }, + [SEG6_ATTR_DST] = + NLA_POLICY_EXACT_LEN(sizeof(struct in6_addr)), [SEG6_ATTR_DSTLEN] = { .type = NLA_S32, }, [SEG6_ATTR_HMACKEYID] = { .type = NLA_U32, }, [SEG6_ATTR_SECRET] = { .type = NLA_BINARY, },