From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 35381611A for ; Sun, 28 May 2023 19:16:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3877C433EF; Sun, 28 May 2023 19:16:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1685301382; bh=k7rFMB37YZFsu82kloAFyuAdoz+Pb5ULwgI8iVEY6dc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lFetTbUnc1i+J17KyaLyUlo8C+D8BlMpxaC8dJiGpd8vnhQvCirmR6DkqRweXmTQb s3jlFoRfV1NwDisb+QbFoa5GyoQOVbqhRhXGU1Us5h0C6vX+dt+EJLN5TZMI3WY1TP GVncpPiGr/JKsLfZgchVBp309NWwqgQ/GyEhjCos= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Gavrilov Ilia , Jiri Pirko , David Ahern , "David S. Miller" Subject: [PATCH 4.14 77/86] ipv6: Fix out-of-bounds access in ipv6_find_tlv() Date: Sun, 28 May 2023 20:10:51 +0100 Message-Id: <20230528190831.501044745@linuxfoundation.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230528190828.564682883@linuxfoundation.org> References: <20230528190828.564682883@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Gavrilov Ilia commit 878ecb0897f4737a4c9401f3523fd49589025671 upstream. optlen is fetched without checking whether there is more than one byte to parse. It can lead to out-of-bounds access. Found by InfoTeCS on behalf of Linux Verification Center (linuxtesting.org) with SVACE. Fixes: c61a40432509 ("[IPV6]: Find option offset by type.") Signed-off-by: Gavrilov Ilia Reviewed-by: Jiri Pirko Reviewed-by: David Ahern Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv6/exthdrs_core.c | 2 ++ 1 file changed, 2 insertions(+) --- a/net/ipv6/exthdrs_core.c +++ b/net/ipv6/exthdrs_core.c @@ -142,6 +142,8 @@ int ipv6_find_tlv(const struct sk_buff * optlen = 1; break; default: + if (len < 2) + goto bad; optlen = nh[offset + 1] + 2; if (optlen > len) goto bad;