From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kees Cook Subject: [PATCH 3/3] btrfs: tree-checker: Avoid accidental stack VLA Date: Wed, 7 Mar 2018 19:30:47 -0800 Message-ID: <1520479847-39174-4-git-send-email-keescook@chromium.org> References: <1520479847-39174-1-git-send-email-keescook@chromium.org> Cc: Kees Cook , linux-kernel@vger.kernel.org, corbet@lwn.net, gustavo@embeddedor.com, rostedt@goodmis.org, Chris Mason , Josef Bacik , David Sterba , "David S. Miller" , Alexey Kuznetsov , Hideaki YOSHIFUJI , Ingo Molnar , Peter Zijlstra , Thomas Gleixner , Masahiro Yamada , Borislav Petkov , Josh Poimboeuf , Randy Dunlap , Ian Abbott , "Tobin C. Harding" , Sergey Senozhatsky , Petr Mladek , Andy Shevchenko , Pantelis Antoniou , linux-bt To: Andrew Morton Return-path: List-Post: List-Help: List-Unsubscribe: List-Subscribe: In-Reply-To: <1520479847-39174-1-git-send-email-keescook@chromium.org> List-Id: netdev.vger.kernel.org In the quest to remove all stack VLAs from the kernel[1], this refactors the stack array size calculation to avoid using max(), which makes the compiler think the size isn't fixed. [1] https://lkml.org/lkml/2018/3/7/621 Signed-off-by: Kees Cook --- fs/btrfs/tree-checker.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c index c3c8d48f6618..59bd07694118 100644 --- a/fs/btrfs/tree-checker.c +++ b/fs/btrfs/tree-checker.c @@ -341,7 +341,8 @@ static int check_dir_item(struct btrfs_root *root, */ if (key->type == BTRFS_DIR_ITEM_KEY || key->type == BTRFS_XATTR_ITEM_KEY) { - char namebuf[max(BTRFS_NAME_LEN, XATTR_NAME_MAX)]; + char namebuf[SIMPLE_MAX(BTRFS_NAME_LEN, + XATTR_NAME_MAX)]; read_extent_buffer(leaf, namebuf, (unsigned long)(di + 1), name_len); -- 2.7.4