Re: [PATCH 4/11] use ether_addr_equal_64bits

2014-01-17 Thread Dan Carpenter
We're worried about reading beyond the end of the array and it's a heap allocation and the last char of the eth addr is the last byte of the page. This causes an oops. It's almost impossible to hit that bug. 1) You would have to have the eth addr at the end of the array. 2) It would have to be

Re: [PATCH 4/11] use ether_addr_equal_64bits

2014-01-17 Thread Dan Carpenter
We're worried about reading beyond the end of the array and it's a heap allocation and the last char of the eth addr is the last byte of the page. This causes an oops. It's almost impossible to hit that bug. 1) You would have to have the eth addr at the end of the array. 2) It would have to be

Re: [PATCH 4/11] use ether_addr_equal_64bits

2014-01-06 Thread Eric Dumazet
On Mon, 2014-01-06 at 10:24 +0100, Geert Uytterhoeven wrote: > Thanks to this discussion, my eye fell on: > > static inline unsigned compare_ether_addr(const u8 *addr1, const u8 *addr2) > { > const u16 *a = (const u16 *) addr1; > const u16 *b = (const u16 *) addr2; > >

Re: [PATCH 4/11] use ether_addr_equal_64bits

2014-01-06 Thread Dan Carpenter
On Tue, Dec 31, 2013 at 12:13:08AM +0100, Johannes Berg wrote: > On Mon, 2013-12-30 at 19:57 -0200, Henrique de Moraes Holschuh wrote: > > On Mon, 30 Dec 2013, Johannes Berg wrote: > > > On Mon, 2013-12-30 at 20:58 +0100, Julia Lawall wrote: > > > > > Is there any way we could catch (sparse, or

Re: [PATCH 4/11] use ether_addr_equal_64bits

2014-01-06 Thread Johannes Berg
On Mon, 2014-01-06 at 10:09 +0100, Julia Lawall wrote: > > BUILD_BUG_ON(sizeof(struct foo) - offsetof(struct foo, addr) < 8); > > > > with the user(s?) and that should catch the scenario I was worrying > > about? > > OK, thanks. That is what I had in mind. But I was hoping to be able to > put

Re: [PATCH 4/11] use ether_addr_equal_64bits

2014-01-06 Thread Julia Lawall
On Mon, 6 Jan 2014, Geert Uytterhoeven wrote: > On Tue, Dec 31, 2013 at 7:26 AM, Emmanuel Grumbach > wrote: > > On Tue, Dec 31, 2013 at 1:13 AM, Johannes Berg > > wrote: > >> > >> On Mon, 2013-12-30 at 19:57 -0200, Henrique de Moraes Holschuh wrote: > >> > On Mon, 30 Dec 2013, Johannes Berg

Re: [PATCH 4/11] use ether_addr_equal_64bits

2014-01-06 Thread Geert Uytterhoeven
On Tue, Dec 31, 2013 at 7:26 AM, Emmanuel Grumbach wrote: > On Tue, Dec 31, 2013 at 1:13 AM, Johannes Berg > wrote: >> >> On Mon, 2013-12-30 at 19:57 -0200, Henrique de Moraes Holschuh wrote: >> > On Mon, 30 Dec 2013, Johannes Berg wrote: >> > > On Mon, 2013-12-30 at 20:58 +0100, Julia Lawall

Re: [PATCH 4/11] use ether_addr_equal_64bits

2014-01-06 Thread Julia Lawall
On Mon, 6 Jan 2014, Johannes Berg wrote: > On Mon, 2014-01-06 at 10:04 +0100, Julia Lawall wrote: > > > OK, the question was expressed badly. Is there any way to use the value > > to trigger an action at build time? The only way I kow to trigger an > > action is with #error, but #error is

Re: [PATCH 4/11] use ether_addr_equal_64bits

2014-01-06 Thread Julia Lawall
On Mon, 6 Jan 2014, Johannes Berg wrote: > On Tue, 2013-12-31 at 17:40 +0100, Julia Lawall wrote: > > > > If nothing else, then some run-time code that calculates the offset off > > > and asserts if it is broken in module initialization or similar might > > > be good enough. > > > > Could be OK.

Re: [PATCH 4/11] use ether_addr_equal_64bits

2014-01-06 Thread Johannes Berg
On Mon, 2014-01-06 at 10:04 +0100, Julia Lawall wrote: > OK, the question was expressed badly. Is there any way to use the value > to trigger an action at build time? The only way I kow to trigger an > action is with #error, but #error is processed by cpp, which doesn't know > about the size of

Re: [PATCH 4/11] use ether_addr_equal_64bits

2014-01-06 Thread Johannes Berg
On Tue, 2013-12-31 at 17:40 +0100, Julia Lawall wrote: > > If nothing else, then some run-time code that calculates the offset off > > and asserts if it is broken in module initialization or similar might > > be good enough. > > Could be OK. Something right in or after the structure declaration

Re: [PATCH 4/11] use ether_addr_equal_64bits

2014-01-06 Thread Julia Lawall
On Mon, 6 Jan 2014, Joe Perches wrote: > On Mon, 2014-01-06 at 09:48 +0100, Julia Lawall wrote: > > Is there any way to get sizeof evaluated at build time? > > I'm confused a bit by what you want to accomplish. To check that a field that is an argument od ether_addr_equal_64bits is a sufficient

Re: [PATCH 4/11] use ether_addr_equal_64bits

2014-01-06 Thread Joe Perches
On Mon, 2014-01-06 at 09:48 +0100, Julia Lawall wrote: > Is there any way to get sizeof evaluated at build time? I'm confused a bit by what you want to accomplish. Except for variable length arrays, isn't sizeof always evaluated at build time? 6.5.3.4 The sizeof operator Constraints [] 2 The

Re: [PATCH 4/11] use ether_addr_equal_64bits

2014-01-06 Thread Julia Lawall
Is there any way to get sizeof evaluated at build time? julia -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at

Re: [PATCH 4/11] use ether_addr_equal_64bits

2014-01-06 Thread Julia Lawall
Is there any way to get sizeof evaluated at build time? julia -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at

Re: [PATCH 4/11] use ether_addr_equal_64bits

2014-01-06 Thread Joe Perches
On Mon, 2014-01-06 at 09:48 +0100, Julia Lawall wrote: Is there any way to get sizeof evaluated at build time? I'm confused a bit by what you want to accomplish. Except for variable length arrays, isn't sizeof always evaluated at build time? 6.5.3.4 The sizeof operator Constraints [] 2 The

Re: [PATCH 4/11] use ether_addr_equal_64bits

2014-01-06 Thread Julia Lawall
On Mon, 6 Jan 2014, Joe Perches wrote: On Mon, 2014-01-06 at 09:48 +0100, Julia Lawall wrote: Is there any way to get sizeof evaluated at build time? I'm confused a bit by what you want to accomplish. To check that a field that is an argument od ether_addr_equal_64bits is a sufficient

Re: [PATCH 4/11] use ether_addr_equal_64bits

2014-01-06 Thread Johannes Berg
On Tue, 2013-12-31 at 17:40 +0100, Julia Lawall wrote: If nothing else, then some run-time code that calculates the offset off and asserts if it is broken in module initialization or similar might be good enough. Could be OK. Something right in or after the structure declaration would

Re: [PATCH 4/11] use ether_addr_equal_64bits

2014-01-06 Thread Johannes Berg
On Mon, 2014-01-06 at 10:04 +0100, Julia Lawall wrote: OK, the question was expressed badly. Is there any way to use the value to trigger an action at build time? The only way I kow to trigger an action is with #error, but #error is processed by cpp, which doesn't know about the size of

Re: [PATCH 4/11] use ether_addr_equal_64bits

2014-01-06 Thread Julia Lawall
On Mon, 6 Jan 2014, Johannes Berg wrote: On Tue, 2013-12-31 at 17:40 +0100, Julia Lawall wrote: If nothing else, then some run-time code that calculates the offset off and asserts if it is broken in module initialization or similar might be good enough. Could be OK. Something

Re: [PATCH 4/11] use ether_addr_equal_64bits

2014-01-06 Thread Julia Lawall
On Mon, 6 Jan 2014, Johannes Berg wrote: On Mon, 2014-01-06 at 10:04 +0100, Julia Lawall wrote: OK, the question was expressed badly. Is there any way to use the value to trigger an action at build time? The only way I kow to trigger an action is with #error, but #error is processed by

Re: [PATCH 4/11] use ether_addr_equal_64bits

2014-01-06 Thread Geert Uytterhoeven
On Tue, Dec 31, 2013 at 7:26 AM, Emmanuel Grumbach egrumb...@gmail.com wrote: On Tue, Dec 31, 2013 at 1:13 AM, Johannes Berg johan...@sipsolutions.net wrote: On Mon, 2013-12-30 at 19:57 -0200, Henrique de Moraes Holschuh wrote: On Mon, 30 Dec 2013, Johannes Berg wrote: On Mon, 2013-12-30

Re: [PATCH 4/11] use ether_addr_equal_64bits

2014-01-06 Thread Julia Lawall
On Mon, 6 Jan 2014, Geert Uytterhoeven wrote: On Tue, Dec 31, 2013 at 7:26 AM, Emmanuel Grumbach egrumb...@gmail.com wrote: On Tue, Dec 31, 2013 at 1:13 AM, Johannes Berg johan...@sipsolutions.net wrote: On Mon, 2013-12-30 at 19:57 -0200, Henrique de Moraes Holschuh wrote: On Mon,

Re: [PATCH 4/11] use ether_addr_equal_64bits

2014-01-06 Thread Johannes Berg
On Mon, 2014-01-06 at 10:09 +0100, Julia Lawall wrote: BUILD_BUG_ON(sizeof(struct foo) - offsetof(struct foo, addr) 8); with the user(s?) and that should catch the scenario I was worrying about? OK, thanks. That is what I had in mind. But I was hoping to be able to put it with the

Re: [PATCH 4/11] use ether_addr_equal_64bits

2014-01-06 Thread Dan Carpenter
On Tue, Dec 31, 2013 at 12:13:08AM +0100, Johannes Berg wrote: On Mon, 2013-12-30 at 19:57 -0200, Henrique de Moraes Holschuh wrote: On Mon, 30 Dec 2013, Johannes Berg wrote: On Mon, 2013-12-30 at 20:58 +0100, Julia Lawall wrote: Is there any way we could catch (sparse, or some other

Re: [PATCH 4/11] use ether_addr_equal_64bits

2014-01-06 Thread Eric Dumazet
On Mon, 2014-01-06 at 10:24 +0100, Geert Uytterhoeven wrote: Thanks to this discussion, my eye fell on: static inline unsigned compare_ether_addr(const u8 *addr1, const u8 *addr2) { const u16 *a = (const u16 *) addr1; const u16 *b = (const u16 *) addr2;

Re: [PATCH 4/11] use ether_addr_equal_64bits

2013-12-31 Thread Julia Lawall
On Tue, 31 Dec 2013, Ben Greear wrote: > On 12/31/2013 08:09 AM, Julia Lawall wrote: > > > > > > On Tue, 31 Dec 2013, Ben Greear wrote: > > > > > On 12/30/2013 10:32 PM, Julia Lawall wrote: > > > > > > > > I'm just thinking of a programmer, e.g. changing a struct like > > > > > > > > this: > >

Re: [PATCH 4/11] use ether_addr_equal_64bits

2013-12-31 Thread Ben Greear
On 12/31/2013 08:09 AM, Julia Lawall wrote: On Tue, 31 Dec 2013, Ben Greear wrote: On 12/30/2013 10:32 PM, Julia Lawall wrote: I'm just thinking of a programmer, e.g. changing a struct like this: struct foo { u8 addr[ETH_ALEN]; - u16 dummy; }; I don't know of a way to catch

Re: [PATCH 4/11] use ether_addr_equal_64bits

2013-12-31 Thread Julia Lawall
On Tue, 31 Dec 2013, Ben Greear wrote: > On 12/30/2013 10:32 PM, Julia Lawall wrote: > > > > > > I'm just thinking of a programmer, e.g. changing a struct like this: > > > > > > > > > > > > struct foo { > > > > > > u8 addr[ETH_ALEN]; > > > > > > - u16 dummy; > > > > > > }; > > > > > >

Re: [PATCH 4/11] use ether_addr_equal_64bits

2013-12-31 Thread Ben Greear
On 12/30/2013 10:32 PM, Julia Lawall wrote: I'm just thinking of a programmer, e.g. changing a struct like this: struct foo { u8 addr[ETH_ALEN]; - u16 dummy; }; I don't know of a way to catch that. Anyone else? Well, one could have a semantic patch that checks for that. But the

Re: [PATCH 4/11] use ether_addr_equal_64bits

2013-12-31 Thread Ben Greear
On 12/30/2013 10:32 PM, Julia Lawall wrote: I'm just thinking of a programmer, e.g. changing a struct like this: struct foo { u8 addr[ETH_ALEN]; - u16 dummy; }; I don't know of a way to catch that. Anyone else? Well, one could have a semantic patch that checks for that. But the

Re: [PATCH 4/11] use ether_addr_equal_64bits

2013-12-31 Thread Julia Lawall
On Tue, 31 Dec 2013, Ben Greear wrote: On 12/30/2013 10:32 PM, Julia Lawall wrote: I'm just thinking of a programmer, e.g. changing a struct like this: struct foo { u8 addr[ETH_ALEN]; - u16 dummy; }; I don't know of a way to catch that.

Re: [PATCH 4/11] use ether_addr_equal_64bits

2013-12-31 Thread Ben Greear
On 12/31/2013 08:09 AM, Julia Lawall wrote: On Tue, 31 Dec 2013, Ben Greear wrote: On 12/30/2013 10:32 PM, Julia Lawall wrote: I'm just thinking of a programmer, e.g. changing a struct like this: struct foo { u8 addr[ETH_ALEN]; - u16 dummy; }; I don't know of a way to catch

Re: [PATCH 4/11] use ether_addr_equal_64bits

2013-12-31 Thread Julia Lawall
On Tue, 31 Dec 2013, Ben Greear wrote: On 12/31/2013 08:09 AM, Julia Lawall wrote: On Tue, 31 Dec 2013, Ben Greear wrote: On 12/30/2013 10:32 PM, Julia Lawall wrote: I'm just thinking of a programmer, e.g. changing a struct like this: struct foo {

Re: [PATCH 4/11] use ether_addr_equal_64bits

2013-12-30 Thread Julia Lawall
> > > > I'm just thinking of a programmer, e.g. changing a struct like this: > > > > > > > > struct foo { > > > >u8 addr[ETH_ALEN]; > > > > - u16 dummy; > > > > }; > > I don't know of a way to catch that. > Anyone else? Well, one could have a semantic patch that checks for that. But the

Re: [PATCH 4/11] use ether_addr_equal_64bits

2013-12-30 Thread Emmanuel Grumbach
On Tue, Dec 31, 2013 at 1:13 AM, Johannes Berg wrote: > > On Mon, 2013-12-30 at 19:57 -0200, Henrique de Moraes Holschuh wrote: > > On Mon, 30 Dec 2013, Johannes Berg wrote: > > > On Mon, 2013-12-30 at 20:58 +0100, Julia Lawall wrote: > > > > > Is there any way we could catch (sparse, or some

Re: [PATCH 4/11] use ether_addr_equal_64bits

2013-12-30 Thread Joe Perches
On Tue, 2013-12-31 at 00:13 +0100, Johannes Berg wrote: > On Mon, 2013-12-30 at 19:57 -0200, Henrique de Moraes Holschuh wrote: > > On Mon, 30 Dec 2013, Johannes Berg wrote: > > > On Mon, 2013-12-30 at 20:58 +0100, Julia Lawall wrote: > > > > > Is there any way we could catch (sparse, or some

Re: [PATCH 4/11] use ether_addr_equal_64bits

2013-12-30 Thread Johannes Berg
On Mon, 2013-12-30 at 19:57 -0200, Henrique de Moraes Holschuh wrote: > On Mon, 30 Dec 2013, Johannes Berg wrote: > > On Mon, 2013-12-30 at 20:58 +0100, Julia Lawall wrote: > > > > Is there any way we could catch (sparse, or some other script?) that > > > > struct reorganising won't break the

Re: [PATCH 4/11] use ether_addr_equal_64bits

2013-12-30 Thread Henrique de Moraes Holschuh
On Mon, 30 Dec 2013, Johannes Berg wrote: > On Mon, 2013-12-30 at 20:58 +0100, Julia Lawall wrote: > > > Is there any way we could catch (sparse, or some other script?) that > > > struct reorganising won't break the condition needed ("within a > > > structure that contains at least two more

Re: [PATCH 4/11] use ether_addr_equal_64bits

2013-12-30 Thread Johannes Berg
On Mon, 2013-12-30 at 20:58 +0100, Julia Lawall wrote: > > Is there any way we could catch (sparse, or some other script?) that > > struct reorganising won't break the condition needed ("within a > > structure that contains at least two more bytes")? > > What kind of reorganizing could happen?

Re: [PATCH 4/11] use ether_addr_equal_64bits

2013-12-30 Thread Julia Lawall
> Seems to be missing an "iwlwifi:" or so prefix, but I guess we can add > it when we take the patch ... Sorry. Not sure why that happened. I'll look into it. > Is there any way we could catch (sparse, or some other script?) that > struct reorganising won't break the condition needed ("within

Re: [PATCH 4/11] use ether_addr_equal_64bits

2013-12-30 Thread Johannes Berg
On Mon, 2013-12-30 at 19:15 +0100, Julia Lawall wrote: > From: Julia Lawall > > Ether_addr_equal_64bits is more efficient than ether_addr_equal, and can be > used when each argument is an array within a structure that contains at > least two bytes of data beyond the array. > > The structures

[PATCH 4/11] use ether_addr_equal_64bits

2013-12-30 Thread Julia Lawall
From: Julia Lawall Ether_addr_equal_64bits is more efficient than ether_addr_equal, and can be used when each argument is an array within a structure that contains at least two bytes of data beyond the array. The structures involved are: iwl_rxon_cmd defined in

[PATCH 4/11] use ether_addr_equal_64bits

2013-12-30 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr Ether_addr_equal_64bits is more efficient than ether_addr_equal, and can be used when each argument is an array within a structure that contains at least two bytes of data beyond the array. The structures involved are: iwl_rxon_cmd defined in

Re: [PATCH 4/11] use ether_addr_equal_64bits

2013-12-30 Thread Johannes Berg
On Mon, 2013-12-30 at 19:15 +0100, Julia Lawall wrote: From: Julia Lawall julia.law...@lip6.fr Ether_addr_equal_64bits is more efficient than ether_addr_equal, and can be used when each argument is an array within a structure that contains at least two bytes of data beyond the array. The

Re: [PATCH 4/11] use ether_addr_equal_64bits

2013-12-30 Thread Julia Lawall
Seems to be missing an iwlwifi: or so prefix, but I guess we can add it when we take the patch ... Sorry. Not sure why that happened. I'll look into it. Is there any way we could catch (sparse, or some other script?) that struct reorganising won't break the condition needed (within a

Re: [PATCH 4/11] use ether_addr_equal_64bits

2013-12-30 Thread Johannes Berg
On Mon, 2013-12-30 at 20:58 +0100, Julia Lawall wrote: Is there any way we could catch (sparse, or some other script?) that struct reorganising won't break the condition needed (within a structure that contains at least two more bytes)? What kind of reorganizing could happen? Do you

Re: [PATCH 4/11] use ether_addr_equal_64bits

2013-12-30 Thread Henrique de Moraes Holschuh
On Mon, 30 Dec 2013, Johannes Berg wrote: On Mon, 2013-12-30 at 20:58 +0100, Julia Lawall wrote: Is there any way we could catch (sparse, or some other script?) that struct reorganising won't break the condition needed (within a structure that contains at least two more bytes)? What

Re: [PATCH 4/11] use ether_addr_equal_64bits

2013-12-30 Thread Johannes Berg
On Mon, 2013-12-30 at 19:57 -0200, Henrique de Moraes Holschuh wrote: On Mon, 30 Dec 2013, Johannes Berg wrote: On Mon, 2013-12-30 at 20:58 +0100, Julia Lawall wrote: Is there any way we could catch (sparse, or some other script?) that struct reorganising won't break the condition

Re: [PATCH 4/11] use ether_addr_equal_64bits

2013-12-30 Thread Joe Perches
On Tue, 2013-12-31 at 00:13 +0100, Johannes Berg wrote: On Mon, 2013-12-30 at 19:57 -0200, Henrique de Moraes Holschuh wrote: On Mon, 30 Dec 2013, Johannes Berg wrote: On Mon, 2013-12-30 at 20:58 +0100, Julia Lawall wrote: Is there any way we could catch (sparse, or some other script?)

Re: [PATCH 4/11] use ether_addr_equal_64bits

2013-12-30 Thread Emmanuel Grumbach
On Tue, Dec 31, 2013 at 1:13 AM, Johannes Berg johan...@sipsolutions.net wrote: On Mon, 2013-12-30 at 19:57 -0200, Henrique de Moraes Holschuh wrote: On Mon, 30 Dec 2013, Johannes Berg wrote: On Mon, 2013-12-30 at 20:58 +0100, Julia Lawall wrote: Is there any way we could catch

Re: [PATCH 4/11] use ether_addr_equal_64bits

2013-12-30 Thread Julia Lawall
I'm just thinking of a programmer, e.g. changing a struct like this: struct foo { u8 addr[ETH_ALEN]; - u16 dummy; }; I don't know of a way to catch that. Anyone else? Well, one could have a semantic patch that checks for that. But the problem is that it is