From patchwork Mon Aug 7 10:56:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 798576 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xQvcr0FZ8z9t1t for ; Mon, 7 Aug 2017 20:57:32 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752883AbdHGK5b (ORCPT ); Mon, 7 Aug 2017 06:57:31 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:52412 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752606AbdHGK5a (ORCPT ); Mon, 7 Aug 2017 06:57:30 -0400 Received: from wuerfel.lan ([78.43.238.10]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.129]) with ESMTPA (Nemesis) id 0MDpjK-1drNJX1pd8-00HAyy; Mon, 07 Aug 2017 12:57:05 +0200 From: Arnd Bergmann To: "Theodore Ts'o" , Andreas Dilger Cc: Stefan Agner , Arnd Bergmann , Jan Kara , Daeho Jeong , Chandan Rajendra , "Darrick J. Wong" , Konstantin Khlebnikov , linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] ext4: fix clang build regression Date: Mon, 7 Aug 2017 12:56:51 +0200 Message-Id: <20170807105701.3835991-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:LiRB3LlHiufwmYgBuH0it7zL1RGW0g5etGgahoZF2oWEMlw8LAv x7WpQuJ/E4hecf/yAhF6WnJEaGwRWvXPnv5peMPpup+oREdA/1LBL2mf4EWfxBTvZR5rjpK HUsd8/28POOv55R4oYQffbE63+nquFeLNEgQkF5czy0tTMeVoFcjaU7zXba8m0ThdSPR1LE aXrFaD2q0B5tcTzr4+vjA== X-UI-Out-Filterresults: notjunk:1; V01:K0:qg1WNlkVCJw=:SVQctkFfqWycUh1MqpR2ur xw/Sy7My7DJlm9m7yvTlCq6taH7dMxnk/tXRrTjvNaFa98vx7EEwOye1aZ8bhEcUHEeTS6dXS zri6YwgF2wcUuocJc/SQRKPqBPy4SPBfVUG7EFYFaMkrZAOqeANymGdRDdoAZrIGat9/C755Y 2W0+aeUCA92BwTgpAwOJ6jER6tdmYk7kGF6OH/NdgJBHBQc2drER8vJjGaZpoBvE9Om0HUzIY +ExiPBNgeF40A0Wb5upRo7/IUGep3/B9U0TNu4HB7seEJKL4xNHMb/dJVDg/cU2dto4NLZrCI l0n3SgUqqcdaGYb+uSQFuqJls3NVRmIp6STSkEIo9RXphgWQtXFSF7UM64HmLVT7fy9BL33Y9 uy6zW5chujz6140MY9UwXvxwS85EZLbnxyOtAvsqSANL/tLFLDKn6t20ibDLKXpm8/W+Oc/cG 42/s6uyCktGnaIC+KeW7fTssFoZ0vj8yYS2bFmROmeYn219u0imQ/diKAHpiymeeUB5zd1qYe KnxxNSEwOSBhQXDNl/87flx5Ry3fl1PsdQq+uFs/cS1h/KcrofNkGozvRSImAqyIAhad6pIyT +d+YLetzpFTCbJqzcdyNKLcFNWLyv9J26Th83czktRFFF7+2lcmMKmsW3zIpZ6fe9588PN2Li rPFvlYwzFbLxJdPoeqmKDIBpGn9k1ThDgKnS2l80RM9PEST1QX0+fF9BGF7GlkRaxx+1VEts9 H/GPEOsXsAdWTgkABHWW9wPFmBosNQ6TI8Qdkw== Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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 Signed-off-by: Arnd Bergmann Tested-by: Chandan Rajendra --- 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);