From: Eric Dumazet <hidden> Date: 2021-06-23 19:44:00
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")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Tom Herbert <redacted>
---
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(-)
@@ -135,18 +135,24 @@ static bool ip6_parse_tlv(const struct tlvtype_proc *procs,len-=2;while(len>0){-intoptlen=nh[off+1]+2;-inti;+intoptlen,i;-switch(nh[off]){-caseIPV6_TLV_PAD1:+if(nh[off]==IPV6_TLV_PAD1){optlen=1;padlen++;if(padlen>7)gotobad;-break;+off++;+len--;+continue;+}+if(len<2)+gotobad;+optlen=nh[off+1]+2;+if(optlen>len)+gotobad;-caseIPV6_TLV_PADN:+if(nh[off]==IPV6_TLV_PADN){/* RFC 2460 states that the purpose of PadN is*toalignthecontainingheadertomultiples*of8.7isthereforethehighestvalidvalue.
@@ -163,12 +169,7 @@ static bool ip6_parse_tlv(const struct tlvtype_proc *procs,if(nh[off+i]!=0)gotobad;}-break;--default:/* Other TLV code so scan list */-if(optlen>len)-gotobad;-+}else{tlv_count++;if(tlv_count>max_count)gotobad;
From: Jakub Kicinski <kuba@kernel.org> Date: 2021-06-23 22:07:25
On Wed, 23 Jun 2021 12:43:53 -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")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Tom Herbert <redacted>
---
Only compiled, I would appreciate a solid review of this patch before merging it, thanks !
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
for what that's worth
From: Paolo Abeni <pabeni@redhat.com> Date: 2021-06-24 09:49:37
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?
quoted hunk
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Tom Herbert <redacted>
---
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(-)
From: Eric Dumazet <edumazet@google.com> Date: 2021-06-24 10:08:21
On Thu, Jun 24, 2021 at 11:49 AM Paolo Abeni [off-list ref] wrote:
On Wed, 2021-06-23 at 12:43 -0700, Eric Dumazet wrote:
quoted
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?
+ if (nh[off] == IPV6_TLV_PAD1) {
quoted
optlen = 1;
It looks like the above assignment is not needed anymore.
Other than that LGTM,