From patchwork Thu Mar 8 03:30:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10265961 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0A1E960364 for ; Thu, 8 Mar 2018 03:32:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1E11296B3 for ; Thu, 8 Mar 2018 03:32:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E6613296ED; Thu, 8 Mar 2018 03:32:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 2978A296B3 for ; Thu, 8 Mar 2018 03:32:01 +0000 (UTC) Received: (qmail 18323 invoked by uid 550); 8 Mar 2018 03:31:45 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 18204 invoked from network); 8 Mar 2018 03:31:42 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/vHLZGS16nbwTMecQJI11d8xIWqeetkTGSb9vfbhh9M=; b=VNJDAjgLgEi46OMxhzKOCJrnZUT4QyaWihKp4w37TkwEDnI+StPaTECS8gjCfqP40Q hY01TVocxcG/Rcj4Hl5Tfl/9gIcDz3X/+gHPvsTePUN+6MC6RFil6CUWBcdAquE+Whcn n2iyxDOWxXvYe5R6tY18kfMTgx2TBtlCGat4o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/vHLZGS16nbwTMecQJI11d8xIWqeetkTGSb9vfbhh9M=; b=rtbQJpHsm6BfBSmroSQ9r4US/QidEWPUYsikBJT086kHtHqb1W9at0ITDLcPJNbhwU l9MzQ6dYwfxjqV/TPV9VRAP1hWRurS4kdqKUgMT5Z1M6zcrG6gOph8mM2WJeQUiL+C/T N93x3lPBs1NKHshpBsFZ67XYexKlQNEjjMqJkg9D79uZ2GjSVgSxJQYraM8/yTLm0LAj mABSG/jIUoamhR94VKBVvdjnLiFx+sk6ELsGkv8G4aPThR00csxQcHfJKgSn+y5yPY2J NTtNFBFLE1bZgKbQfL5XzmpfbI6QtRjdT012gYStj534UBdUxv+VtM9Pn5/dnjRZIJli m97w== X-Gm-Message-State: APf1xPCjAYoIIiip+P7Rp+xcPKONnDagtQ6BfkvMa9nOU+YsnFeM/ZXg TxqZ+oTY5bKClbgDEbUBHyR6KA== X-Google-Smtp-Source: AG47ELuZ74DnxoOUGkEy1ly37hb0YXX0nSJwi3loSRpoRqIxXp48RXooR+5xF/xkTQS4LI/RuE/esw== X-Received: by 2002:a17:902:710f:: with SMTP id a15-v6mr22100933pll.87.1520479891076; Wed, 07 Mar 2018 19:31:31 -0800 (PST) From: Kees Cook To: Andrew Morton 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-btrfs@vger.kernel.org, netdev@vger.kernel.org, kernel-hardening@lists.openwall.com 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> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520479847-39174-1-git-send-email-keescook@chromium.org> References: <1520479847-39174-1-git-send-email-keescook@chromium.org> X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: David Sterba --- 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);