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 ECC9313C9C4; Mon, 17 Aug 2026 14:20:53 +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=1786976455; cv=none; b=eWePqDN0A3MExHdE6bz/IHGbYnV7YiFuhzFlhaDYhvTD1dBwicJ6/8nnvqVQqrM3Yfvim1Xkl9RGF4kVWWvyA+U6+Xc1q45jAgaGz2K117lwdK9r+ToQx8A7BaSTXD1qnrpaNljEf6Uf60/FZ7NMU+Uzey5GRzFWRsnMVeFM2rs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786976455; c=relaxed/simple; bh=CYc2csFGPUTMJr1v1jutjy+YgY1YZcRFUfb5k+1VipI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nYz0nJL8ZZrJPK1wta6q0fGxd1+lsiVeoGohWRXaVbGefd48bShFwDDrQPKHiVff5UO3QMZBMleY/mckA7PphhPj8HKsGqQVGKEb6Jxw53ubkrTyy4qy8RXOA8/o8xJEYCiDfGdmMenKdfDmdBsnzZ8t/We86w9d49rZR16Md38= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=eLgds/Xh; 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="eLgds/Xh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A3271F000E9; Mon, 17 Aug 2026 14:20:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1786976453; bh=+I0tm/eMQvy8/Fk3TKriSe5yxA0TkoF+KW6viF0L8pM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=eLgds/XhemDmLeJ601hZXrkR/dbhWDX9EAnv4PTfFWLqF4ORKMlLUlV60oIvv8xiF CzUwPRM7z/ra59aX+vhdl7Ic69kOsbzy7Oj7K2sKe8JvD8u0UYg1czgOrR93A6HNA5 G0vHrBwQO7gu566k0YpL/wSL1X+SKWuP7UF1nFXE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yuejie Shi , Ido Schimmel , Jakub Kicinski Subject: [PATCH 5.10 379/389] ipv6: fix Route Information option length validation Date: Mon, 17 Aug 2026 15:33:38 +0200 Message-ID: <20260817132553.466588038@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260817132538.796021292@linuxfoundation.org> References: <20260817132538.796021292@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: Yuejie Shi commit d1ad8fb2ac6a1afb71dc22d9ae8efb4dda96c824 upstream. rt6_route_rcv() validates the Route Information option (RFC 4191) length against the prefix length, but both checks are off by one. rinfo->length is the ND option length in units of 8 octets and it *includes* the 8-byte option header, so an option carrying N bytes of prefix has length == 1 + N/8. RFC 4191 section 2.3 requires length 3 when Prefix Length is greater than 64, and 2 or 3 when it is greater than 0. The code accepts length >= 2 and length >= 1 respectively. ipv6_addr_prefix() then copies prefix_len/8 bytes out of rinfo->prefix, so a Router Advertisement with (prefix_len=128, length=2) or (prefix_len=64, length=1) makes the kernel read up to 8 bytes past the end of the option. Those bytes end up in the prefix of the route that gets installed, so they are visible to userspace: # RA with a Route Information option (prefix_len=128, length=2) # followed by a source link-layer address option, 01 01 de ad be ef ca fe $ ip -6 route show 2001:db8:dead:beef:101:dead:beef:cafe via fe80::1234 dev veth0 proto ra ^^^^^^^^^^^^^^^^^^ the next option, read out of bounds When the Route Information option is the last one in the packet, those eight bytes come from the skb tail room instead. Reject the option lengths RFC 4191 does not allow. Fixes: 70ceb4f53929 ("[IPV6]: ROUTE: Add experimental support for Route Information Option in RA (RFC4191).") Cc: stable@vger.kernel.org Signed-off-by: Yuejie Shi Reviewed-by: Ido Schimmel Link: https://patch.msgid.link/20260730035310.74584-1-syjcnss@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/ipv6/route.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -942,13 +942,13 @@ int rt6_route_rcv(struct net_device *dev } else if (rinfo->prefix_len > 128) { return -EINVAL; } else if (rinfo->prefix_len > 64) { - if (rinfo->length < 2) { + /* RFC 4191: Length MUST be 3 when Prefix Length > 64 */ + if (rinfo->length < 3) return -EINVAL; - } } else if (rinfo->prefix_len > 0) { - if (rinfo->length < 1) { + /* RFC 4191: Length MUST be 2 or 3 when Prefix Length > 0 */ + if (rinfo->length < 2) return -EINVAL; - } } pref = rinfo->route_pref;