All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: Eric Dumazet <eric.dumazet@gmail.com>,
	"David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>
Cc: netdev <netdev@vger.kernel.org>,
	Eric Dumazet <edumazet@google.com>,
	Tom Herbert <tom@herbertland.com>
Subject: Re: [PATCH net] ipv6: fix out-of-bound access in ip6_parse_tlv()
Date: Thu, 24 Jun 2021 11:49:30 +0200	[thread overview]
Message-ID: <e0e59d780e1c979c2666e8bc77ce00249ac3e6e1.camel@redhat.com> (raw)
In-Reply-To: <20210623194353.2021745-1-eric.dumazet@gmail.com>

On Wed, 2021-06-23 at 12:43 -0700, Eric Dumazet wrote:
> From: Eric Dumazet <edumazet@google.com>
> 
> First problem is that optlen is fetched without checking
> there is more than one byte to parse.
> 
> Fix this by taking care of IPV6_TLV_PAD1 before
> fetching optlen (under appropriate sanity checks against len)
> 
> Second problem is that IPV6_TLV_PADN checks of zero
> padding are performed before the check of remaining length.
> 
> Fixes: c1412fce7ecc ("net/ipv6/exthdrs.c: Strict PadN option checking")

Perhaps even:

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")

for the first issue?

> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: Tom Herbert <tom@herbertland.com>
> ---
> 
> Only compiled, I would appreciate a solid review of this patch before merging it, thanks !
> 
>  net/ipv6/exthdrs.c | 26 +++++++++++++-------------
>  1 file changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
> index 6f7da8f3e2e5849f917853984c69bf02a0f1e27c..007959d4d3748f1e21f83946024a9967d08b25b6 100644
> --- a/net/ipv6/exthdrs.c
> +++ b/net/ipv6/exthdrs.c
> @@ -135,18 +135,24 @@ static bool ip6_parse_tlv(const struct tlvtype_proc *procs,
>  	len -= 2;
>  
>  	while (len > 0) {
> -		int optlen = nh[off + 1] + 2;
> -		int i;
> +		int optlen, i;
>  
> -		switch (nh[off]) {
> -		case IPV6_TLV_PAD1:
> +		if (nh[off] == IPV6_TLV_PAD1) {
>  			optlen = 1;

It looks like the above assignment is not needed anymore.

Other than that LGTM,

Thanks!

Paolo


  parent reply	other threads:[~2021-06-24  9:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-23 19:43 [PATCH net] ipv6: fix out-of-bound access in ip6_parse_tlv() Eric Dumazet
2021-06-23 22:07 ` Jakub Kicinski
2021-06-24  9:49 ` Paolo Abeni [this message]
2021-06-24 10:08   ` Eric Dumazet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e0e59d780e1c979c2666e8bc77ce00249ac3e6e1.camel@redhat.com \
    --to=pabeni@redhat.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=tom@herbertland.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.