public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] ipv6: Fix out-of-bounds access in ipv6_find_tlv()
@ 2023-05-23  8:29 Gavrilov Ilia
  2023-05-23 13:26 ` Jiri Pirko
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Gavrilov Ilia @ 2023-05-23  8:29 UTC (permalink / raw)
  To: David S. Miller
  Cc: David Ahern, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Vlad Yasevich, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org

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")
Signed-off-by: Gavrilov Ilia <Ilia.Gavrilov@infotecs.ru>
---
 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;
-- 
2.30.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net] ipv6: Fix out-of-bounds access in ipv6_find_tlv()
  2023-05-23  8:29 [PATCH net] ipv6: Fix out-of-bounds access in ipv6_find_tlv() Gavrilov Ilia
@ 2023-05-23 13:26 ` Jiri Pirko
  2023-05-23 15:21 ` David Ahern
  2023-05-24  7:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Jiri Pirko @ 2023-05-23 13:26 UTC (permalink / raw)
  To: Gavrilov Ilia
  Cc: David S. Miller, David Ahern, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Vlad Yasevich, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org

Tue, May 23, 2023 at 10:29:44AM CEST, Ilia.Gavrilov@infotecs.ru 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")
>Signed-off-by: Gavrilov Ilia <Ilia.Gavrilov@infotecs.ru>

Reviewed-by: Jiri Pirko <jiri@nvidia.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] ipv6: Fix out-of-bounds access in ipv6_find_tlv()
  2023-05-23  8:29 [PATCH net] ipv6: Fix out-of-bounds access in ipv6_find_tlv() Gavrilov Ilia
  2023-05-23 13:26 ` Jiri Pirko
@ 2023-05-23 15:21 ` David Ahern
  2023-05-24  7:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: David Ahern @ 2023-05-23 15:21 UTC (permalink / raw)
  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

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 <Ilia.Gavrilov@infotecs.ru>
> ---
>  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 <dsahern@kernel.org>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] ipv6: Fix out-of-bounds access in ipv6_find_tlv()
  2023-05-23  8:29 [PATCH net] ipv6: Fix out-of-bounds access in ipv6_find_tlv() Gavrilov Ilia
  2023-05-23 13:26 ` Jiri Pirko
  2023-05-23 15:21 ` David Ahern
@ 2023-05-24  7:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-05-24  7:50 UTC (permalink / raw)
  To: Gavrilov Ilia
  Cc: davem, dsahern, edumazet, kuba, pabeni, vyasevic, netdev,
	linux-kernel, lvc-project

Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:

On Tue, 23 May 2023 08:29:44 +0000 you 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")
> Signed-off-by: Gavrilov Ilia <Ilia.Gavrilov@infotecs.ru>
> 
> [...]

Here is the summary with links:
  - [net] ipv6: Fix out-of-bounds access in ipv6_find_tlv()
    https://git.kernel.org/netdev/net/c/878ecb0897f4

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-05-24  7:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-23  8:29 [PATCH net] ipv6: Fix out-of-bounds access in ipv6_find_tlv() Gavrilov Ilia
2023-05-23 13:26 ` Jiri Pirko
2023-05-23 15:21 ` David Ahern
2023-05-24  7:50 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox