WE-22 : prevent information leak on 64 bit
Subsystems (3)
PATCH 1/1 WE-22 : prevent information leak on 64 bit
Hi, Johannes Berg discovered that kernel space was leaking to
userspace on 64 bit platform. He made a first patch to fix that. This is an improved version of his patch.
This was tested on 2.6.21-rc4. Would you mind pushing that
upstream ?
Thanks... Jean
-----------------------------------------------------------
include/linux/wireless.h renamed from include/linux/wireless.j1.h +18 -3
@@ -1,10 +1,10 @@/* * This file define a set of standard wireless extensions * -* Version : 21 14.3.06 +* Version : 22 16.3.07 * * Authors : Jean Tourrilhes - HPL - <[email protected]> -* Copyright (c) 1997-2006 Jean Tourrilhes, All Rights Reserved. +* Copyright (c) 1997-2007 Jean Tourrilhes, All Rights Reserved. */ #ifndef _LINUX_WIRELESS_H
@@ -85,7 +85,7 @@* (there is some stuff that will be added in the future...) * I just plan to increment with each new version. */ -#define WIRELESS_EXT 21 +#define WIRELESS_EXT 22/* * Changes :
@@ -221,6 +221,10 @@* - Add IW_RETRY_SHORT/IW_RETRY_LONG retry modifiers * - Power/Retry relative values no longer * 100000 * - Add explicit flag to tell stats are in 802.11k RCPI : IW_QUAL_RCPI +* +* V21 to V22 +* ---------- +* - Prevent leaking of kernel space in stream on 64 bits. */ /**************************** CONSTANTS ****************************/
@@ -1085,4 +1089,15 @@ struct iw_event#define IW_EV_POINT_LEN (IW_EV_LCP_LEN + sizeof(struct iw_point) - \ IW_EV_POINT_OFF) +/* Size of the Event prefix when packed in stream */ +#define IW_EV_LCP_PK_LEN (4) +/* Size of the various events when packed in stream */ +#define IW_EV_CHAR_PK_LEN (IW_EV_LCP_PK_LEN + IFNAMSIZ) +#define IW_EV_UINT_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(__u32)) +#define IW_EV_FREQ_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct iw_freq)) +#define IW_EV_PARAM_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct iw_param)) +#define IW_EV_ADDR_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct sockaddr)) +#define IW_EV_QUAL_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct iw_quality)) +#define IW_EV_POINT_PK_LEN (IW_EV_LCP_LEN + 4) +#endif /* _LINUX_WIRELESS_H */
include/net/iw_handler.h renamed from include/net/iw_handler.j1.h +21 -9
@@ -1,10 +1,10 @@/* * This file define the new driver API for Wireless Extensions * -* Version : 7 18.3.05 +* Version : 8 16.3.07 * * Authors : Jean Tourrilhes - HPL - <[email protected]> -* Copyright (c) 2001-2006 Jean Tourrilhes, All Rights Reserved. +* Copyright (c) 2001-2007 Jean Tourrilhes, All Rights Reserved. */ #ifndef _IW_HANDLER_H
@@ -207,7 +207,7 @@* will be needed... * I just plan to increment with each new version. */ -#define IW_HANDLER_VERSION 7 +#define IW_HANDLER_VERSION 8/* * Changes :
@@ -239,6 +239,10 @@* - Remove (struct iw_point *)->pointer from events and streams * - Remove spy_offset from struct iw_handler_def * - Add "check" version of event macros for ieee802.11 stack +* +* V7 to V8 +* ---------- +* - Prevent leaking of kernel space in stream on 64 bits. */ /**************************** CONSTANTS ****************************/
@@ -500,7 +504,11 @@ iwe_stream_add_event(char * stream, /*/* Check if it's possible */ if (likely ((stream + event_len) < ends)) { iwe->len = event_len; -memcpy (stream, (char *) iwe, event_len); +/* Beware of alignement issues on 64 bits */ +memcpy (stream, (char *) iwe,IW_EV_LCP_PK_LEN ); +memcpy (stream +IW_EV_LCP_LEN , + ((char *) iwe) +IW_EV_LCP_LEN , + event_len -IW_EV_LCP_LEN ); stream += event_len; }return stream;
@@ -521,10 +529,10 @@ iwe_stream_add_point(char * stream, /*/* Check if it's possible */ if (likely ((stream + event_len) < ends)) { iwe->len = event_len; -memcpy (stream, (char *) iwe,IW_EV_LCP_LEN ); +memcpy (stream, (char *) iwe,IW_EV_LCP_PK_LEN );memcpy (stream +IW_EV_LCP_LEN , ((char *) iwe) +IW_EV_LCP_LEN +IW_EV_POINT_OFF , -IW_EV_POINT_LEN -IW_EV_LCP_LEN ); +IW_EV_POINT_PK_LEN -IW_EV_LCP_PK_LEN );memcpy (stream +IW_EV_POINT_LEN , extra, iwe->u.data.length); stream += event_len; }
@@ -574,7 +582,11 @@ iwe_stream_check_add_event(char * stream/* Check if it's possible, set error if not */ if (likely ((stream + event_len) < ends)) { iwe->len = event_len; -memcpy (stream, (char *) iwe, event_len); +/* Beware of alignement issues on 64 bits */ +memcpy (stream, (char *) iwe,IW_EV_LCP_PK_LEN ); +memcpy (stream +IW_EV_LCP_LEN , + ((char *) iwe) +IW_EV_LCP_LEN , + event_len -IW_EV_LCP_LEN ); stream += event_len; }else *perr = -E2BIG ;
@@ -598,10 +610,10 @@ iwe_stream_check_add_point(char * stream/* Check if it's possible */ if (likely ((stream + event_len) < ends)) { iwe->len = event_len; -memcpy (stream, (char *) iwe,IW_EV_LCP_LEN ); +memcpy (stream, (char *) iwe,IW_EV_LCP_PK_LEN );memcpy (stream +IW_EV_LCP_LEN , ((char *) iwe) +IW_EV_LCP_LEN +IW_EV_POINT_OFF , -IW_EV_POINT_LEN -IW_EV_LCP_LEN ); +IW_EV_POINT_PK_LEN -IW_EV_LCP_PK_LEN );memcpy (stream +IW_EV_POINT_LEN , extra, iwe->u.data.length); stream += event_len; }else
net/core/rtnetlink.c renamed from net/core/rtnetlink.j1.c +2 -1
@@ -621,7 +621,8 @@ static int rtnl_getlink(struct sk_buff *if (err <0 ) goto errout; - iw += IW_EV_POINT_OFF; +/* Payload is at an offset in buffer */ + iw = iw_buf + IW_EV_POINT_OFF; }#endif /* CONFIG_NET_WIRELESS_RTNETLINK */
net/core/wireless.c renamed from net/core/wireless.j1.c +50 -32
216 lines not on this page · raw message
Hi,
include/net/iw_handler.h iwe_stream_add_event(char * stream, /* · line 508
Quoted 10 lines · Jean Tourrilhes
diff -u -p
linux/include/net/iw_handler.j1.hlinux/include/net/iw_handler.hinclude/net/iw_handler.h renamed from include/net/iw_handler.j1.h +2
-1@@ -500,7 +504,11 @@ iwe_stream_add_event(char * stream, /*/* Check if it's possible */ if (likely ((stream + event_len) < ends)) { iwe->len = event_len; -memcpy (stream, (char *) iwe, event_len); +/* Beware of alignement issues on 64 bits */ +memcpy (stream, (char *) iwe,IW_EV_LCP_PK_LEN );
useless cast (void* and char* are already compatible).
You just need to cast to "char *", if you like to add an byte offset. If not, just don't cast.
include/net/iw_handler.h iwe_stream_add_event(char * stream, /* · line 512
Quoted 4 lines
include/net/iw_handler.h renamed from include/net/iw_handler.j1.h +3
-0+memcpy (stream +IW_EV_LCP_LEN , + ((char *) iwe) +IW_EV_LCP_LEN , + event_len -IW_EV_LCP_LEN ); stream += event_len;
Can this be a helper like "stream = copy_to_stream(stream, iwe, len);" ? Or do the offsets in stream and iwe vary too much for this?
include/net/iw_handler.h iwe_stream_add_point(char * stream, /* · line 532
Quoted 8 lines
include/net/iw_handler.h renamed from include/net/iw_handler.j1.h +1
-1}return stream;@@ -521,10 +529,10 @@ iwe_stream_add_point(char * stream, /*/* Check if it's possible */ if (likely ((stream + event_len) < ends)) { iwe->len = event_len; -memcpy (stream, (char *) iwe,IW_EV_LCP_LEN ); +memcpy (stream, (char *) iwe,IW_EV_LCP_PK_LEN );
useless cast.
Quoted 8 lines
include/net/iw_handler.h renamed from include/net/iw_handler.j1.h +1
-1memcpy (stream +IW_EV_LCP_LEN , ((char *) iwe) +IW_EV_LCP_LEN +IW_EV_POINT_OFF , -IW_EV_POINT_LEN -IW_EV_LCP_LEN ); +IW_EV_POINT_PK_LEN -IW_EV_LCP_PK_LEN );memcpy (stream +IW_EV_POINT_LEN , extra, iwe->u.data.length); stream += event_len; }
include/net/iw_handler.h iwe_stream_check_add_event(char * stream · line 586
Quoted 6 lines
include/net/iw_handler.h renamed from include/net/iw_handler.j1.h +2
-1@@ -574,7 +582,11 @@ iwe_stream_check_add_event(char * stream/* Check if it's possible, set error if not */ if (likely ((stream + event_len) < ends)) { iwe->len = event_len; -memcpy (stream, (char *) iwe, event_len); +/* Beware of alignement issues on 64 bits */ +memcpy (stream, (char *) iwe,IW_EV_LCP_PK_LEN );
useless cast.
include/net/iw_handler.h iwe_stream_check_add_point(char * stream · line 613
Quoted 12 lines
include/net/iw_handler.h renamed from include/net/iw_handler.j1.h +4
-1+memcpy (stream +IW_EV_LCP_LEN , + ((char *) iwe) +IW_EV_LCP_LEN , + event_len -IW_EV_LCP_LEN ); stream += event_len; }else *perr = -E2BIG ;@@ -598,10 +610,10 @@ iwe_stream_check_add_point(char * stream/* Check if it's possible */ if (likely ((stream + event_len) < ends)) { iwe->len = event_len; -memcpy (stream, (char *) iwe,IW_EV_LCP_LEN ); +memcpy (stream, (char *) iwe,IW_EV_LCP_PK_LEN );
useless cast.
include/net/iw_handler.h iwe_stream_check_add_point(char * stream · line 619
Quoted 7 lines
include/net/iw_handler.h renamed from include/net/iw_handler.j1.h +1
-1memcpy (stream +IW_EV_LCP_LEN , ((char *) iwe) +IW_EV_LCP_LEN +IW_EV_POINT_OFF , -IW_EV_POINT_LEN -IW_EV_LCP_LEN ); +IW_EV_POINT_PK_LEN -IW_EV_LCP_PK_LEN );memcpy (stream +IW_EV_POINT_LEN , extra, iwe->u.data.length); stream += event_len; }else
Regards
Ingo Oeser
Johannes Berg
maintainerQuoted 6 lines
Johannes Berg discovered that kernel space was leaking to
userspace on 64 bit platform. He made a first patch to fix that. This is an improved version of his patch.
This was tested on 2.6.21-rc4. Would you mind pushing that
upstream ?
Just FYI. This patch applies with rejects in net/core/rtnetlink.c and net/core/wireless.c to wireless-dev. The changes in those two files can be ignored completely since they affect only the removed wext-over-netlink interface.
johannes
A message that is not in the archive (sent off-list or not yet received): 1175508410.23438.75.camel-YfaajirXv214zXjbi5bjpg@public.gmane.org
Quoted 8 lines · Johannes Berg
Quoted 5 lines · Jean Tourrilhes
Johannes Berg discovered that kernel space was leaking to
userspace on 64 bit platform. He made a first patch to fix that. This is an improved version of his patch.
This was tested on 2.6.21-rc4. Would you mind pushing that
upstream ?
Quoted 6 lines
Just FYI. This patch applies with rejects in
net/core/rtnetlink.candnet/core/wireless.cto wireless-dev. The changes in those two files can be ignored completely since they affect only the removed wext-over-netlink interface.johannes
I'm sorry to have to write this e-mail. But this incident is
completely opposed to the ideal of FreeSoftware/OpenSource and demonstrate some of the bad politics happening in Linux.
First, I'm the current active maintainer of the
wext-over-netlink interface, and nobody bothered to even 'inform' me about its removal, let alone consult with me.
This shows a complete lack of courtesy and a total disrespect
to the concept of maintainer, basically some people are just second class citizens.
Second, there is no technical justification to such decision,
it's just plain politics. I would agree that for the vast majority of people, this API was useless, as any work in progress. But, it is maintained (by me), it is not causing any technical issue, for those people it's not compiled in (i.e. no bloat), it is not causing bugs and not preventing other code to be merged in the kernel.
Therefore a purely politic decision.
Now, I've got a problem with your attitude in this matter,
Johannes. It's now the second time you remove features from code I maintain by pure fiat, and you have engaged in a long running FUD campain about my code. This is totally disgraceful of a Linux maintainer, and you should know it.
If the only way you have to promote your code is by actively
destroying my code, then you have a real issue. Your code should stand on its own merit, without the need of attacking other people's work and playing political tricks.
I hope you will note that I never disparaged your code, I
never prevented its inclusion in Linux and I never attempted to control the Linux Wireless space and left plenty of space for new developpers.
You still have a lot to learn, like all of us. You still don't
understand Wireless Extensions (as your FUD shows) and why it's still so popular despite all its warts. You don't get the value of not burning bridges with other developpers and professional conduct.
By the way : don't bother replying to this e-mail, nothing
good will come of it.
Have fun... Jean
A message that is not in the archive (sent off-list or not yet received): 20070417170820.GB22372-yAE0UhLNZJawPNPzzlOzwdBPR1lH4CV8@public.gmane.org
Quoted 16 lines · Jean Tourrilhes
Quoted 8 lines · Johannes Berg
Quoted 5 lines · Jean Tourrilhes
Johannes Berg discovered that kernel space was leaking to
userspace on 64 bit platform. He made a first patch to fix that. This is an improved version of his patch.
This was tested on 2.6.21-rc4. Would you mind pushing that
upstream ?Quoted 6 lines
Just FYI. This patch applies with rejects in
net/core/rtnetlink.candnet/core/wireless.cto wireless-dev. The changes in those two files can be ignored completely since they affect only the removed wext-over-netlink interface.johannes
Quoted 7 lines
I'm sorry to have to write this e-mail. But this incident is
completely opposed to the ideal of FreeSoftware/OpenSource and demonstrate some of the bad politics happening in Linux.First, I'm the current active maintainer of the
wext-over-netlink interface, and nobody bothered to even 'inform' me about its removal, let alone consult with me.
Honestly, most of us thought you weren't interested.
Quoted 3 lines
This shows a complete lack of courtesy and a total disrespect
to the concept of maintainer, basically some people are just second class citizens.
I'm sorry that you are upset. I do not believe any disrespect was intended.
Quoted 7 lines
Second, there is no technical justification to such decision,
it's just plain politics. I would agree that for the vast majority of people, this API was useless, as any work in progress. But, it is maintained (by me), it is not causing any technical issue, for those people it's not compiled in (i.e. no bloat), it is not causing bugs and not preventing other code to be merged in the kernel.
Therefore a purely politic decision.
I would not call it politics, but I do not want to split hairs.
This API was controversial and mostly unwelcome from the start. It was ridiculed as "ioctls over netlink" at the last kernel summit. It is widely regarded as less of a solution and more of an extension to a problem.
One of the objections to having merged the API was that _if_ it were to gain users then we would have to carry that maintenance burden ad infinitum. This fear was already beginning to be confirmed by the efforts at maintaining WE compatibility in cfg80211. Since there were (thankfully) still no users and only compatibility headaches from maintaining it, Johannes wanted to remove the code, and I consented to his request.
I wish you would not view this as a personal issue. Your contributions are certainly welcome in general. We just don't see any benefit from keeping this code around as we move forward.
Again, I am terribly sorry that this was a surprise to you. I will be sure to communicate with you directly should another such issue arise.
Quoted 2 lines
By the way : don't bother replying to this e-mail, nothing
good will come of it.
Hopefully that isn't totally true...
Regards,
John
Signature · 2 lines
John W. Linville [email protected]
Quoted 7 lines · John W. Linville
Quoted 4 lines · Jean Tourrilhes
First, I'm the current active maintainer of the
wext-over-netlink interface, and nobody bothered to even 'inform' me about its removal, let alone consult with me.Honestly, most of us thought you weren't interested.
Please !
Quoted 2 lines
This API was controversial and mostly unwelcome from the start. It was ridiculed as "ioctls over netlink" at the last kernel summit.
Which is complete FUD. In that case, the whole RtNetlink can
be classified as "ioctls over netlink".
Quoted 3 lines
One of the objections to having merged the API was that _if_ it were to gain users then we would have to carry that maintenance burden ad infinitum.
More FUD. It does not add any new commands. The proof is in
the pudding, no change was needed in any driver to support it, therefore it could not have added any burden on any compatibility layer.
Quoted 3 lines
Regards,
John
Have fun... Jean
A message that is not in the archive (sent off-list or not yet received): 20070417211859.GB22897-yAE0UhLNZJawPNPzzlOzwdBPR1lH4CV8@public.gmane.org
Quoted 5 lines
Quoted 2 lines
This API was controversial and mostly unwelcome from the start. It was ridiculed as "ioctls over netlink" at the last kernel summit.
Which is complete FUD. In that case, the whole RtNetlink can
be classified as "ioctls over netlink".
The problem is that WE over netlink is basically using netlink to transfer the same binary blobs as the WE ioctls, rather than using properly structured netlink messages.
Quoted 8 lines
Quoted 3 lines
One of the objections to having merged the API was that _if_ it were to gain users then we would have to carry that maintenance burden ad infinitum.
More FUD. It does not add any new commands. The proof is in
the pudding, no change was needed in any driver to support it, therefore it could not have added any burden on any compatibility layer.
The point is that if WE over netlink is used by applications, then the kernel must maintain that ABI (of WE over netlink) forever.
- R.
Quoted 11 lines · Jean Tourrilhes
I'm sorry to have to write this e-mail. But this incident is
completely opposed to the ideal of FreeSoftware/OpenSource and demonstrate some of the bad politics happening in Linux.First, I'm the current active maintainer of the
wext-over-netlink interface, and nobody bothered to even 'inform' me about its removal, let alone consult with me.
This shows a complete lack of courtesy and a total disrespect
to the concept of maintainer, basically some people are just second class citizens.
Quoted 7 lines
Second, there is no technical justification to such decision,
it's just plain politics. I would agree that for the vast majority of people, this API was useless, as any work in progress. But, it is maintained (by me), it is not causing any technical issue, for those people it's not compiled in (i.e. no bloat), it is not causing bugs and not preventing other code to be merged in the kernel.
Therefore a purely politic decision.
It is _only_ about replacing obsolete code by code that obsoleted it. That happens all the time. Look at the process scheduler and compare it to 2.4, for example.
We want to reduce the maintainance burden. Nothing more. If we remove unused code (which WEXT-NL is), then we don't have to write compatibility code to support it in future.
Why wait with removal until we can't anymore (when people use it)?
Quoted 14 lines
Now, I've got a problem with your attitude in this matter,
Johannes. It's now the second time you remove features from code I maintain by pure fiat, and you have engaged in a long running FUD campain about my code. This is totally disgraceful of a Linux maintainer, and you should know it.
If the only way you have to promote your code is by actively
destroying my code, then you have a real issue. Your code should stand on its own merit, without the need of attacking other people's work and playing political tricks.
I hope you will note that I never disparaged your code, I
never prevented its inclusion in Linux and I never attempted to control the Linux Wireless space and left plenty of space for new developpers.
Quoted 4 lines
You still have a lot to learn, like all of us. You still don't
understand Wireless Extensions (as your FUD shows) and why it's still so popular despite all its warts. You don't get the value of not burning bridges with other developpers and professional conduct.
I'd say nobody but you does fully understand WEXT. Somebody might call that either a design issue, or a documentation issue. I personally make both issues responsible for this.
Signature · 1 line
Greetings Michael.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 2 lines · Michael Buesch
I'd say nobody but you does fully understand WEXT.
Not true. If tommorow I was run over by an ICE, you could ask
Jouni, Dan or Pavel to take over.
Have fun... Jean
Johannes Berg
maintainerJean,
Quoted 3 lines
First, I'm the current active maintainer of the
wext-over-netlink interface, and nobody bothered to even 'inform' me about its removal, let alone consult with me.
I definitely should have copied you on the feature-removal schedule patch for wext-over-netlink and then the actual removal in wireless-dev; please accept my apologies for not doing that, it was not done in bad faith. It was never my intention to demote you to a "second class citizen", I'm sorry you feel that way.
I have previously (and multiple times) given technical justification for removing this code (even recorded in the kernel changelog now) and I contend your allegation that it is a political issue. Others in this thread have pointed out the technical issues with wext and wext/nl so I will not repeat them.
I hope that despite my mistakes in handling the wext/nl removal we will be able to work together in the future to have wext fully supported with clear semantics for backwards compatibility while the kernel internally migrates towards cfg80211.
johannes