Received: by 10.223.185.116 with SMTP id b49csp4667468wrg; Tue, 6 Mar 2018 21:48:41 -0800 (PST) X-Google-Smtp-Source: AG47ELtKBWcinQigkUjyqJWu7T84yhwHYg29UmTn0KV1epLj6Sdfkf9YwxPdTKisooOwTVbPmMPt X-Received: by 10.99.55.70 with SMTP id g6mr17197278pgn.284.1520401720976; Tue, 06 Mar 2018 21:48:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520401720; cv=none; d=google.com; s=arc-20160816; b=umkaZWD2L2yhWLyMbAUrDCr8A+hjZM4QEEtjmhk2NiV1g3DW+9kmqLAX+HI0zS6Vxb mL8Tdc8UO9pkASj0acu5fxAcgLlffohn4bfGdKQc4nWARbUtWY8E+P84JY20GEQsbCha zEmnJj0Sok6/mzl/cVqj2cC9K9blNeNoY8ueG0UZZAIm0T13LwCKy6J9ybyJDyQKins1 NZNacXNAjs0ADryKDKF8vZPbPyEv5Rx1f+rzkhB7mjsMk6GXD/2FRtxkFYPAxQBv8mjd Sa2iTiWMtysT3dObo+hHn9JDsHipAwU4atx20O3NF4UTxo0i+6e3EPSc8Mny0+zHkaew d2jA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=x5JfCzOkEunq/JJYivUAszT35eOQPYfrTlGPv5rCsOI=; b=g4XYus1vB4QKPhr25HvWVB6dudoWP4aCIYomAsiaX+gHwbX9+rVU3lcKTIOdC0it2P L4fZ/7FNmckkV5cvZrGBYbbMnX8wTXgHIBWRxe03gdmBgGb5aC52QstSAJOSR8eXLUrB ZazggbQ9TlFLp6Zho+kFAOI8l2WcWshwhamoHmllMbw9c72prNsA8gX+T9Gx+tBP0YbX Wz7BG3tKAa816QG8znjZ6vLr/d3hK99sHKSnNZxIu9weSLRG6mGEsjRpd3EsSzTnM+aL 9/hFMhOgVSgiRtKbdpUQdXdWOdLEm5cD80ZWfwN4SHW0moMlAJHD/0OMMTaLZKh8X5ok yF5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=HLJ0m/B2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h71si10900882pgc.3.2018.03.06.21.48.25; Tue, 06 Mar 2018 21:48:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=HLJ0m/B2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751099AbeCGFqQ (ORCPT + 99 others); Wed, 7 Mar 2018 00:46:16 -0500 Received: from mail-pl0-f68.google.com ([209.85.160.68]:36815 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751042AbeCGFqM (ORCPT ); Wed, 7 Mar 2018 00:46:12 -0500 Received: by mail-pl0-f68.google.com with SMTP id 61-v6so753392plf.3 for ; Tue, 06 Mar 2018 21:46:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=x5JfCzOkEunq/JJYivUAszT35eOQPYfrTlGPv5rCsOI=; b=HLJ0m/B2kf6Kka1IenDc1BkaRyCFoNNJjIeWSR8kIZsPmtTDYI1JLOL2V2rr9R4LNV LMpJWRHqNjHJ8mxnl3wBzYY0wRaNYkp99fctQkr9HY21Ft3iOXBAhAo41LTJ8P8zsMqs wyyq+egIjnsypPZD9zH1QXHCam/Oru2uEaCfA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=x5JfCzOkEunq/JJYivUAszT35eOQPYfrTlGPv5rCsOI=; b=dAAnfKrZvEavfJmJJ4c+vhWoCyONxZRcgdtmFmXOHIeHzMbfUJbHkPHVf3SsIij6y6 t6lYLAzhRiy3hD6ZKp7ffCqPmsA/hi82HviuDGDoWlY0F6UY+v/qt2OeIOYknG5seck0 N6IbPjsb6vxdV+VsWK/B6zXPO8/sA5PbU6UPZzAJtbdfXdDLNuLlAZEgT8CIvR1Cr4ji 8zFKmIMeTrHEb3YeiSmf03I55F/ixRD3prLSxxxJlgDahU76QfXxuKWOKx2t1Ucm87/b mqPSmi8Uri9h6YmWPAM3VTyUnL+iX9n1HTHifiQFgzq72WJM4CKaHGpS7G+3y51dKety rLKw== X-Gm-Message-State: APf1xPCl49hNcJV+KmwTNkrleqicf/cToLMquDsS6cQFuw8gYxQ/HjWe F6ebxaNXqejbXvzBH0T4ln8IxQ== X-Received: by 2002:a17:902:3283:: with SMTP id z3-v6mr19743745plb.118.1520401571723; Tue, 06 Mar 2018 21:46:11 -0800 (PST) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id l74sm18061206pga.33.2018.03.06.21.46.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Mar 2018 21:46:09 -0800 (PST) Date: Tue, 6 Mar 2018 21:46:08 -0800 From: Kees Cook To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, "Tobin C. Harding" , Tycho Andersen , Oleg Drokin , Andreas Dilger , James Simmons , Greg Kroah-Hartman , Dmitry Eremin , Gargi Sharma , lustre-devel@lists.lustre.org, devel@driverdev.osuosl.org, Kernel Hardening Subject: [PATCH] staging: lustre: Remove VLA usage Message-ID: <20180307054608.GA9300@beast> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The kernel would like to remove all VLA usage. This switches to a simple kasprintf() instead. Signed-off-by: Kees Cook --- drivers/staging/lustre/lustre/llite/xattr.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c index 532384c91447..aab4eab64289 100644 --- a/drivers/staging/lustre/lustre/llite/xattr.c +++ b/drivers/staging/lustre/lustre/llite/xattr.c @@ -87,7 +87,7 @@ 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]; + char *fullname; struct ll_sb_info *sbi = ll_i2sbi(inode); struct ptlrpc_request *req = NULL; const char *pv = value; @@ -141,10 +141,13 @@ ll_xattr_set_common(const struct xattr_handler *handler, return -EPERM; } - sprintf(fullname, "%s%s\n", handler->prefix, name); + fullname = kasprintf(GFP_KERNEL, "%s%s\n", handler->prefix, name); + if (!fullname) + return -ENOMEM; rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode), valid, fullname, pv, size, 0, flags, ll_i2suppgid(inode), &req); + kfree(fullname); if (rc) { if (rc == -EOPNOTSUPP && handler->flags == XATTR_USER_T) { LCONSOLE_INFO("Disabling user_xattr feature because it is not supported on the server\n"); @@ -364,7 +367,7 @@ static int ll_xattr_get_common(const struct xattr_handler *handler, struct dentry *dentry, struct inode *inode, const char *name, void *buffer, size_t size) { - char fullname[strlen(handler->prefix) + strlen(name) + 1]; + char *fullname; struct ll_sb_info *sbi = ll_i2sbi(inode); #ifdef CONFIG_FS_POSIX_ACL struct ll_inode_info *lli = ll_i2info(inode); @@ -411,9 +414,13 @@ static int ll_xattr_get_common(const struct xattr_handler *handler, if (handler->flags == XATTR_ACL_DEFAULT_T && !S_ISDIR(inode->i_mode)) return -ENODATA; #endif - sprintf(fullname, "%s%s\n", handler->prefix, name); - return ll_xattr_list(inode, fullname, handler->flags, buffer, size, - OBD_MD_FLXATTR); + fullname = kasprintf(GFP_KERNEL, "%s%s\n", handler->prefix, name); + if (!fullname) + return -ENOMEM; + rc = ll_xattr_list(inode, fullname, handler->flags, buffer, size, + OBD_MD_FLXATTR); + kfree(fullname); + return rc; } static ssize_t ll_getxattr_lov(struct inode *inode, void *buf, size_t buf_size) -- 2.7.4 -- Kees Cook Pixel Security