netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3 v2] ipv6: do not disable temp_address when reaching max_address
@ 2013-08-13  7:57 Ding Tianhong
  2013-08-13 11:05 ` Hannes Frederic Sowa
  0 siblings, 1 reply; 5+ messages in thread
From: Ding Tianhong @ 2013-08-13  7:57 UTC (permalink / raw)
  To: David S. Miller, Alexey Kuznetsov, James Morris,
	Hideaki YOSHIFUJI, Patrick McHardy, Netdev

A LAN user can remotely disable temporary address which may lead
to privacy violatins and information disclosure.

The reason is that the linux kernel uses the 'ipv6.max_addresses'
option to specify how many ipv6 addresses and interface may have.
The 'ipv6.regen_max_retry' (default value 3) option specifies
how many times the kernel will try to create a new address.

But the kernel is not distinguish between the event of reaching
max_addresses for an interface and failing to generate a new address.
the kernel disable the temporary address after regenerate a new
address 'regen_max_retry' times.

According RFC4941 3.3.7:

---------------------------------------

If DAD indicates the address is already in use,
the node must generate a new randomized interface
identifier as described in section 3.2 above, and
repeat the previous steps as appropriate up to
TEMP_IDGEN_RETRIES times.

If after TEMP_IDGEN_RETRIES consecutive attempts no
non-unique address was generated, the node must log
a system error and must not attempt to generate
temporary address for that interface.

------------------------------------------

RFC4941 3.3.7 specifies that disabling the temp_address must happen
upon the address is already in use, not reach the max_address,
So we have to check the return err and distinguish the correct retry path.

This fixes CVE-2013-0343

Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
Tested-by: Wang Weidong <wangweidong1@huawei.com>
Cc: David S. Miller <davem@davemloft.net>
---
 net/ipv6/addrconf.c | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index da4241c..72911fd 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -1134,10 +1134,27 @@ retry:
 	if (IS_ERR_OR_NULL(ift)) {
 		in6_ifa_put(ifp);
 		in6_dev_put(idev);
-		pr_info("%s: retry temporary address regeneration\n", __func__);
-		tmpaddr = &addr;
-		write_lock(&idev->lock);
-		goto retry;
+
+		/* According RFC4941 3.3.7:
+		 * If DAD indicates the address is already in use,
+		 * the node must generate a new randomized interface
+		 * identifier as described in section 3.2 above, and
+		 * repeat the previous steps as appropriate up to
+		 * TEMP_IDGEN_RETRIES times.
+		 * If after TEMP_IDGEN_RETRIES consecutive attempts no
+		 * non-unique address was generated, the node must log
+		 * a system error and must not attempt to generate
+		 * temporary address for that interface.
+		 * So we have to check the return err and distinguish
+		 * the correct retry path.
+		 */
+		if (PTR_ERR(ift) == -EEXIST) {
+			pr_info("%s: retry temporary address regeneration\n", __func__);
+			tmpaddr = &addr;
+			write_lock(&idev->lock);
+			goto retry;
+		} else
+			goto out;
 	}
 
 	spin_lock_bh(&ift->lock);
-- 
1.8.2.1

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

* Re: [PATCH 1/3 v2] ipv6: do not disable temp_address when reaching max_address
  2013-08-13  7:57 [PATCH 1/3 v2] ipv6: do not disable temp_address when reaching max_address Ding Tianhong
@ 2013-08-13 11:05 ` Hannes Frederic Sowa
  2013-08-13 11:53   ` Hannes Frederic Sowa
  2013-08-14  1:34   ` Ding Tianhong
  0 siblings, 2 replies; 5+ messages in thread
From: Hannes Frederic Sowa @ 2013-08-13 11:05 UTC (permalink / raw)
  To: Ding Tianhong
  Cc: David S. Miller, Alexey Kuznetsov, James Morris,
	Hideaki YOSHIFUJI, Patrick McHardy, Netdev

On Tue, Aug 13, 2013 at 03:57:14PM +0800, Ding Tianhong wrote:
> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
> index da4241c..72911fd 100644
> --- a/net/ipv6/addrconf.c
> +++ b/net/ipv6/addrconf.c
> @@ -1134,10 +1134,27 @@ retry:
>  	if (IS_ERR_OR_NULL(ift)) {
>  		in6_ifa_put(ifp);
>  		in6_dev_put(idev);
> -		pr_info("%s: retry temporary address regeneration\n", __func__);
> -		tmpaddr = &addr;
> -		write_lock(&idev->lock);
> -		goto retry;
> +
> +		/* According RFC4941 3.3.7:
> +		 * If DAD indicates the address is already in use,
> +		 * the node must generate a new randomized interface
> +		 * identifier as described in section 3.2 above, and
> +		 * repeat the previous steps as appropriate up to
> +		 * TEMP_IDGEN_RETRIES times.
> +		 * If after TEMP_IDGEN_RETRIES consecutive attempts no
> +		 * non-unique address was generated, the node must log
> +		 * a system error and must not attempt to generate
> +		 * temporary address for that interface.
> +		 * So we have to check the return err and distinguish
> +		 * the correct retry path.
> +		 */
> +		if (PTR_ERR(ift) == -EEXIST) {
> +			pr_info("%s: retry temporary address regeneration\n", __func__);
> +			tmpaddr = &addr;
> +			write_lock(&idev->lock);
> +			goto retry;
> +		} else
> +			goto out;

Correct me if I am wrong, but the RFC referes by mentioning "in use" to
allocated on the subnet and not in use by this host. I don't see how this
fixes the CVE then. dad is triggered by ipv6_add_addr.

Greetings,

  Hannes

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

* Re: [PATCH 1/3 v2] ipv6: do not disable temp_address when reaching max_address
  2013-08-13 11:05 ` Hannes Frederic Sowa
@ 2013-08-13 11:53   ` Hannes Frederic Sowa
  2013-08-14  1:39     ` Ding Tianhong
  2013-08-14  1:34   ` Ding Tianhong
  1 sibling, 1 reply; 5+ messages in thread
From: Hannes Frederic Sowa @ 2013-08-13 11:53 UTC (permalink / raw)
  To: Ding Tianhong, David S. Miller, Alexey Kuznetsov, James Morris,
	Hideaki YOSHIFUJI, Patrick McHardy, Netdev

On Tue, Aug 13, 2013 at 01:05:21PM +0200, Hannes Frederic Sowa wrote:
> On Tue, Aug 13, 2013 at 03:57:14PM +0800, Ding Tianhong wrote:
> > diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
> > index da4241c..72911fd 100644
> > --- a/net/ipv6/addrconf.c
> > +++ b/net/ipv6/addrconf.c
> > @@ -1134,10 +1134,27 @@ retry:
> >  	if (IS_ERR_OR_NULL(ift)) {
> >  		in6_ifa_put(ifp);
> >  		in6_dev_put(idev);
> > -		pr_info("%s: retry temporary address regeneration\n", __func__);
> > -		tmpaddr = &addr;
> > -		write_lock(&idev->lock);
> > -		goto retry;
> > +
> > +		/* According RFC4941 3.3.7:
> > +		 * If DAD indicates the address is already in use,
> > +		 * the node must generate a new randomized interface
> > +		 * identifier as described in section 3.2 above, and
> > +		 * repeat the previous steps as appropriate up to
> > +		 * TEMP_IDGEN_RETRIES times.
> > +		 * If after TEMP_IDGEN_RETRIES consecutive attempts no
> > +		 * non-unique address was generated, the node must log
> > +		 * a system error and must not attempt to generate
> > +		 * temporary address for that interface.
> > +		 * So we have to check the return err and distinguish
> > +		 * the correct retry path.
> > +		 */
> > +		if (PTR_ERR(ift) == -EEXIST) {
> > +			pr_info("%s: retry temporary address regeneration\n", __func__);
> > +			tmpaddr = &addr;
> > +			write_lock(&idev->lock);
> > +			goto retry;
> > +		} else
> > +			goto out;
> 
> Correct me if I am wrong, but the RFC referes by mentioning "in use" to
> allocated on the subnet and not in use by this host. I don't see how this
> fixes the CVE then. dad is triggered by ipv6_add_addr.

Eric already posted a proposal. It seems it lacked testing. Maybe you could
start from this?

http://permalink.gmane.org/gmane.linux.network/253518

Thanks for looking into this,

  Hannes

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

* Re: [PATCH 1/3 v2] ipv6: do not disable temp_address when reaching max_address
  2013-08-13 11:05 ` Hannes Frederic Sowa
  2013-08-13 11:53   ` Hannes Frederic Sowa
@ 2013-08-14  1:34   ` Ding Tianhong
  1 sibling, 0 replies; 5+ messages in thread
From: Ding Tianhong @ 2013-08-14  1:34 UTC (permalink / raw)
  To: David S. Miller, Alexey Kuznetsov, James Morris,
	Hideaki YOSHIFUJI, Patrick McHardy, Netdev

On 2013/8/13 19:05, Hannes Frederic Sowa wrote:
> On Tue, Aug 13, 2013 at 03:57:14PM +0800, Ding Tianhong wrote:
>> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
>> index da4241c..72911fd 100644
>> --- a/net/ipv6/addrconf.c
>> +++ b/net/ipv6/addrconf.c
>> @@ -1134,10 +1134,27 @@ retry:
>>  	if (IS_ERR_OR_NULL(ift)) {
>>  		in6_ifa_put(ifp);
>>  		in6_dev_put(idev);
>> -		pr_info("%s: retry temporary address regeneration\n", __func__);
>> -		tmpaddr = &addr;
>> -		write_lock(&idev->lock);
>> -		goto retry;
>> +
>> +		/* According RFC4941 3.3.7:
>> +		 * If DAD indicates the address is already in use,
>> +		 * the node must generate a new randomized interface
>> +		 * identifier as described in section 3.2 above, and
>> +		 * repeat the previous steps as appropriate up to
>> +		 * TEMP_IDGEN_RETRIES times.
>> +		 * If after TEMP_IDGEN_RETRIES consecutive attempts no
>> +		 * non-unique address was generated, the node must log
>> +		 * a system error and must not attempt to generate
>> +		 * temporary address for that interface.
>> +		 * So we have to check the return err and distinguish
>> +		 * the correct retry path.
>> +		 */
>> +		if (PTR_ERR(ift) == -EEXIST) {
>> +			pr_info("%s: retry temporary address regeneration\n", __func__);
>> +			tmpaddr = &addr;
>> +			write_lock(&idev->lock);
>> +			goto retry;
>> +		} else
>> +			goto out;
> 
> Correct me if I am wrong, but the RFC referes by mentioning "in use" to
> allocated on the subnet and not in use by this host. I don't see how this
> fixes the CVE then. dad is triggered by ipv6_add_addr.
> 
> Greetings,
> 
>   Hannes
> 
Reference:
  -> http://seclists.org/oss-sec/2012/q4/292
  -> http://seclists.org/oss-sec/2013/q1/92

I think the point is after the ./flood_route26 attack, 
the proc/sys/net/ipv6/conf/iface/use_tempaddr will change from 2 to -1,
whether is correct? :)

regards
Ding Tianhong


> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> .
> 

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

* Re: [PATCH 1/3 v2] ipv6: do not disable temp_address when reaching max_address
  2013-08-13 11:53   ` Hannes Frederic Sowa
@ 2013-08-14  1:39     ` Ding Tianhong
  0 siblings, 0 replies; 5+ messages in thread
From: Ding Tianhong @ 2013-08-14  1:39 UTC (permalink / raw)
  To: David S. Miller, Alexey Kuznetsov, James Morris,
	Hideaki YOSHIFUJI, Patrick McHardy, Netdev

On 2013/8/13 19:53, Hannes Frederic Sowa wrote:
> On Tue, Aug 13, 2013 at 01:05:21PM +0200, Hannes Frederic Sowa wrote:
>> On Tue, Aug 13, 2013 at 03:57:14PM +0800, Ding Tianhong wrote:
>>> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
>>> index da4241c..72911fd 100644
>>> --- a/net/ipv6/addrconf.c
>>> +++ b/net/ipv6/addrconf.c
>>> @@ -1134,10 +1134,27 @@ retry:
>>>  	if (IS_ERR_OR_NULL(ift)) {
>>>  		in6_ifa_put(ifp);
>>>  		in6_dev_put(idev);
>>> -		pr_info("%s: retry temporary address regeneration\n", __func__);
>>> -		tmpaddr = &addr;
>>> -		write_lock(&idev->lock);
>>> -		goto retry;
>>> +
>>> +		/* According RFC4941 3.3.7:
>>> +		 * If DAD indicates the address is already in use,
>>> +		 * the node must generate a new randomized interface
>>> +		 * identifier as described in section 3.2 above, and
>>> +		 * repeat the previous steps as appropriate up to
>>> +		 * TEMP_IDGEN_RETRIES times.
>>> +		 * If after TEMP_IDGEN_RETRIES consecutive attempts no
>>> +		 * non-unique address was generated, the node must log
>>> +		 * a system error and must not attempt to generate
>>> +		 * temporary address for that interface.
>>> +		 * So we have to check the return err and distinguish
>>> +		 * the correct retry path.
>>> +		 */
>>> +		if (PTR_ERR(ift) == -EEXIST) {
>>> +			pr_info("%s: retry temporary address regeneration\n", __func__);
>>> +			tmpaddr = &addr;
>>> +			write_lock(&idev->lock);
>>> +			goto retry;
>>> +		} else
>>> +			goto out;
>>
>> Correct me if I am wrong, but the RFC referes by mentioning "in use" to
>> allocated on the subnet and not in use by this host. I don't see how this
>> fixes the CVE then. dad is triggered by ipv6_add_addr.
> 
> Eric already posted a proposal. It seems it lacked testing. Maybe you could
> start from this?
> 
> http://permalink.gmane.org/gmane.linux.network/253518
> 
> Thanks for looking into this,
> 
>   Hannes
> 

the patch could not solve the problem, the use_tempaddr will still be -1 after the attack.

> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> .
> 

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

end of thread, other threads:[~2013-08-14  1:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-13  7:57 [PATCH 1/3 v2] ipv6: do not disable temp_address when reaching max_address Ding Tianhong
2013-08-13 11:05 ` Hannes Frederic Sowa
2013-08-13 11:53   ` Hannes Frederic Sowa
2013-08-14  1:39     ` Ding Tianhong
2013-08-14  1:34   ` Ding Tianhong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).