* [PATCH 4.19] wireless: Use offsetof instead of custom macro.
@ 2020-07-31 21:02 Nick Desaulniers
2020-08-01 12:02 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: Nick Desaulniers @ 2020-07-31 21:02 UTC (permalink / raw)
To: stable; +Cc: Pi-Hsun Shih, Johannes Berg, Nick Desaulniers
From: Pi-Hsun Shih <pihsun@chromium.org>
commit 6989310f5d4327e8595664954edd40a7f99ddd0d upstream.
Use offsetof to calculate offset of a field to take advantage of
compiler built-in version when possible, and avoid UBSAN warning when
compiling with Clang:
==================================================================
UBSAN: Undefined behaviour in net/wireless/wext-core.c:525:14
member access within null pointer of type 'struct iw_point'
CPU: 3 PID: 165 Comm: kworker/u16:3 Tainted: G S W 4.19.23 #43
Workqueue: cfg80211 __cfg80211_scan_done [cfg80211]
Call trace:
dump_backtrace+0x0/0x194
show_stack+0x20/0x2c
__dump_stack+0x20/0x28
dump_stack+0x70/0x94
ubsan_epilogue+0x14/0x44
ubsan_type_mismatch_common+0xf4/0xfc
__ubsan_handle_type_mismatch_v1+0x34/0x54
wireless_send_event+0x3cc/0x470
___cfg80211_scan_done+0x13c/0x220 [cfg80211]
__cfg80211_scan_done+0x28/0x34 [cfg80211]
process_one_work+0x170/0x35c
worker_thread+0x254/0x380
kthread+0x13c/0x158
ret_from_fork+0x10/0x18
===================================================================
Signed-off-by: Pi-Hsun Shih <pihsun@chromium.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Link: https://lore.kernel.org/r/20191204081307.138765-1-pihsun@chromium.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
---
Fix landed in v5.7-rc1. Thanks to James Hsu of MediaTek for the report.
include/uapi/linux/wireless.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/include/uapi/linux/wireless.h b/include/uapi/linux/wireless.h
index 86eca3208b6b..a2c006a364e0 100644
--- a/include/uapi/linux/wireless.h
+++ b/include/uapi/linux/wireless.h
@@ -74,6 +74,8 @@
#include <linux/socket.h> /* for "struct sockaddr" et al */
#include <linux/if.h> /* for IFNAMSIZ and co... */
+#include <stddef.h> /* for offsetof */
+
/***************************** VERSION *****************************/
/*
* This constant is used to know the availability of the wireless
@@ -1090,8 +1092,7 @@ struct iw_event {
/* iw_point events are special. First, the payload (extra data) come at
* the end of the event, so they are bigger than IW_EV_POINT_LEN. Second,
* we omit the pointer, so start at an offset. */
-#define IW_EV_POINT_OFF (((char *) &(((struct iw_point *) NULL)->length)) - \
- (char *) NULL)
+#define IW_EV_POINT_OFF offsetof(struct iw_point, length)
#define IW_EV_POINT_LEN (IW_EV_LCP_LEN + sizeof(struct iw_point) - \
IW_EV_POINT_OFF)
--
2.28.0.163.g6104cc2f0b6-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 4.19] wireless: Use offsetof instead of custom macro.
2020-07-31 21:02 [PATCH 4.19] wireless: Use offsetof instead of custom macro Nick Desaulniers
@ 2020-08-01 12:02 ` Greg KH
2020-08-03 17:16 ` Nick Desaulniers
0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2020-08-01 12:02 UTC (permalink / raw)
To: Nick Desaulniers; +Cc: stable, Pi-Hsun Shih, Johannes Berg
On Fri, Jul 31, 2020 at 02:02:55PM -0700, Nick Desaulniers wrote:
> From: Pi-Hsun Shih <pihsun@chromium.org>
>
> commit 6989310f5d4327e8595664954edd40a7f99ddd0d upstream.
>
> Use offsetof to calculate offset of a field to take advantage of
> compiler built-in version when possible, and avoid UBSAN warning when
> compiling with Clang:
>
> ==================================================================
> UBSAN: Undefined behaviour in net/wireless/wext-core.c:525:14
> member access within null pointer of type 'struct iw_point'
> CPU: 3 PID: 165 Comm: kworker/u16:3 Tainted: G S W 4.19.23 #43
> Workqueue: cfg80211 __cfg80211_scan_done [cfg80211]
> Call trace:
> dump_backtrace+0x0/0x194
> show_stack+0x20/0x2c
> __dump_stack+0x20/0x28
> dump_stack+0x70/0x94
> ubsan_epilogue+0x14/0x44
> ubsan_type_mismatch_common+0xf4/0xfc
> __ubsan_handle_type_mismatch_v1+0x34/0x54
> wireless_send_event+0x3cc/0x470
> ___cfg80211_scan_done+0x13c/0x220 [cfg80211]
> __cfg80211_scan_done+0x28/0x34 [cfg80211]
> process_one_work+0x170/0x35c
> worker_thread+0x254/0x380
> kthread+0x13c/0x158
> ret_from_fork+0x10/0x18
> ===================================================================
>
> Signed-off-by: Pi-Hsun Shih <pihsun@chromium.org>
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> Link: https://lore.kernel.org/r/20191204081307.138765-1-pihsun@chromium.org
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> ---
> Fix landed in v5.7-rc1. Thanks to James Hsu of MediaTek for the report.
What about 5.4.y? Why ignore that tree? You can not have people moving
from an older stable to a newer stable tree and have regressions :(
I'll queue it up there, but be more careful next time please.
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 4.19] wireless: Use offsetof instead of custom macro.
2020-08-01 12:02 ` Greg KH
@ 2020-08-03 17:16 ` Nick Desaulniers
0 siblings, 0 replies; 3+ messages in thread
From: Nick Desaulniers @ 2020-08-03 17:16 UTC (permalink / raw)
To: Greg KH; +Cc: # 3.4.x, Pi-Hsun Shih, Johannes Berg
On Sat, Aug 1, 2020 at 5:02 AM Greg KH <greg@kroah.com> wrote:
>
> On Fri, Jul 31, 2020 at 02:02:55PM -0700, Nick Desaulniers wrote:
> > Fix landed in v5.7-rc1. Thanks to James Hsu of MediaTek for the report.
>
> What about 5.4.y? Why ignore that tree? You can not have people moving
> from an older stable to a newer stable tree and have regressions :(
>
> I'll queue it up there, but be more careful next time please.
Yes, sorry, my mistake. I don't know what happened; perhaps I forgot
how to count.
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-08-03 17:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-31 21:02 [PATCH 4.19] wireless: Use offsetof instead of custom macro Nick Desaulniers
2020-08-01 12:02 ` Greg KH
2020-08-03 17:16 ` Nick Desaulniers
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).