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 4D4441F922 for ; Tue, 23 May 2023 15:21:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 952D5C4339B; Tue, 23 May 2023 15:21:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684855303; bh=z4Tb9HwQR3qu2omMR1+2EyzzwcS65O49EGKOPEOuCM4=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=XsThTIi8BWp8lNdnvT18YqAX/fGTxOCWVb8v3c86j5cKKoWj5a/wP47vngNKqufLn dFZpTM1bcNipiqo2qyFTGJMCqeFH4ZQX9JQQrUcwYop3FILkDgULwSmX1YZ8Yxn5h/ 9ttEEadjLSHkwAVbo8T3tiBpqO3RaqU3smuf2uzoSSAhIAMJFm+CN0drF6UiOaMVSb Tor1w7YCo7PVCB6d+Hz1nMK84IRi399puEeKt7EVmG4YVAgk8pG86t6QIOu3AqvsMP qq3/7wQdyetbhtQcByRIee07RvsDTXuoR0XEdl6TkrT5gCUCY65qhQw4Y63aQ2B6uA c1RGeSpMst60A== Message-ID: <36eea968-d3e8-fc1e-6d88-0f19fce130d8@kernel.org> Date: Tue, 23 May 2023 09:21:41 -0600 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH net] ipv6: Fix out-of-bounds access in ipv6_find_tlv() Content-Language: en-US To: Gavrilov Ilia , "David S. Miller" Cc: Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vlad Yasevich , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "lvc-project@linuxtesting.org" References: <20230523082903.117626-1-Ilia.Gavrilov@infotecs.ru> From: David Ahern In-Reply-To: <20230523082903.117626-1-Ilia.Gavrilov@infotecs.ru> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 5/23/23 2:29 AM, Gavrilov Ilia wrote: > 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: 3c73a0368e99 ("ipv6: Update ipv6 static library with newly needed functions") That is not the right Fixes tag; that commit only moved the code. Fixes: c61a40432509 ("[IPV6]: Find option offset by type.") > Signed-off-by: Gavrilov Ilia > --- > net/ipv6/exthdrs_core.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/net/ipv6/exthdrs_core.c b/net/ipv6/exthdrs_core.c > index da46c4284676..49e31e4ae7b7 100644 > --- a/net/ipv6/exthdrs_core.c > +++ b/net/ipv6/exthdrs_core.c > @@ -143,6 +143,8 @@ int ipv6_find_tlv(const struct sk_buff *skb, int offset, int type) > optlen = 1; > break; > default: > + if (len < 2) > + goto bad; > optlen = nh[offset + 1] + 2; > if (optlen > len) > goto bad; Reviewed-by: David Ahern