netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iptables] libxt_sctp: fix array out of range in print_chunk
@ 2017-11-10 10:49 Nicolas Dichtel
  2017-11-13 12:38 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Dichtel @ 2017-11-10 10:49 UTC (permalink / raw)
  To: pablo; +Cc: netfilter-devel, huaibin Wang, Nicolas Dichtel

From: huaibin Wang <huaibin.wang@6wind.com>

For chunk type ASCONF, ASCONF_ACK and FORWARD_TSN, sctp_chunk_names[].chunk_type
is not equal to the corresponding index in sctp_chunk_names[]. Using this field
leads to a segmentation fault (index out of range).

Example
$ iptables -A INPUT -p sctp --chunk-type all ASCONF,ASCONF_ACK,FORWARD_TSN -j ACCEPT
$ iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
Segmentation fault

Signed-off-by: huaibin Wang <huaibin.wang@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 extensions/libxt_sctp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/extensions/libxt_sctp.c b/extensions/libxt_sctp.c
index df1936be8b83..140de2653b1e 100644
--- a/extensions/libxt_sctp.c
+++ b/extensions/libxt_sctp.c
@@ -370,7 +370,7 @@ print_chunk(uint32_t chunknum, int numeric)
 
 		for (i = 0; i < ARRAY_SIZE(sctp_chunk_names); ++i)
 			if (sctp_chunk_names[i].chunk_type == chunknum)
-				printf("%s", sctp_chunk_names[chunknum].name);
+				printf("%s", sctp_chunk_names[i].name);
 	}
 }
 
-- 
2.13.2


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

* Re: [PATCH iptables] libxt_sctp: fix array out of range in print_chunk
  2017-11-10 10:49 [PATCH iptables] libxt_sctp: fix array out of range in print_chunk Nicolas Dichtel
@ 2017-11-13 12:38 ` Pablo Neira Ayuso
  2017-11-13 13:27   ` [PATCH iptables v2] " Nicolas Dichtel
  0 siblings, 1 reply; 4+ messages in thread
From: Pablo Neira Ayuso @ 2017-11-13 12:38 UTC (permalink / raw)
  To: Nicolas Dichtel; +Cc: netfilter-devel, huaibin Wang

Hi Nicolas,

On Fri, Nov 10, 2017 at 11:49:05AM +0100, Nicolas Dichtel wrote:
> From: huaibin Wang <huaibin.wang@6wind.com>
> 
> For chunk type ASCONF, ASCONF_ACK and FORWARD_TSN, sctp_chunk_names[].chunk_type
> is not equal to the corresponding index in sctp_chunk_names[]. Using this field
> leads to a segmentation fault (index out of range).
> 
> Example
> $ iptables -A INPUT -p sctp --chunk-type all ASCONF,ASCONF_ACK,FORWARD_TSN -j ACCEPT
> $ iptables -L
> Chain INPUT (policy ACCEPT)
> target     prot opt source               destination
> Segmentation fault
> 
> Signed-off-by: huaibin Wang <huaibin.wang@6wind.com>
> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
> ---
>  extensions/libxt_sctp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/extensions/libxt_sctp.c b/extensions/libxt_sctp.c
> index df1936be8b83..140de2653b1e 100644
> --- a/extensions/libxt_sctp.c
> +++ b/extensions/libxt_sctp.c
> @@ -370,7 +370,7 @@ print_chunk(uint32_t chunknum, int numeric)
>  
>  		for (i = 0; i < ARRAY_SIZE(sctp_chunk_names); ++i)
>  			if (sctp_chunk_names[i].chunk_type == chunknum)
> -				printf("%s", sctp_chunk_names[chunknum].name);
> +				printf("%s", sctp_chunk_names[i].name);

Can we get a test for iptables/extensions/libxt_sctp.t ?

Thanks!

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

* [PATCH iptables v2] libxt_sctp: fix array out of range in print_chunk
  2017-11-13 12:38 ` Pablo Neira Ayuso
@ 2017-11-13 13:27   ` Nicolas Dichtel
  2017-11-13 13:29     ` Pablo Neira Ayuso
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Dichtel @ 2017-11-13 13:27 UTC (permalink / raw)
  To: pablo; +Cc: netfilter-devel, huaibin Wang, Nicolas Dichtel

From: huaibin Wang <huaibin.wang@6wind.com>

For chunk type ASCONF, ASCONF_ACK and FORWARD_TSN, sctp_chunk_names[].chunk_type
is not equal to the corresponding index in sctp_chunk_names[]. Using this field
leads to a segmentation fault (index out of range).

Example
$ iptables -A INPUT -p sctp --chunk-type all ASCONF,ASCONF_ACK,FORWARD_TSN -j ACCEPT
$ iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
Segmentation fault

Signed-off-by: huaibin Wang <huaibin.wang@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---

v1 -> v2:
 uncomment corresponding tests

 extensions/libxt_sctp.c | 2 +-
 extensions/libxt_sctp.t | 9 +++------
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/extensions/libxt_sctp.c b/extensions/libxt_sctp.c
index df1936be8b83..140de2653b1e 100644
--- a/extensions/libxt_sctp.c
+++ b/extensions/libxt_sctp.c
@@ -370,7 +370,7 @@ print_chunk(uint32_t chunknum, int numeric)
 
 		for (i = 0; i < ARRAY_SIZE(sctp_chunk_names); ++i)
 			if (sctp_chunk_names[i].chunk_type == chunknum)
-				printf("%s", sctp_chunk_names[chunknum].name);
+				printf("%s", sctp_chunk_names[i].name);
 	}
 }
 
diff --git a/extensions/libxt_sctp.t b/extensions/libxt_sctp.t
index 2f75e2a68e8e..4016e4fb1880 100644
--- a/extensions/libxt_sctp.t
+++ b/extensions/libxt_sctp.t
@@ -23,10 +23,7 @@
 -p sctp -m sctp --chunk-types all COOKIE_ACK;=;OK
 -p sctp -m sctp --chunk-types all ECN_ECNE;=;OK
 -p sctp -m sctp --chunk-types all ECN_CWR;=;OK
-# ERROR: iptables-save segfaults: iptables -A INPUT -p sctp -m sctp --chunk-types all ASCONF
-# -p sctp -m sctp --chunk-types all ASCONF;=;OK
-# ERROR: iptables-save segfaults: iptables -A INPUT -p sctp -m sctp --chunk-types all ASCONF_ACK
-# -p sctp -m sctp --chunk-types all ASCONF_ACK;=;OK
-# ERROR: iptables-save segfaults: iptables -A INPUT -p sctp -m sctp --chunk-types all FORWARD_TSN
-# -p sctp -m sctp --chunk-types all FORWARD_TSN;=;OK
+-p sctp -m sctp --chunk-types all ASCONF;=;OK
+-p sctp -m sctp --chunk-types all ASCONF_ACK;=;OK
+-p sctp -m sctp --chunk-types all FORWARD_TSN;=;OK
 -p sctp -m sctp --chunk-types all SHUTDOWN_COMPLETE;=;OK
-- 
2.13.2


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

* Re: [PATCH iptables v2] libxt_sctp: fix array out of range in print_chunk
  2017-11-13 13:27   ` [PATCH iptables v2] " Nicolas Dichtel
@ 2017-11-13 13:29     ` Pablo Neira Ayuso
  0 siblings, 0 replies; 4+ messages in thread
From: Pablo Neira Ayuso @ 2017-11-13 13:29 UTC (permalink / raw)
  To: Nicolas Dichtel; +Cc: netfilter-devel, huaibin Wang

On Mon, Nov 13, 2017 at 02:27:54PM +0100, Nicolas Dichtel wrote:
> From: huaibin Wang <huaibin.wang@6wind.com>
> 
> For chunk type ASCONF, ASCONF_ACK and FORWARD_TSN, sctp_chunk_names[].chunk_type
> is not equal to the corresponding index in sctp_chunk_names[]. Using this field
> leads to a segmentation fault (index out of range).
> 
> Example
> $ iptables -A INPUT -p sctp --chunk-type all ASCONF,ASCONF_ACK,FORWARD_TSN -j ACCEPT
> $ iptables -L
> Chain INPUT (policy ACCEPT)
> target     prot opt source               destination
> Segmentation fault

Applied, thanks a lot Nicolas.

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

end of thread, other threads:[~2017-11-13 13:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-10 10:49 [PATCH iptables] libxt_sctp: fix array out of range in print_chunk Nicolas Dichtel
2017-11-13 12:38 ` Pablo Neira Ayuso
2017-11-13 13:27   ` [PATCH iptables v2] " Nicolas Dichtel
2017-11-13 13:29     ` Pablo Neira Ayuso

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