From fcc2a36e777557295860389bb3527b2a0d02094e Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 17 May 2020 14:17:15 +0200 Subject: [PATCH] 4.9-stable patches added patches: gcc-10-disable-array-bounds-warning-for-now.patch gcc-10-disable-restrict-warning-for-now.patch gcc-10-disable-stringop-overflow-warning-for-now.patch gcc-10-disable-zero-length-bounds-warning-for-now.patch gcc-10-warnings-fix-low-hanging-fruit.patch kbuild-compute-false-positive-wmaybe-uninitialized-cases-in-kconfig.patch pnp-use-list_for_each_entry-instead-of-open-coding.patch stop-the-ad-hoc-games-with-wno-maybe-initialized.patch --- ...disable-array-bounds-warning-for-now.patch | 55 +++++++++ ...-10-disable-restrict-warning-for-now.patch | 66 +++++++++++ ...le-stringop-overflow-warning-for-now.patch | 32 +++++ ...e-zero-length-bounds-warning-for-now.patch | 42 +++++++ ...cc-10-warnings-fix-low-hanging-fruit.patch | 50 ++++++++ ...maybe-uninitialized-cases-in-kconfig.patch | 104 +++++++++++++++++ ...or_each_entry-instead-of-open-coding.patch | 93 +++++++++++++++ queue-4.9/series | 8 ++ ...hoc-games-with-wno-maybe-initialized.patch | 109 ++++++++++++++++++ 9 files changed, 559 insertions(+) create mode 100644 queue-4.9/gcc-10-disable-array-bounds-warning-for-now.patch create mode 100644 queue-4.9/gcc-10-disable-restrict-warning-for-now.patch create mode 100644 queue-4.9/gcc-10-disable-stringop-overflow-warning-for-now.patch create mode 100644 queue-4.9/gcc-10-disable-zero-length-bounds-warning-for-now.patch create mode 100644 queue-4.9/gcc-10-warnings-fix-low-hanging-fruit.patch create mode 100644 queue-4.9/kbuild-compute-false-positive-wmaybe-uninitialized-cases-in-kconfig.patch create mode 100644 queue-4.9/pnp-use-list_for_each_entry-instead-of-open-coding.patch create mode 100644 queue-4.9/stop-the-ad-hoc-games-with-wno-maybe-initialized.patch diff --git a/queue-4.9/gcc-10-disable-array-bounds-warning-for-now.patch b/queue-4.9/gcc-10-disable-array-bounds-warning-for-now.patch new file mode 100644 index 00000000000..d484e474788 --- /dev/null +++ b/queue-4.9/gcc-10-disable-array-bounds-warning-for-now.patch @@ -0,0 +1,55 @@ +From 44720996e2d79e47d508b0abe99b931a726a3197 Mon Sep 17 00:00:00 2001 +From: Linus Torvalds +Date: Sat, 9 May 2020 14:52:44 -0700 +Subject: gcc-10: disable 'array-bounds' warning for now + +From: Linus Torvalds + +commit 44720996e2d79e47d508b0abe99b931a726a3197 upstream. + +This is another fine warning, related to the 'zero-length-bounds' one, +but hitting the same historical code in the kernel. + +Because C didn't historically support flexible array members, we have +code that instead uses a one-sized array, the same way we have cases of +zero-sized arrays. + +The one-sized arrays come from either not wanting to use the gcc +zero-sized array extension, or from a slight convenience-feature, where +particularly for strings, the size of the structure now includes the +allocation for the final NUL character. + +So with a "char name[1];" at the end of a structure, you can do things +like + + v = my_malloc(sizeof(struct vendor) + strlen(name)); + +and avoid the "+1" for the terminator. + +Yes, the modern way to do that is with a flexible array, and using +'offsetof()' instead of 'sizeof()', and adding the "+1" by hand. That +also technically gets the size "more correct" in that it avoids any +alignment (and thus padding) issues, but this is another long-term +cleanup thing that will not happen for 5.7. + +So disable the warning for now, even though it's potentially quite +useful. Having a slew of warnings that then hide more urgent new issues +is not an improvement. + +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + Makefile | 1 + + 1 file changed, 1 insertion(+) + +--- a/Makefile ++++ b/Makefile +@@ -799,6 +799,7 @@ KBUILD_CFLAGS += $(call cc-disable-warni + + # We'll want to enable this eventually, but it's not going away for 5.7 at least + KBUILD_CFLAGS += $(call cc-disable-warning, zero-length-bounds) ++KBUILD_CFLAGS += $(call cc-disable-warning, array-bounds) + + # Enabled with W=2, disabled by default as noisy + KBUILD_CFLAGS += $(call cc-disable-warning, maybe-uninitialized) diff --git a/queue-4.9/gcc-10-disable-restrict-warning-for-now.patch b/queue-4.9/gcc-10-disable-restrict-warning-for-now.patch new file mode 100644 index 00000000000..98ca79ab2e7 --- /dev/null +++ b/queue-4.9/gcc-10-disable-restrict-warning-for-now.patch @@ -0,0 +1,66 @@ +From adc71920969870dfa54e8f40dac8616284832d02 Mon Sep 17 00:00:00 2001 +From: Linus Torvalds +Date: Sat, 9 May 2020 15:45:21 -0700 +Subject: gcc-10: disable 'restrict' warning for now + +From: Linus Torvalds + +commit adc71920969870dfa54e8f40dac8616284832d02 upstream. + +gcc-10 now warns about passing aliasing pointers to functions that take +restricted pointers. + +That's actually a great warning, and if we ever start using 'restrict' +in the kernel, it might be quite useful. But right now we don't, and it +turns out that the only thing this warns about is an idiom where we have +declared a few functions to be "printf-like" (which seems to make gcc +pick up the restricted pointer thing), and then we print to the same +buffer that we also use as an input. + +And people do that as an odd concatenation pattern, with code like this: + + #define sysfs_show_gen_prop(buffer, fmt, ...) \ + snprintf(buffer, PAGE_SIZE, "%s"fmt, buffer, __VA_ARGS__) + +where we have 'buffer' as both the destination of the final result, and +as the initial argument. + +Yes, it's a bit questionable. And outside of the kernel, people do have +standard declarations like + + int snprintf( char *restrict buffer, size_t bufsz, + const char *restrict format, ... ); + +where that output buffer is marked as a restrict pointer that cannot +alias with any other arguments. + +But in the context of the kernel, that 'use snprintf() to concatenate to +the end result' does work, and the pattern shows up in multiple places. +And we have not marked our own version of snprintf() as taking restrict +pointers, so the warning is incorrect for now, and gcc picks it up on +its own. + +If we do start using 'restrict' in the kernel (and it might be a good +idea if people find places where it matters), we'll need to figure out +how to avoid this issue for snprintf and friends. But in the meantime, +this warning is not useful. + +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + Makefile | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/Makefile ++++ b/Makefile +@@ -802,6 +802,9 @@ KBUILD_CFLAGS += $(call cc-disable-warni + KBUILD_CFLAGS += $(call cc-disable-warning, array-bounds) + KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow) + ++# Another good warning that we'll want to enable eventually ++KBUILD_CFLAGS += $(call cc-disable-warning, restrict) ++ + # Enabled with W=2, disabled by default as noisy + KBUILD_CFLAGS += $(call cc-disable-warning, maybe-uninitialized) + diff --git a/queue-4.9/gcc-10-disable-stringop-overflow-warning-for-now.patch b/queue-4.9/gcc-10-disable-stringop-overflow-warning-for-now.patch new file mode 100644 index 00000000000..70db0d502c5 --- /dev/null +++ b/queue-4.9/gcc-10-disable-stringop-overflow-warning-for-now.patch @@ -0,0 +1,32 @@ +From 5a76021c2eff7fcf2f0918a08fd8a37ce7922921 Mon Sep 17 00:00:00 2001 +From: Linus Torvalds +Date: Sat, 9 May 2020 15:40:52 -0700 +Subject: gcc-10: disable 'stringop-overflow' warning for now + +From: Linus Torvalds + +commit 5a76021c2eff7fcf2f0918a08fd8a37ce7922921 upstream. + +This is the final array bounds warning removal for gcc-10 for now. + +Again, the warning is good, and we should re-enable all these warnings +when we have converted all the legacy array declaration cases to +flexible arrays. But in the meantime, it's just noise. + +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + Makefile | 1 + + 1 file changed, 1 insertion(+) + +--- a/Makefile ++++ b/Makefile +@@ -800,6 +800,7 @@ KBUILD_CFLAGS += $(call cc-disable-warni + # We'll want to enable this eventually, but it's not going away for 5.7 at least + KBUILD_CFLAGS += $(call cc-disable-warning, zero-length-bounds) + KBUILD_CFLAGS += $(call cc-disable-warning, array-bounds) ++KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow) + + # Enabled with W=2, disabled by default as noisy + KBUILD_CFLAGS += $(call cc-disable-warning, maybe-uninitialized) diff --git a/queue-4.9/gcc-10-disable-zero-length-bounds-warning-for-now.patch b/queue-4.9/gcc-10-disable-zero-length-bounds-warning-for-now.patch new file mode 100644 index 00000000000..ef33d111645 --- /dev/null +++ b/queue-4.9/gcc-10-disable-zero-length-bounds-warning-for-now.patch @@ -0,0 +1,42 @@ +From 5c45de21a2223fe46cf9488c99a7fbcf01527670 Mon Sep 17 00:00:00 2001 +From: Linus Torvalds +Date: Sat, 9 May 2020 14:30:29 -0700 +Subject: gcc-10: disable 'zero-length-bounds' warning for now + +From: Linus Torvalds + +commit 5c45de21a2223fe46cf9488c99a7fbcf01527670 upstream. + +This is a fine warning, but we still have a number of zero-length arrays +in the kernel that come from the traditional gcc extension. Yes, they +are getting converted to flexible arrays, but in the meantime the gcc-10 +warning about zero-length bounds is very verbose, and is hiding other +issues. + +I missed one actual build failure because it was hidden among hundreds +of lines of warning. Thankfully I caught it on the second go before +pushing things out, but it convinced me that I really need to disable +the new warnings for now. + +We'll hopefully be all done with our conversion to flexible arrays in +the not too distant future, and we can then re-enable this warning. + +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + Makefile | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/Makefile ++++ b/Makefile +@@ -797,6 +797,9 @@ KBUILD_CFLAGS += $(call cc-disable-warni + # disable stringop warnings in gcc 8+ + KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation) + ++# We'll want to enable this eventually, but it's not going away for 5.7 at least ++KBUILD_CFLAGS += $(call cc-disable-warning, zero-length-bounds) ++ + # Enabled with W=2, disabled by default as noisy + KBUILD_CFLAGS += $(call cc-disable-warning, maybe-uninitialized) + diff --git a/queue-4.9/gcc-10-warnings-fix-low-hanging-fruit.patch b/queue-4.9/gcc-10-warnings-fix-low-hanging-fruit.patch new file mode 100644 index 00000000000..d5ab7db309c --- /dev/null +++ b/queue-4.9/gcc-10-warnings-fix-low-hanging-fruit.patch @@ -0,0 +1,50 @@ +From 9d82973e032e246ff5663c9805fbb5407ae932e3 Mon Sep 17 00:00:00 2001 +From: Linus Torvalds +Date: Mon, 4 May 2020 09:16:37 -0700 +Subject: gcc-10 warnings: fix low-hanging fruit + +From: Linus Torvalds + +commit 9d82973e032e246ff5663c9805fbb5407ae932e3 upstream. + +Due to a bug-report that was compiler-dependent, I updated one of my +machines to gcc-10. That shows a lot of new warnings. Happily they +seem to be mostly the valid kind, but it's going to cause a round of +churn for getting rid of them.. + +This is the really low-hanging fruit of removing a couple of zero-sized +arrays in some core code. We have had a round of these patches before, +and we'll have many more coming, and there is nothing special about +these except that they were particularly trivial, and triggered more +warnings than most. + +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + include/linux/fs.h | 2 +- + include/linux/tty.h | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +--- a/include/linux/fs.h ++++ b/include/linux/fs.h +@@ -931,7 +931,7 @@ struct file_handle { + __u32 handle_bytes; + int handle_type; + /* file identifier */ +- unsigned char f_handle[0]; ++ unsigned char f_handle[]; + }; + + static inline struct file *get_file(struct file *f) +--- a/include/linux/tty.h ++++ b/include/linux/tty.h +@@ -64,7 +64,7 @@ struct tty_buffer { + int read; + int flags; + /* Data points here */ +- unsigned long data[0]; ++ unsigned long data[]; + }; + + /* Values for .flags field of tty_buffer */ diff --git a/queue-4.9/kbuild-compute-false-positive-wmaybe-uninitialized-cases-in-kconfig.patch b/queue-4.9/kbuild-compute-false-positive-wmaybe-uninitialized-cases-in-kconfig.patch new file mode 100644 index 00000000000..7d2926e407c --- /dev/null +++ b/queue-4.9/kbuild-compute-false-positive-wmaybe-uninitialized-cases-in-kconfig.patch @@ -0,0 +1,104 @@ +From b303c6df80c9f8f13785aa83a0471fca7e38b24d Mon Sep 17 00:00:00 2001 +From: Masahiro Yamada +Date: Thu, 21 Feb 2019 13:13:38 +0900 +Subject: kbuild: compute false-positive -Wmaybe-uninitialized cases in Kconfig + +From: Masahiro Yamada + +commit b303c6df80c9f8f13785aa83a0471fca7e38b24d upstream. + +Since -Wmaybe-uninitialized was introduced by GCC 4.7, we have patched +various false positives: + + - commit e74fc973b6e5 ("Turn off -Wmaybe-uninitialized when building + with -Os") turned off this option for -Os. + + - commit 815eb71e7149 ("Kbuild: disable 'maybe-uninitialized' warning + for CONFIG_PROFILE_ALL_BRANCHES") turned off this option for + CONFIG_PROFILE_ALL_BRANCHES + + - commit a76bcf557ef4 ("Kbuild: enable -Wmaybe-uninitialized warning + for "make W=1"") turned off this option for GCC < 4.9 + Arnd provided more explanation in https://lkml.org/lkml/2017/3/14/903 + +I think this looks better by shifting the logic from Makefile to Kconfig. + +Link: https://github.com/ClangBuiltLinux/linux/issues/350 +Signed-off-by: Masahiro Yamada +Reviewed-by: Nathan Chancellor +Tested-by: Nick Desaulniers +Signed-off-by: Greg Kroah-Hartman + +--- + Makefile | 11 ++++------- + init/Kconfig | 17 +++++++++++++++++ + kernel/trace/Kconfig | 1 + + 3 files changed, 22 insertions(+), 7 deletions(-) + +--- a/Makefile ++++ b/Makefile +@@ -658,17 +658,14 @@ KBUILD_CFLAGS += $(call cc-option,-fdata + endif + + ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE +-KBUILD_CFLAGS += -Os $(call cc-disable-warning,maybe-uninitialized,) +-else +-ifdef CONFIG_PROFILE_ALL_BRANCHES +-KBUILD_CFLAGS += -O2 $(call cc-disable-warning,maybe-uninitialized,) ++KBUILD_CFLAGS += -Os + else + KBUILD_CFLAGS += -O2 + endif +-endif + +-KBUILD_CFLAGS += $(call cc-ifversion, -lt, 0409, \ +- $(call cc-disable-warning,maybe-uninitialized,)) ++ifdef CONFIG_CC_DISABLE_WARN_MAYBE_UNINITIALIZED ++KBUILD_CFLAGS += -Wno-maybe-uninitialized ++endif + + # Tell gcc to never replace conditional load with a non-conditional one + KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0) +--- a/init/Kconfig ++++ b/init/Kconfig +@@ -16,6 +16,22 @@ config DEFCONFIG_LIST + default "$ARCH_DEFCONFIG" + default "arch/$ARCH/defconfig" + ++config CC_HAS_WARN_MAYBE_UNINITIALIZED ++ def_bool $(cc-option,-Wmaybe-uninitialized) ++ help ++ GCC >= 4.7 supports this option. ++ ++config CC_DISABLE_WARN_MAYBE_UNINITIALIZED ++ bool ++ depends on CC_HAS_WARN_MAYBE_UNINITIALIZED ++ default CC_IS_GCC && GCC_VERSION < 40900 # unreliable for GCC < 4.9 ++ help ++ GCC's -Wmaybe-uninitialized is not reliable by definition. ++ Lots of false positive warnings are produced in some cases. ++ ++ If this option is enabled, -Wno-maybe-uninitialzed is passed ++ to the compiler to suppress maybe-uninitialized warnings. ++ + config CONSTRUCTORS + bool + depends on !UML +@@ -1333,6 +1349,7 @@ config CC_OPTIMIZE_FOR_PERFORMANCE + + config CC_OPTIMIZE_FOR_SIZE + bool "Optimize for size" ++ imply CC_DISABLE_WARN_MAYBE_UNINITIALIZED # avoid false positives + help + Enabling this option will pass "-Os" instead of "-O2" to + your compiler resulting in a smaller kernel. +--- a/kernel/trace/Kconfig ++++ b/kernel/trace/Kconfig +@@ -342,6 +342,7 @@ config PROFILE_ANNOTATED_BRANCHES + config PROFILE_ALL_BRANCHES + bool "Profile all if conditionals" + select TRACE_BRANCH_PROFILING ++ imply CC_DISABLE_WARN_MAYBE_UNINITIALIZED # avoid false positives + help + This tracer profiles all branch conditions. Every if () + taken in the kernel is recorded whether it hit or miss. diff --git a/queue-4.9/pnp-use-list_for_each_entry-instead-of-open-coding.patch b/queue-4.9/pnp-use-list_for_each_entry-instead-of-open-coding.patch new file mode 100644 index 00000000000..baa90313e9b --- /dev/null +++ b/queue-4.9/pnp-use-list_for_each_entry-instead-of-open-coding.patch @@ -0,0 +1,93 @@ +From 01b2bafe57b19d9119413f138765ef57990921ce Mon Sep 17 00:00:00 2001 +From: Jason Gunthorpe +Date: Tue, 14 Apr 2020 12:10:50 -0300 +Subject: pnp: Use list_for_each_entry() instead of open coding +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Jason Gunthorpe + +commit 01b2bafe57b19d9119413f138765ef57990921ce upstream. + +Aside from good practice, this avoids a warning from gcc 10: + +./include/linux/kernel.h:997:3: warning: array subscript -31 is outside array bounds of ‘struct list_head[1]’ [-Warray-bounds] + 997 | ((type *)(__mptr - offsetof(type, member))); }) + | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +./include/linux/list.h:493:2: note: in expansion of macro ‘container_of’ + 493 | container_of(ptr, type, member) + | ^~~~~~~~~~~~ +./include/linux/pnp.h:275:30: note: in expansion of macro ‘list_entry’ + 275 | #define global_to_pnp_dev(n) list_entry(n, struct pnp_dev, global_list) + | ^~~~~~~~~~ +./include/linux/pnp.h:281:11: note: in expansion of macro ‘global_to_pnp_dev’ + 281 | (dev) != global_to_pnp_dev(&pnp_global); \ + | ^~~~~~~~~~~~~~~~~ +arch/x86/kernel/rtc.c:189:2: note: in expansion of macro ‘pnp_for_each_dev’ + 189 | pnp_for_each_dev(dev) { + +Because the common code doesn't cast the starting list_head to the +containing struct. + +Signed-off-by: Jason Gunthorpe +[ rjw: Whitespace adjustments ] +Signed-off-by: Rafael J. Wysocki +Signed-off-by: Greg Kroah-Hartman + +--- + include/linux/pnp.h | 29 +++++++++-------------------- + 1 file changed, 9 insertions(+), 20 deletions(-) + +--- a/include/linux/pnp.h ++++ b/include/linux/pnp.h +@@ -219,10 +219,8 @@ struct pnp_card { + #define global_to_pnp_card(n) list_entry(n, struct pnp_card, global_list) + #define protocol_to_pnp_card(n) list_entry(n, struct pnp_card, protocol_list) + #define to_pnp_card(n) container_of(n, struct pnp_card, dev) +-#define pnp_for_each_card(card) \ +- for((card) = global_to_pnp_card(pnp_cards.next); \ +- (card) != global_to_pnp_card(&pnp_cards); \ +- (card) = global_to_pnp_card((card)->global_list.next)) ++#define pnp_for_each_card(card) \ ++ list_for_each_entry(card, &pnp_cards, global_list) + + struct pnp_card_link { + struct pnp_card *card; +@@ -275,14 +273,9 @@ struct pnp_dev { + #define card_to_pnp_dev(n) list_entry(n, struct pnp_dev, card_list) + #define protocol_to_pnp_dev(n) list_entry(n, struct pnp_dev, protocol_list) + #define to_pnp_dev(n) container_of(n, struct pnp_dev, dev) +-#define pnp_for_each_dev(dev) \ +- for((dev) = global_to_pnp_dev(pnp_global.next); \ +- (dev) != global_to_pnp_dev(&pnp_global); \ +- (dev) = global_to_pnp_dev((dev)->global_list.next)) +-#define card_for_each_dev(card,dev) \ +- for((dev) = card_to_pnp_dev((card)->devices.next); \ +- (dev) != card_to_pnp_dev(&(card)->devices); \ +- (dev) = card_to_pnp_dev((dev)->card_list.next)) ++#define pnp_for_each_dev(dev) list_for_each_entry(dev, &pnp_global, global_list) ++#define card_for_each_dev(card, dev) \ ++ list_for_each_entry(dev, &(card)->devices, card_list) + #define pnp_dev_name(dev) (dev)->name + + static inline void *pnp_get_drvdata(struct pnp_dev *pdev) +@@ -436,14 +429,10 @@ struct pnp_protocol { + }; + + #define to_pnp_protocol(n) list_entry(n, struct pnp_protocol, protocol_list) +-#define protocol_for_each_card(protocol,card) \ +- for((card) = protocol_to_pnp_card((protocol)->cards.next); \ +- (card) != protocol_to_pnp_card(&(protocol)->cards); \ +- (card) = protocol_to_pnp_card((card)->protocol_list.next)) +-#define protocol_for_each_dev(protocol,dev) \ +- for((dev) = protocol_to_pnp_dev((protocol)->devices.next); \ +- (dev) != protocol_to_pnp_dev(&(protocol)->devices); \ +- (dev) = protocol_to_pnp_dev((dev)->protocol_list.next)) ++#define protocol_for_each_card(protocol, card) \ ++ list_for_each_entry(card, &(protocol)->cards, protocol_list) ++#define protocol_for_each_dev(protocol, dev) \ ++ list_for_each_entry(dev, &(protocol)->devices, protocol_list) + + extern struct bus_type pnp_bus_type; + diff --git a/queue-4.9/series b/queue-4.9/series index 3f8b75a7782..d90f0f14edf 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -55,3 +55,11 @@ pinctrl-cherryview-add-missing-spinlock-usage-in-chv.patch i40iw-fix-error-handling-in-i40iw_manage_arp_cache.patch netfilter-conntrack-avoid-gcc-10-zero-length-bounds-.patch ib-mlx4-test-return-value-of-calls-to-ib_get_cached_.patch +pnp-use-list_for_each_entry-instead-of-open-coding.patch +gcc-10-warnings-fix-low-hanging-fruit.patch +kbuild-compute-false-positive-wmaybe-uninitialized-cases-in-kconfig.patch +stop-the-ad-hoc-games-with-wno-maybe-initialized.patch +gcc-10-disable-zero-length-bounds-warning-for-now.patch +gcc-10-disable-array-bounds-warning-for-now.patch +gcc-10-disable-stringop-overflow-warning-for-now.patch +gcc-10-disable-restrict-warning-for-now.patch diff --git a/queue-4.9/stop-the-ad-hoc-games-with-wno-maybe-initialized.patch b/queue-4.9/stop-the-ad-hoc-games-with-wno-maybe-initialized.patch new file mode 100644 index 00000000000..8b3e66aa7d0 --- /dev/null +++ b/queue-4.9/stop-the-ad-hoc-games-with-wno-maybe-initialized.patch @@ -0,0 +1,109 @@ +From 78a5255ffb6a1af189a83e493d916ba1c54d8c75 Mon Sep 17 00:00:00 2001 +From: Linus Torvalds +Date: Sat, 9 May 2020 13:57:10 -0700 +Subject: Stop the ad-hoc games with -Wno-maybe-initialized + +From: Linus Torvalds + +commit 78a5255ffb6a1af189a83e493d916ba1c54d8c75 upstream. + +We have some rather random rules about when we accept the +"maybe-initialized" warnings, and when we don't. + +For example, we consider it unreliable for gcc versions < 4.9, but also +if -O3 is enabled, or if optimizing for size. And then various kernel +config options disabled it, because they know that they trigger that +warning by confusing gcc sufficiently (ie PROFILE_ALL_BRANCHES). + +And now gcc-10 seems to be introducing a lot of those warnings too, so +it falls under the same heading as 4.9 did. + +At the same time, we have a very straightforward way to _enable_ that +warning when wanted: use "W=2" to enable more warnings. + +So stop playing these ad-hoc games, and just disable that warning by +default, with the known and straight-forward "if you want to work on the +extra compiler warnings, use W=123". + +Would it be great to have code that is always so obvious that it never +confuses the compiler whether a variable is used initialized or not? +Yes, it would. In a perfect world, the compilers would be smarter, and +our source code would be simpler. + +That's currently not the world we live in, though. + +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + Makefile | 7 +++---- + init/Kconfig | 17 ----------------- + kernel/trace/Kconfig | 1 - + 3 files changed, 3 insertions(+), 22 deletions(-) + +--- a/Makefile ++++ b/Makefile +@@ -663,10 +663,6 @@ else + KBUILD_CFLAGS += -O2 + endif + +-ifdef CONFIG_CC_DISABLE_WARN_MAYBE_UNINITIALIZED +-KBUILD_CFLAGS += -Wno-maybe-uninitialized +-endif +- + # Tell gcc to never replace conditional load with a non-conditional one + KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0) + +@@ -801,6 +797,9 @@ KBUILD_CFLAGS += $(call cc-disable-warni + # disable stringop warnings in gcc 8+ + KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation) + ++# Enabled with W=2, disabled by default as noisy ++KBUILD_CFLAGS += $(call cc-disable-warning, maybe-uninitialized) ++ + # disable invalid "can't wrap" optimizations for signed / pointers + KBUILD_CFLAGS += $(call cc-option,-fno-strict-overflow) + +--- a/init/Kconfig ++++ b/init/Kconfig +@@ -16,22 +16,6 @@ config DEFCONFIG_LIST + default "$ARCH_DEFCONFIG" + default "arch/$ARCH/defconfig" + +-config CC_HAS_WARN_MAYBE_UNINITIALIZED +- def_bool $(cc-option,-Wmaybe-uninitialized) +- help +- GCC >= 4.7 supports this option. +- +-config CC_DISABLE_WARN_MAYBE_UNINITIALIZED +- bool +- depends on CC_HAS_WARN_MAYBE_UNINITIALIZED +- default CC_IS_GCC && GCC_VERSION < 40900 # unreliable for GCC < 4.9 +- help +- GCC's -Wmaybe-uninitialized is not reliable by definition. +- Lots of false positive warnings are produced in some cases. +- +- If this option is enabled, -Wno-maybe-uninitialzed is passed +- to the compiler to suppress maybe-uninitialized warnings. +- + config CONSTRUCTORS + bool + depends on !UML +@@ -1349,7 +1333,6 @@ config CC_OPTIMIZE_FOR_PERFORMANCE + + config CC_OPTIMIZE_FOR_SIZE + bool "Optimize for size" +- imply CC_DISABLE_WARN_MAYBE_UNINITIALIZED # avoid false positives + help + Enabling this option will pass "-Os" instead of "-O2" to + your compiler resulting in a smaller kernel. +--- a/kernel/trace/Kconfig ++++ b/kernel/trace/Kconfig +@@ -342,7 +342,6 @@ config PROFILE_ANNOTATED_BRANCHES + config PROFILE_ALL_BRANCHES + bool "Profile all if conditionals" + select TRACE_BRANCH_PROFILING +- imply CC_DISABLE_WARN_MAYBE_UNINITIALIZED # avoid false positives + help + This tracer profiles all branch conditions. Every if () + taken in the kernel is recorded whether it hit or miss. -- 2.47.3