From: Greg Kroah-Hartman Date: Mon, 4 Jan 2021 12:39:51 +0000 (+0100) Subject: 4.19-stable patches X-Git-Tag: v4.19.165~18 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=86ca9affec394ea3b7800613a4d201bf1cd94850;p=thirdparty%2Fkernel%2Fstable-queue.git 4.19-stable patches added patches: of-fix-linker-section-match-table-corruption.patch --- diff --git a/queue-4.19/of-fix-linker-section-match-table-corruption.patch b/queue-4.19/of-fix-linker-section-match-table-corruption.patch new file mode 100644 index 00000000000..47d3f9239e5 --- /dev/null +++ b/queue-4.19/of-fix-linker-section-match-table-corruption.patch @@ -0,0 +1,66 @@ +From 5812b32e01c6d86ba7a84110702b46d8a8531fe9 Mon Sep 17 00:00:00 2001 +From: Johan Hovold +Date: Mon, 23 Nov 2020 11:23:12 +0100 +Subject: of: fix linker-section match-table corruption + +From: Johan Hovold + +commit 5812b32e01c6d86ba7a84110702b46d8a8531fe9 upstream. + +Specify type alignment when declaring linker-section match-table entries +to prevent gcc from increasing alignment and corrupting the various +tables with padding (e.g. timers, irqchips, clocks, reserved memory). + +This is specifically needed on x86 where gcc (typically) aligns larger +objects like struct of_device_id with static extent on 32-byte +boundaries which at best prevents matching on anything but the first +entry. Specifying alignment when declaring variables suppresses this +optimisation. + +Here's a 64-bit example where all entries are corrupt as 16 bytes of +padding has been inserted before the first entry: + + ffffffff8266b4b0 D __clk_of_table + ffffffff8266b4c0 d __of_table_fixed_factor_clk + ffffffff8266b5a0 d __of_table_fixed_clk + ffffffff8266b680 d __clk_of_table_sentinel + +And here's a 32-bit example where the 8-byte-aligned table happens to be +placed on a 32-byte boundary so that all but the first entry are corrupt +due to the 28 bytes of padding inserted between entries: + + 812b3ec0 D __irqchip_of_table + 812b3ec0 d __of_table_irqchip1 + 812b3fa0 d __of_table_irqchip2 + 812b4080 d __of_table_irqchip3 + 812b4160 d irqchip_of_match_end + +Verified on x86 using gcc-9.3 and gcc-4.9 (which uses 64-byte +alignment), and on arm using gcc-7.2. + +Note that there are no in-tree users of these tables on x86 currently +(even if they are included in the image). + +Fixes: 54196ccbe0ba ("of: consolidate linker section OF match table declarations") +Fixes: f6e916b82022 ("irqchip: add basic infrastructure") +Cc: stable # 3.9 +Signed-off-by: Johan Hovold +Link: https://lore.kernel.org/r/20201123102319.8090-2-johan@kernel.org +[ johan: adjust context to 5.4 ] +Signed-off-by: Johan Hovold +Signed-off-by: Greg Kroah-Hartman + +--- + include/linux/of.h | 1 + + 1 file changed, 1 insertion(+) + +--- a/include/linux/of.h ++++ b/include/linux/of.h +@@ -1258,6 +1258,7 @@ static inline int of_get_available_child + #define _OF_DECLARE(table, name, compat, fn, fn_type) \ + static const struct of_device_id __of_table_##name \ + __used __section(__##table##_of_table) \ ++ __aligned(__alignof__(struct of_device_id)) \ + = { .compatible = compat, \ + .data = (fn == (fn_type)NULL) ? fn : fn } + #else diff --git a/queue-4.19/series b/queue-4.19/series index e882481d4c6..66eee5ed355 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -11,3 +11,4 @@ kvm-x86-reinstate-vendor-agnostic-check-on-spec_ctrl.patch powerpc-bitops-fix-possible-undefined-behaviour-with.patch xen-gntdev.c-mark-pages-as-dirty.patch null_blk-fix-zone-size-initialization.patch +of-fix-linker-section-match-table-corruption.patch