netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [SCTP]: Do not enable peer IPv6 address support on PF_INET socket
@ 2008-05-09 19:09 Vlad Yasevich
  2008-05-09 19:09 ` [PATCH] [SCTP]: Add address type check while process paramaters of ASCONF chunk Vlad Yasevich
  2008-05-09 22:11 ` [PATCH] [SCTP]: Do not enable peer IPv6 address support on PF_INET socket David Miller
  0 siblings, 2 replies; 11+ messages in thread
From: Vlad Yasevich @ 2008-05-09 19:09 UTC (permalink / raw)
  To: netdev; +Cc: davem, linux-sctp, lksctp-developers, Wei Yongjun, Vlad Yasevich

From: Wei Yongjun <yjwei@cn.fujitsu.com>

If socket is create by PF_INET type, it can not used IPv6 address to
send/recv DATA, So we can not used IPv6 address even if peer tell us it
support IPv6 address.
This patch fix to only enabled peer IPv6 address support on PF_INET6 socket.

Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
---
 net/sctp/sm_make_chunk.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index 81b6064..69a464f 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -2418,7 +2418,8 @@ static int sctp_process_param(struct sctp_association *asoc,
 				break;
 
 			case SCTP_PARAM_IPV6_ADDRESS:
-				asoc->peer.ipv6_address = 1;
+				if (PF_INET6 == asoc->base.sk->sk_family)
+					asoc->peer.ipv6_address = 1;
 				break;
 
 			case SCTP_PARAM_HOST_NAME_ADDRESS:
-- 
1.5.3.5


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

* [PATCH] [SCTP]: Add address type check while process paramaters of ASCONF chunk
  2008-05-09 19:09 [PATCH] [SCTP]: Do not enable peer IPv6 address support on PF_INET socket Vlad Yasevich
@ 2008-05-09 19:09 ` Vlad Yasevich
  2008-05-09 22:12   ` David Miller
  2008-05-13 11:30   ` Patrick McHardy
  2008-05-09 22:11 ` [PATCH] [SCTP]: Do not enable peer IPv6 address support on PF_INET socket David Miller
  1 sibling, 2 replies; 11+ messages in thread
From: Vlad Yasevich @ 2008-05-09 19:09 UTC (permalink / raw)
  To: netdev; +Cc: davem, linux-sctp, lksctp-developers, Wei Yongjun, Vlad Yasevich

From: Wei Yongjun <yjwei@cn.fujitsu.com>

If socket is create by AF_INET type, add IPv6 address to asoc will cause
kernel panic while packet is transmitted on that transport.

This patch add address type check before process paramaters of ASCONF
chunk. If peer is not support this address type, return with error
invald parameter.

Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
---
 net/sctp/sm_make_chunk.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index 69a464f..6eeee53 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -2827,6 +2827,19 @@ static __be16 sctp_process_asconf_param(struct sctp_association *asoc,
 	union sctp_addr	addr;
 	union sctp_addr_param *addr_param;
 
+	switch (addr_param->v4.param_hdr.type) {
+	case SCTP_PARAM_IPV6_ADDRESS:
+		if (!asoc->peer.ipv6_address)
+			return SCTP_ERROR_INV_PARAM;
+		break;
+	case SCTP_PARAM_IPV4_ADDRESS:
+		if (!asoc->peer.ipv4_address)
+			return SCTP_ERROR_INV_PARAM;
+		break;
+	default:
+		return SCTP_ERROR_INV_PARAM;
+	}
+
 	addr_param = (union sctp_addr_param *)
 			((void *)asconf_param + sizeof(sctp_addip_param_t));
 
-- 
1.5.3.5


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

* Re: [PATCH] [SCTP]: Do not enable peer IPv6 address support on PF_INET socket
  2008-05-09 19:09 [PATCH] [SCTP]: Do not enable peer IPv6 address support on PF_INET socket Vlad Yasevich
  2008-05-09 19:09 ` [PATCH] [SCTP]: Add address type check while process paramaters of ASCONF chunk Vlad Yasevich
@ 2008-05-09 22:11 ` David Miller
  1 sibling, 0 replies; 11+ messages in thread
From: David Miller @ 2008-05-09 22:11 UTC (permalink / raw)
  To: vladislav.yasevich; +Cc: netdev, linux-sctp, lksctp-developers, yjwei

From: Vlad Yasevich <vladislav.yasevich@hp.com>
Date: Fri,  9 May 2008 15:09:54 -0400

> If socket is create by PF_INET type, it can not used IPv6 address to
> send/recv DATA, So we can not used IPv6 address even if peer tell us it
> support IPv6 address.
> This patch fix to only enabled peer IPv6 address support on PF_INET6 socket.
> 
> Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
> Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>

Applied.

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

* Re: [PATCH] [SCTP]: Add address type check while process paramaters of ASCONF chunk
  2008-05-09 19:09 ` [PATCH] [SCTP]: Add address type check while process paramaters of ASCONF chunk Vlad Yasevich
@ 2008-05-09 22:12   ` David Miller
  2008-05-13 11:30   ` Patrick McHardy
  1 sibling, 0 replies; 11+ messages in thread
From: David Miller @ 2008-05-09 22:12 UTC (permalink / raw)
  To: vladislav.yasevich; +Cc: netdev, linux-sctp, lksctp-developers, yjwei

From: Vlad Yasevich <vladislav.yasevich@hp.com>
Date: Fri,  9 May 2008 15:09:55 -0400

> If socket is create by AF_INET type, add IPv6 address to asoc will cause
> kernel panic while packet is transmitted on that transport.
> 
> This patch add address type check before process paramaters of ASCONF
> chunk. If peer is not support this address type, return with error
> invald parameter.
> 
> Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
> Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>

Applied, thanks.

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

* Re: [PATCH] [SCTP]: Add address type check while process paramaters of ASCONF chunk
  2008-05-09 19:09 ` [PATCH] [SCTP]: Add address type check while process paramaters of ASCONF chunk Vlad Yasevich
  2008-05-09 22:12   ` David Miller
@ 2008-05-13 11:30   ` Patrick McHardy
  2008-05-13 12:48     ` Vlad Yasevich
  1 sibling, 1 reply; 11+ messages in thread
From: Patrick McHardy @ 2008-05-13 11:30 UTC (permalink / raw)
  To: Vlad Yasevich; +Cc: netdev, davem, linux-sctp, lksctp-developers, Wei Yongjun

[-- Attachment #1: Type: text/plain, Size: 731 bytes --]

Vlad Yasevich wrote:
> @@ -2827,6 +2827,19 @@ static __be16 sctp_process_asconf_param(struct sctp_association *asoc,
>  	union sctp_addr	addr;
>  	union sctp_addr_param *addr_param;
>  
> +	switch (addr_param->v4.param_hdr.type) {

^^^ use of addr_param

> +	case SCTP_PARAM_IPV6_ADDRESS:
> +		if (!asoc->peer.ipv6_address)
> +			return SCTP_ERROR_INV_PARAM;
> +		break;
> +	case SCTP_PARAM_IPV4_ADDRESS:
> +		if (!asoc->peer.ipv4_address)
> +			return SCTP_ERROR_INV_PARAM;
> +		break;
> +	default:
> +		return SCTP_ERROR_INV_PARAM;
> +	}
> +
>  	addr_param = (union sctp_addr_param *)
>  			((void *)asconf_param + sizeof(sctp_addip_param_t));

^^^ initialization of addr_param

The patch is wrong and needs this fix on top.





[-- Attachment #2: x --]
[-- Type: text/plain, Size: 1465 bytes --]

commit 1beb4530b5bf180d8989993d3050fabdf21522cc
Author: Patrick McHardy <kaber@trash.net>
Date:   Tue May 13 13:27:22 2008 +0200

    [SCTP]: Fix use of uninitialized pointer
    
    Introduced by c4492586 (sctp: Add address type check while process
    paramaters of ASCONF chunk):
    
    net/sctp/sm_make_chunk.c: In function 'sctp_process_asconf':
    net/sctp/sm_make_chunk.c:2828: warning: 'addr_param' may be used uninitialized in this function
    net/sctp/sm_make_chunk.c:2828: note: 'addr_param' was declared here
    
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index 6eeee53..bbc7107 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -2827,6 +2827,9 @@ static __be16 sctp_process_asconf_param(struct sctp_association *asoc,
 	union sctp_addr	addr;
 	union sctp_addr_param *addr_param;
 
+	addr_param = (union sctp_addr_param *)
+			((void *)asconf_param + sizeof(sctp_addip_param_t));
+
 	switch (addr_param->v4.param_hdr.type) {
 	case SCTP_PARAM_IPV6_ADDRESS:
 		if (!asoc->peer.ipv6_address)
@@ -2840,9 +2843,6 @@ static __be16 sctp_process_asconf_param(struct sctp_association *asoc,
 		return SCTP_ERROR_INV_PARAM;
 	}
 
-	addr_param = (union sctp_addr_param *)
-			((void *)asconf_param + sizeof(sctp_addip_param_t));
-
 	af = sctp_get_af_specific(param_type2af(addr_param->v4.param_hdr.type));
 	if (unlikely(!af))
 		return SCTP_ERROR_INV_PARAM;

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

* Re: [PATCH] [SCTP]: Add address type check while process paramaters of ASCONF chunk
  2008-05-13 11:30   ` Patrick McHardy
@ 2008-05-13 12:48     ` Vlad Yasevich
  2008-05-13 22:32       ` David Miller
  2008-05-14  6:25       ` David Miller
  0 siblings, 2 replies; 11+ messages in thread
From: Vlad Yasevich @ 2008-05-13 12:48 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: netdev, davem, linux-sctp, lksctp-developers, Wei Yongjun

Patrick McHardy wrote:
> Vlad Yasevich wrote:
>> @@ -2827,6 +2827,19 @@ static __be16 sctp_process_asconf_param(struct 
>> sctp_association *asoc,
>>      union sctp_addr    addr;
>>      union sctp_addr_param *addr_param;
>>  
>> +    switch (addr_param->v4.param_hdr.type) {
> 
> ^^^ use of addr_param
> 
>> +    case SCTP_PARAM_IPV6_ADDRESS:
>> +        if (!asoc->peer.ipv6_address)
>> +            return SCTP_ERROR_INV_PARAM;
>> +        break;
>> +    case SCTP_PARAM_IPV4_ADDRESS:
>> +        if (!asoc->peer.ipv4_address)
>> +            return SCTP_ERROR_INV_PARAM;
>> +        break;
>> +    default:
>> +        return SCTP_ERROR_INV_PARAM;
>> +    }
>> +
>>      addr_param = (union sctp_addr_param *)
>>              ((void *)asconf_param + sizeof(sctp_addip_param_t));
> 
> ^^^ initialization of addr_param
> 
> The patch is wrong and needs this fix on top.
> 

Ack.  David, please apply.  I missed this warning in the my builds...

Thanks
-vlad

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

* Re: [PATCH] [SCTP]: Add address type check while process paramaters of ASCONF chunk
  2008-05-13 12:48     ` Vlad Yasevich
@ 2008-05-13 22:32       ` David Miller
  2008-05-14  0:56         ` Wei Yongjun
  2008-05-14  6:25       ` David Miller
  1 sibling, 1 reply; 11+ messages in thread
From: David Miller @ 2008-05-13 22:32 UTC (permalink / raw)
  To: vladislav.yasevich; +Cc: kaber, netdev, linux-sctp, lksctp-developers, yjwei

From: Vlad Yasevich <vladislav.yasevich@hp.com>
Date: Tue, 13 May 2008 08:48:39 -0400

> I missed this warning in the my builds...

And in your testing of the patch too, right?

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

* Re: [PATCH] [SCTP]: Add address type check while process paramaters of ASCONF chunk
  2008-05-13 22:32       ` David Miller
@ 2008-05-14  0:56         ` Wei Yongjun
  2008-05-14  1:14           ` David Miller
  0 siblings, 1 reply; 11+ messages in thread
From: Wei Yongjun @ 2008-05-14  0:56 UTC (permalink / raw)
  To: David Miller
  Cc: vladislav.yasevich, kaber, netdev, linux-sctp, lksctp-developers

Hi David:

 Sorry for my mistake. This patch is create and tested by me.

 I tested it used a test tool which is created by me. And this patchset 
resolved the kernel panic problem. It seems that I need to do more 
review my patch and
add more test case to my tool. I will pay more attention to do the 
correct patchs.

 Thanks everyone.

David Miller wrote:
> From: Vlad Yasevich <vladislav.yasevich@hp.com>
> Date: Tue, 13 May 2008 08:48:39 -0400
>
>   
>> I missed this warning in the my builds...
>>     
>
> And in your testing of the patch too, right?
>
>   

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

* Re: [PATCH] [SCTP]: Add address type check while process paramaters of ASCONF chunk
  2008-05-14  0:56         ` Wei Yongjun
@ 2008-05-14  1:14           ` David Miller
  2008-05-14  1:49             ` Wei Yongjun
  0 siblings, 1 reply; 11+ messages in thread
From: David Miller @ 2008-05-14  1:14 UTC (permalink / raw)
  To: yjwei; +Cc: vladislav.yasevich, kaber, netdev, linux-sctp, lksctp-developers

From: Wei Yongjun <yjwei@cn.fujitsu.com>
Date: Wed, 14 May 2008 08:56:21 +0800

> Hi David:
> 
>  Sorry for my mistake. This patch is create and tested by me.
> 
>  I tested it used a test tool which is created by me. And this patchset 
> resolved the kernel panic problem. It seems that I need to do more 
> review my patch and
> add more test case to my tool. I will pay more attention to do the 
> correct patchs.

It dereferences an uninitialized pointer, unconditionally.  Therefore,
the patch was definitely completely untested.  This function never ran
during your tests.

Please, no more excuses.

You didn't test the patch.
The end.

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

* Re: [PATCH] [SCTP]: Add address type check while process paramaters of ASCONF chunk
  2008-05-14  1:14           ` David Miller
@ 2008-05-14  1:49             ` Wei Yongjun
  0 siblings, 0 replies; 11+ messages in thread
From: Wei Yongjun @ 2008-05-14  1:49 UTC (permalink / raw)
  To: David Miller
  Cc: vladislav.yasevich, kaber, netdev, linux-sctp, lksctp-developers

David Miller wrote:
> From: Wei Yongjun <yjwei@cn.fujitsu.com>
> Date: Wed, 14 May 2008 08:56:21 +0800
>
>   
>> Hi David:
>>
>>  Sorry for my mistake. This patch is create and tested by me.
>>
>>  I tested it used a test tool which is created by me. And this patchset 
>> resolved the kernel panic problem. It seems that I need to do more 
>> review my patch and
>> add more test case to my tool. I will pay more attention to do the 
>> correct patchs.
>>     
>
> It dereferences an uninitialized pointer, unconditionally.  Therefore,
> the patch was definitely completely untested.  This function never ran
> during your tests.
>
> Please, no more excuses.
>
> You didn't test the patch.
> The end.
>   

Are you sure you are right?

First I am sorry for stupid patch, second I said again, I do test it, 
but do not enough test.

uninitialized pointer is not NULL pointer, so it not kernel panic when 
use "addr_param->v4.param_hdr.type", this patch cause function alaways 
return SCTP_ERROR_INV_PARAM error, so even if I add IPv6 address to peer 
which not supported IPv6 address or add IPv4 address to peer which not 
supported IPv4 address is returned SCTP_ERROR_INV_PARAM, and passed my 
test case.
I not do test add IPv4/IPv6 address to peer which supported IPv4/IPv6 
address, this is my fault .







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

* Re: [PATCH] [SCTP]: Add address type check while process paramaters of ASCONF chunk
  2008-05-13 12:48     ` Vlad Yasevich
  2008-05-13 22:32       ` David Miller
@ 2008-05-14  6:25       ` David Miller
  1 sibling, 0 replies; 11+ messages in thread
From: David Miller @ 2008-05-14  6:25 UTC (permalink / raw)
  To: vladislav.yasevich; +Cc: kaber, netdev, linux-sctp, lksctp-developers, yjwei

From: Vlad Yasevich <vladislav.yasevich@hp.com>
Date: Tue, 13 May 2008 08:48:39 -0400

> Patrick McHardy wrote:
> > The patch is wrong and needs this fix on top.
> > 
> 
> Ack.  David, please apply.

Done, thanks everyone.


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

end of thread, other threads:[~2008-05-14  6:25 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-09 19:09 [PATCH] [SCTP]: Do not enable peer IPv6 address support on PF_INET socket Vlad Yasevich
2008-05-09 19:09 ` [PATCH] [SCTP]: Add address type check while process paramaters of ASCONF chunk Vlad Yasevich
2008-05-09 22:12   ` David Miller
2008-05-13 11:30   ` Patrick McHardy
2008-05-13 12:48     ` Vlad Yasevich
2008-05-13 22:32       ` David Miller
2008-05-14  0:56         ` Wei Yongjun
2008-05-14  1:14           ` David Miller
2008-05-14  1:49             ` Wei Yongjun
2008-05-14  6:25       ` David Miller
2008-05-09 22:11 ` [PATCH] [SCTP]: Do not enable peer IPv6 address support on PF_INET socket David Miller

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).