From 2d7594ad61bda362abe886d605d5dc0712daf8b1 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 14 Aug 2017 08:29:27 -0400 Subject: [PATCH] add patch fix-clang-build-regression --- fix-clang-build-regression | 57 ++++++++++++++++++++++++++++++++++++++++++++++ series | 2 ++ timestamps | 7 +++--- 3 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 fix-clang-build-regression diff --git a/fix-clang-build-regression b/fix-clang-build-regression new file mode 100644 index 00000000..24a47c6a --- /dev/null +++ b/fix-clang-build-regression @@ -0,0 +1,57 @@ +ext4: fix clang build regression + +Arnd Bergmann + +As Stefan pointed out, I misremembered what clang can do specifically, +and it turns out that the variable-length array at the end of the +structure did not work (a flexible array would have worked here +but not solved the problem): + +fs/ext4/mballoc.c:2303:17: error: fields must have a constant size: +'variable length array in structure' extension will never be supported + ext4_grpblk_t counters[blocksize_bits + 2]; + +This reverts part of my previous patch, using a fixed-size array +again, but keeping the check for the array overflow. + +Fixes: 2df2c3402fc8 ("ext4: fix warning about stack corruption") +Reported-by: Stefan Agner +Tested-by: Chandan Rajendra +Signed-off-by: Arnd Bergmann +Signed-off-by: Theodore Ts'o +--- + fs/ext4/mballoc.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c +index 5a1052627a81..701085620cd8 100644 +--- a/fs/ext4/mballoc.c ++++ b/fs/ext4/mballoc.c +@@ -2300,7 +2300,7 @@ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v) + EXT4_MAX_BLOCK_LOG_SIZE); + struct sg { + struct ext4_group_info info; +- ext4_grpblk_t counters[blocksize_bits + 2]; ++ ext4_grpblk_t counters[EXT4_MAX_BLOCK_LOG_SIZE + 2]; + } sg; + + group--; +@@ -2309,6 +2309,9 @@ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v) + " 2^0 2^1 2^2 2^3 2^4 2^5 2^6 " + " 2^7 2^8 2^9 2^10 2^11 2^12 2^13 ]\n"); + ++ i = (blocksize_bits + 2) * sizeof(sg.info.bb_counters[0]) + ++ sizeof(struct ext4_group_info); ++ + grinfo = ext4_get_group_info(sb, group); + /* Load the group info in memory only if not already loaded. */ + if (unlikely(EXT4_MB_GRP_NEED_INIT(grinfo))) { +@@ -2320,7 +2323,7 @@ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v) + buddy_loaded = 1; + } + +- memcpy(&sg, ext4_get_group_info(sb, group), sizeof(sg)); ++ memcpy(&sg, ext4_get_group_info(sb, group), i); + + if (buddy_loaded) + ext4_mb_unload_buddy(&e4b); diff --git a/series b/series index 92b558f4..53e3a53a 100644 --- a/series +++ b/series @@ -1,5 +1,7 @@ # v4.13-rc4 +fix-clang-build-regression + #################################################### # unstable patches #################################################### diff --git a/timestamps b/timestamps index 724e2c6d..0a7b8399 100755 --- a/timestamps +++ b/timestamps @@ -28,11 +28,12 @@ touch -d @1502070529 jbd2-dont-double-bump-transaction-number touch -d @1502070589 journal-superblock-changes touch -d @1502070649 add-journal-no-cleanup-option touch -d @1502070709 add-support-for-log-metadata-block-tracking-in-log -touch -d @1502682265 series touch -d @1502684565 add-indirection-to-metadata-block-read-paths touch -d @1502684568 cleaner touch -d @1502684568 load-jmap-from-journal touch -d @1502684569 add-ext4-journal-lazy-mount-option touch -d @1502684569 disable-writeback -touch -d @1502684572 status -touch -d @1502684616 timestamps +touch -d @1502713301 series +touch -d @1502713758 fix-clang-build-regression +touch -d @1502713758 status +touch -d @1502713760 timestamps -- 2.11.4.GIT