* [PATCH v4 2/3] mac80211: Prevent build failure with CONFIG_UBSAN=y [not found] <1449157807-20298-1-git-send-email-aryabinin@virtuozzo.com> @ 2015-12-03 15:50 ` Andrey Ryabinin 2015-12-03 17:05 ` Johannes Berg 0 siblings, 1 reply; 3+ messages in thread From: Andrey Ryabinin @ 2015-12-03 15:50 UTC (permalink / raw) To: linux-kernel Cc: Andrey Ryabinin, linux-wireless, netdev, Johannes Berg, David S. Miller, Andrew Morton, Peter Zijlstra, Sasha Levin, Randy Dunlap, Rasmus Villemoes, Jonathan Corbet, Michal Marek, Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Yury Gribov, Dmitry Vyukov, Konstantin Khlebnikov, Kostya Serebryany, x86, linux-doc, linux-kbuild With upcoming CONFIG_UBSAN the following BUILD_BUG_ON in net/mac80211/debugfs.c starts to trigger: BUILD_BUG_ON(hw_flag_names[NUM_IEEE80211_HW_FLAGS] != (void *)0x1); It seems, that compiler instrumentation causes some code deoptimizations. Because of that GCC is not being able to resolve condition in BUILD_BUG_ON() at compile time. We could make size of hw_flag_names array unspecified and replace the condition in BUILD_BUG_ON() with following: ARRAY_SIZE(hw_flag_names) != NUM_IEEE80211_HW_FLAGS That will have the same effect as before (adding new flag without updating array will trigger build failure) except it doesn't fail with CONFIG_UBSAN. As a bonus this patch slightly decreases size of hw_flag_names array. Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com> Cc: Johannes Berg <johannes@sipsolutions.net> Cc: "David S. Miller" <davem@davemloft.net> --- net/mac80211/debugfs.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c index abbdff0..3e24d0d 100644 --- a/net/mac80211/debugfs.c +++ b/net/mac80211/debugfs.c @@ -91,7 +91,7 @@ static const struct file_operations reset_ops = { }; #endif -static const char *hw_flag_names[NUM_IEEE80211_HW_FLAGS + 1] = { +static const char *hw_flag_names[] = { #define FLAG(F) [IEEE80211_HW_##F] = #F FLAG(HAS_RATE_CONTROL), FLAG(RX_INCLUDES_FCS), @@ -126,9 +126,6 @@ static const char *hw_flag_names[NUM_IEEE80211_HW_FLAGS + 1] = { FLAG(SUPPORTS_AMSDU_IN_AMPDU), FLAG(BEACON_TX_STATUS), FLAG(NEEDS_UNIQUE_STA_ADDR), - - /* keep last for the build bug below */ - (void *)0x1 #undef FLAG }; @@ -148,7 +145,7 @@ static ssize_t hwflags_read(struct file *file, char __user *user_buf, /* fail compilation if somebody adds or removes * a flag without updating the name array above */ - BUILD_BUG_ON(hw_flag_names[NUM_IEEE80211_HW_FLAGS] != (void *)0x1); + BUILD_BUG_ON(ARRAY_SIZE(hw_flag_names) != NUM_IEEE80211_HW_FLAGS); for (i = 0; i < NUM_IEEE80211_HW_FLAGS; i++) { if (test_bit(i, local->hw.flags)) -- 2.4.10 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v4 2/3] mac80211: Prevent build failure with CONFIG_UBSAN=y 2015-12-03 15:50 ` [PATCH v4 2/3] mac80211: Prevent build failure with CONFIG_UBSAN=y Andrey Ryabinin @ 2015-12-03 17:05 ` Johannes Berg 2015-12-03 19:18 ` Andrey Ryabinin 0 siblings, 1 reply; 3+ messages in thread From: Johannes Berg @ 2015-12-03 17:05 UTC (permalink / raw) To: Andrey Ryabinin, linux-kernel Cc: linux-wireless, netdev, David S. Miller, Andrew Morton, Peter Zijlstra, Sasha Levin, Randy Dunlap, Rasmus Villemoes, Jonathan Corbet, Michal Marek, Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Yury Gribov, Dmitry Vyukov, Konstantin Khlebnikov, Kostya Serebryany, x86, linux-doc, linux-kbuild On Thu, 2015-12-03 at 18:50 +0300, Andrey Ryabinin wrote: > With upcoming CONFIG_UBSAN the following BUILD_BUG_ON in > net/mac80211/debugfs.c starts to trigger: > BUILD_BUG_ON(hw_flag_names[NUM_IEEE80211_HW_FLAGS] != (void > *)0x1); > > It seems, that compiler instrumentation causes some code > deoptimizations. > Because of that GCC is not being able to resolve condition in > BUILD_BUG_ON() > at compile time. > > We could make size of hw_flag_names array unspecified and replace the > condition in BUILD_BUG_ON() with following: > ARRAY_SIZE(hw_flag_names) != NUM_IEEE80211_HW_FLAGS > > That will have the same effect as before (adding new flag without > updating > array will trigger build failure) except it doesn't fail with > CONFIG_UBSAN. > As a bonus this patch slightly decreases size of hw_flag_names array. > Seems fine, would you want to take it through some other tree together with UBSAN, or do you expect that to still take long enough to allow this to trickle through our trees? johannes ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v4 2/3] mac80211: Prevent build failure with CONFIG_UBSAN=y 2015-12-03 17:05 ` Johannes Berg @ 2015-12-03 19:18 ` Andrey Ryabinin 0 siblings, 0 replies; 3+ messages in thread From: Andrey Ryabinin @ 2015-12-03 19:18 UTC (permalink / raw) To: Johannes Berg, Andrew Morton Cc: Andrey Ryabinin, LKML, linux-wireless, netdev@vger.kernel.org, David S. Miller, Peter Zijlstra, Sasha Levin, Randy Dunlap, Rasmus Villemoes, Jonathan Corbet, Michal Marek, Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Yury Gribov, Dmitry Vyukov, Konstantin Khlebnikov, Kostya Serebryany, x86@kernel.org, open list:DOCUMENTATION, open list:KERNEL BUILD + fi... 2015-12-03 20:05 GMT+03:00 Johannes Berg <johannes@sipsolutions.net>: > On Thu, 2015-12-03 at 18:50 +0300, Andrey Ryabinin wrote: >> With upcoming CONFIG_UBSAN the following BUILD_BUG_ON in >> net/mac80211/debugfs.c starts to trigger: >> BUILD_BUG_ON(hw_flag_names[NUM_IEEE80211_HW_FLAGS] != (void >> *)0x1); >> >> It seems, that compiler instrumentation causes some code >> deoptimizations. >> Because of that GCC is not being able to resolve condition in >> BUILD_BUG_ON() >> at compile time. >> >> We could make size of hw_flag_names array unspecified and replace the >> condition in BUILD_BUG_ON() with following: >> ARRAY_SIZE(hw_flag_names) != NUM_IEEE80211_HW_FLAGS >> >> That will have the same effect as before (adding new flag without >> updating >> array will trigger build failure) except it doesn't fail with >> CONFIG_UBSAN. >> As a bonus this patch slightly decreases size of hw_flag_names array. >> > Seems fine, would you want to take it through some other tree together > with UBSAN, or do you expect that to still take long enough to allow > this to trickle through our trees? > I expect that Andrew will take it with UBSAN for 4.5 ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-12-03 19:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1449157807-20298-1-git-send-email-aryabinin@virtuozzo.com>
2015-12-03 15:50 ` [PATCH v4 2/3] mac80211: Prevent build failure with CONFIG_UBSAN=y Andrey Ryabinin
2015-12-03 17:05 ` Johannes Berg
2015-12-03 19:18 ` Andrey Ryabinin
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).