From patchwork Wed Mar 7 05:27:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobin Harding X-Patchwork-Id: 10263385 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 378FC602C8 for ; Wed, 7 Mar 2018 05:28:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25D8F292C8 for ; Wed, 7 Mar 2018 05:28:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1691C292EE; Wed, 7 Mar 2018 05:28:30 +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 4FEEC292C8 for ; Wed, 7 Mar 2018 05:28:28 +0000 (UTC) Received: (qmail 1845 invoked by uid 550); 7 Mar 2018 05:28:05 -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 1797 invoked from network); 7 Mar 2018 05:28:02 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tobin.cc; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=jPFg9xfD5J+UdjOVU kic4j1OoDxvgi11rVHOiABWRsQ=; b=bA3amzsvtrDl4w8hvz8YQYQVg9R7P8H7y p/cQNnMakGX2G6+aE0zGX/nzjqk7g4ZehHXnr+e/XQzhG9LDiSK0bVR/i6gX0xJ2 Wrg8bdJx1OCb1Gz7Q3hORgcj9rkgsRWKD4w2aLtXBi1BSW817Hu5VLIJfJlRFzTx jVdNDVobuPw0WogNItBxKfbicrjCEYdVPmpAjAjl8MdUXs9yutzL3Wm5ecRRu7+3 0NBowEWtNqEGVOS3vXX8vRpY4nH6oDxYVpiwp9Jt8D+suaw576X1dnaMi36rpshJ p/K9XWBXGOsYFtpdS2Y/dHcXpUGpH8hxbZ1k/lNVoShr0XtCZoAAQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=jPFg9xfD5J+UdjOVUkic4j1OoDxvgi11rVHOiABWRsQ=; b=CRDnIQ0s fqAQ8FAQ1cr7+eEOkYmMWoHmMRFIuXwuAEQoHynNYQKUq3YNNOYiy7YqP3oUCbw3 j+MTba2r/30RXHhdm8jFy8w10jPxGWAEWV58hapbpEwK65waJvWPIqdJNQu2a1hb F/J53FhGpTeAvTkvbwaST/KYHzm0j1WVXJ+U00EBabXwFmpWvshYWzKkHtoOjVkE K9poSXBYx5YNnDuTwIgECmytOz8qZ+SGGl17jJ5gwWoTg31kZGfaG5ndP4NSDusA iJdMUE4ciuoqra+E3GCNIJ3EMPI/F9h31CrF3Tp8Phaa1rTvUOJXQ+7qHdJbIeoF dohi8GnD/P+kqw== X-ME-Sender: From: "Tobin C. Harding" To: Kernel Hardening , Tycho Andersen Cc: "Tobin C. Harding" , Kees Cook , Oleg Drokin , Andreas Dilger , James Simmons , Greg Kroah-Hartman Subject: [RFC 2/2] lustre: use VLA_SAFE Date: Wed, 7 Mar 2018 16:27:31 +1100 Message-Id: <1520400451-11475-3-git-send-email-me@tobin.cc> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520400451-11475-1-git-send-email-me@tobin.cc> References: <1520400451-11475-1-git-send-email-me@tobin.cc> X-Virus-Scanned: ClamAV using ClamSMTP Currently lustre uses a VLA to store a string on the stack. We can use the newly define VLA_SAFE macro to make this declaration safer. Use VLA_SAFE to declare VLA. Signed-off-by: Tobin C. Harding --- drivers/staging/lustre/lustre/llite/xattr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c index 532384c91447..6f4099cd4afa 100644 --- a/drivers/staging/lustre/lustre/llite/xattr.c +++ b/drivers/staging/lustre/lustre/llite/xattr.c @@ -36,6 +36,7 @@ #include #include #include +#include #define DEBUG_SUBSYSTEM S_LLITE @@ -87,12 +88,13 @@ ll_xattr_set_common(const struct xattr_handler *handler, const char *name, const void *value, size_t size, int flags) { - char fullname[strlen(handler->prefix) + strlen(name) + 1]; struct ll_sb_info *sbi = ll_i2sbi(inode); struct ptlrpc_request *req = NULL; const char *pv = value; __u64 valid; int rc; + int size = strlen(handler->prefix) + strlen(name) + 1; + VLA_SAFE(char, fullname, size, VLA_DEFAULT_MAX); if (flags == XATTR_REPLACE) { ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_REMOVEXATTR, 1);