netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xfrm: use ISO C standard for array in linux/xfrm.h
@ 2012-10-16 15:42 nicolas.dichtel
  2012-10-17  5:43 ` Steffen Klassert
  0 siblings, 1 reply; 6+ messages in thread
From: nicolas.dichtel @ 2012-10-16 15:42 UTC (permalink / raw)
  To: herbert, steffen.klassert; +Cc: netdev, davem, Nicolas Dichtel

From: Nicolas Dichtel <nicolas.dichtel@6wind.com>

Use the ISO C standard compliant form instead of the gcc extension.

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 include/uapi/linux/xfrm.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/uapi/linux/xfrm.h b/include/uapi/linux/xfrm.h
index 28e493b..6a6a605 100644
--- a/include/uapi/linux/xfrm.h
+++ b/include/uapi/linux/xfrm.h
@@ -30,7 +30,7 @@ struct xfrm_sec_ctx {
 	__u8	ctx_alg;
 	__u16	ctx_len;
 	__u32	ctx_sid;
-	char	ctx_str[0];
+	char	ctx_str[];
 };
 
 /* Security Context Domains of Interpretation */
@@ -93,27 +93,27 @@ struct xfrm_replay_state_esn {
 	__u32		oseq_hi;
 	__u32		seq_hi;
 	__u32		replay_window;
-	__u32		bmp[0];
+	__u32		bmp[];
 };
 
 struct xfrm_algo {
 	char		alg_name[64];
 	unsigned int	alg_key_len;    /* in bits */
-	char		alg_key[0];
+	char		alg_key[];
 };
 
 struct xfrm_algo_auth {
 	char		alg_name[64];
 	unsigned int	alg_key_len;    /* in bits */
 	unsigned int	alg_trunc_len;  /* in bits */
-	char		alg_key[0];
+	char		alg_key[];
 };
 
 struct xfrm_algo_aead {
 	char		alg_name[64];
 	unsigned int	alg_key_len;	/* in bits */
 	unsigned int	alg_icv_len;	/* in bits */
-	char		alg_key[0];
+	char		alg_key[];
 };
 
 struct xfrm_stats {
-- 
1.7.12

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

* Re: [PATCH] xfrm: use ISO C standard for array in linux/xfrm.h
  2012-10-16 15:42 [PATCH] xfrm: use ISO C standard for array in linux/xfrm.h nicolas.dichtel
@ 2012-10-17  5:43 ` Steffen Klassert
  2012-10-17  6:16   ` David Miller
  2012-10-17  7:50   ` Nicolas Dichtel
  0 siblings, 2 replies; 6+ messages in thread
From: Steffen Klassert @ 2012-10-17  5:43 UTC (permalink / raw)
  To: nicolas.dichtel; +Cc: herbert, netdev, davem

On Tue, Oct 16, 2012 at 05:42:33PM +0200, nicolas.dichtel@6wind.com wrote:
> From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
> 
> Use the ISO C standard compliant form instead of the gcc extension.
> 
> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
> ---
>  include/uapi/linux/xfrm.h | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/include/uapi/linux/xfrm.h b/include/uapi/linux/xfrm.h
> index 28e493b..6a6a605 100644
> --- a/include/uapi/linux/xfrm.h
> +++ b/include/uapi/linux/xfrm.h
> @@ -30,7 +30,7 @@ struct xfrm_sec_ctx {
>  	__u8	ctx_alg;
>  	__u16	ctx_len;
>  	__u32	ctx_sid;
> -	char	ctx_str[0];
> +	char	ctx_str[];

Hm, what's the benefit of such a change? The kernel source is full
of these foo[0] type arrays. I don't see a reason to change this
just for xfrm.

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

* Re: [PATCH] xfrm: use ISO C standard for array in linux/xfrm.h
  2012-10-17  5:43 ` Steffen Klassert
@ 2012-10-17  6:16   ` David Miller
  2012-10-17  7:50   ` Nicolas Dichtel
  1 sibling, 0 replies; 6+ messages in thread
From: David Miller @ 2012-10-17  6:16 UTC (permalink / raw)
  To: steffen.klassert; +Cc: nicolas.dichtel, herbert, netdev

From: Steffen Klassert <steffen.klassert@secunet.com>
Date: Wed, 17 Oct 2012 07:43:43 +0200

> On Tue, Oct 16, 2012 at 05:42:33PM +0200, nicolas.dichtel@6wind.com wrote:
>> From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
>> 
>> Use the ISO C standard compliant form instead of the gcc extension.
>> 
>> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
>> ---
>>  include/uapi/linux/xfrm.h | 10 +++++-----
>>  1 file changed, 5 insertions(+), 5 deletions(-)
>> 
>> diff --git a/include/uapi/linux/xfrm.h b/include/uapi/linux/xfrm.h
>> index 28e493b..6a6a605 100644
>> --- a/include/uapi/linux/xfrm.h
>> +++ b/include/uapi/linux/xfrm.h
>> @@ -30,7 +30,7 @@ struct xfrm_sec_ctx {
>>  	__u8	ctx_alg;
>>  	__u16	ctx_len;
>>  	__u32	ctx_sid;
>> -	char	ctx_str[0];
>> +	char	ctx_str[];
> 
> Hm, what's the benefit of such a change? The kernel source is full
> of these foo[0] type arrays. I don't see a reason to change this
> just for xfrm.

Agreed.

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

* Re: [PATCH] xfrm: use ISO C standard for array in linux/xfrm.h
  2012-10-17  5:43 ` Steffen Klassert
  2012-10-17  6:16   ` David Miller
@ 2012-10-17  7:50   ` Nicolas Dichtel
  2012-10-17  8:27     ` Steffen Klassert
  1 sibling, 1 reply; 6+ messages in thread
From: Nicolas Dichtel @ 2012-10-17  7:50 UTC (permalink / raw)
  To: Steffen Klassert; +Cc: herbert, netdev, davem

Le 17/10/2012 07:43, Steffen Klassert a écrit :
> On Tue, Oct 16, 2012 at 05:42:33PM +0200, nicolas.dichtel@6wind.com wrote:
>> From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
>>
>> Use the ISO C standard compliant form instead of the gcc extension.
>>
>> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
>> ---
>>   include/uapi/linux/xfrm.h | 10 +++++-----
>>   1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/include/uapi/linux/xfrm.h b/include/uapi/linux/xfrm.h
>> index 28e493b..6a6a605 100644
>> --- a/include/uapi/linux/xfrm.h
>> +++ b/include/uapi/linux/xfrm.h
>> @@ -30,7 +30,7 @@ struct xfrm_sec_ctx {
>>   	__u8	ctx_alg;
>>   	__u16	ctx_len;
>>   	__u32	ctx_sid;
>> -	char	ctx_str[0];
>> +	char	ctx_str[];
>
> Hm, what's the benefit of such a change? The kernel source is full
> of these foo[0] type arrays. I don't see a reason to change this
> just for xfrm.
>
We got a problem with "ip xfrm state add" when compiled with gcc 4.4.6.
Error was "*** buffer overflow detected ***: ip terminated", because when we try 
to copy the key in struct xfrm_algo, the function strncpy() calls some builtin 
checks about the size of the destination buffer, which is 0. With the standard 
notation, there is no problem.

With gcc 4.7.0, there is no problem, I don't know exactly which version of gcc 
triggers the problem.

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

* Re: [PATCH] xfrm: use ISO C standard for array in linux/xfrm.h
  2012-10-17  7:50   ` Nicolas Dichtel
@ 2012-10-17  8:27     ` Steffen Klassert
  2012-10-17  9:03       ` Nicolas Dichtel
  0 siblings, 1 reply; 6+ messages in thread
From: Steffen Klassert @ 2012-10-17  8:27 UTC (permalink / raw)
  To: Nicolas Dichtel; +Cc: herbert, netdev, davem

On Wed, Oct 17, 2012 at 09:50:58AM +0200, Nicolas Dichtel wrote:
> We got a problem with "ip xfrm state add" when compiled with gcc 4.4.6.
> Error was "*** buffer overflow detected ***: ip terminated", because
> when we try to copy the key in struct xfrm_algo, the function
> strncpy() calls some builtin checks about the size of the
> destination buffer, which is 0. With the standard notation, there is
> no problem.

This is likely to be a gcc FORITFY bug. Try to build iproute2 with
the -D_FORTIFY_SOURCE=0 flag.

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

* Re: [PATCH] xfrm: use ISO C standard for array in linux/xfrm.h
  2012-10-17  8:27     ` Steffen Klassert
@ 2012-10-17  9:03       ` Nicolas Dichtel
  0 siblings, 0 replies; 6+ messages in thread
From: Nicolas Dichtel @ 2012-10-17  9:03 UTC (permalink / raw)
  To: Steffen Klassert; +Cc: herbert, netdev, davem

Le 17/10/2012 10:27, Steffen Klassert a écrit :
> On Wed, Oct 17, 2012 at 09:50:58AM +0200, Nicolas Dichtel wrote:
>> We got a problem with "ip xfrm state add" when compiled with gcc 4.4.6.
>> Error was "*** buffer overflow detected ***: ip terminated", because
>> when we try to copy the key in struct xfrm_algo, the function
>> strncpy() calls some builtin checks about the size of the
>> destination buffer, which is 0. With the standard notation, there is
>> no problem.
>
> This is likely to be a gcc FORITFY bug. Try to build iproute2 with
> the -D_FORTIFY_SOURCE=0 flag.
>
Right, it works. Thank you.

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

end of thread, other threads:[~2012-10-17  9:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-16 15:42 [PATCH] xfrm: use ISO C standard for array in linux/xfrm.h nicolas.dichtel
2012-10-17  5:43 ` Steffen Klassert
2012-10-17  6:16   ` David Miller
2012-10-17  7:50   ` Nicolas Dichtel
2012-10-17  8:27     ` Steffen Klassert
2012-10-17  9:03       ` Nicolas Dichtel

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