Received: by 10.223.185.116 with SMTP id b49csp4852731wrg; Wed, 7 Mar 2018 02:03:33 -0800 (PST) X-Google-Smtp-Source: AG47ELvWzvPurMyj4NEWa9K2XWnh7EtH52g7Ywe9wBWGTikVENBTOj514MhySKkaqI2dyP0CHJb+ X-Received: by 10.98.198.92 with SMTP id m89mr13439940pfg.73.1520417013264; Wed, 07 Mar 2018 02:03:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520417013; cv=none; d=google.com; s=arc-20160816; b=kDVQSw9T5nktJp0EZOtgaFCbYtCZ0s549pDN9ibRpZ9zkc0n3D+UHFdg2v1Z3LkkVX PxVZaBHE2bB9/17R/PWQyqJvCVxV62Ik1dS6lYvlgFAY70huJ8PMGARtMHAF8nv7NS5U JfeKCRqu2zTfUXocxFKTVZROv+9cwXnLbiJ7Rg/iwpmhEA68fWZAJGcMVzkVR+3PGiRv CI4rzIG/1XEZcqcDmyXOCeWKHRo7RHTCclz9hnImzTkJRvJ8AGPGKc0Kn7U7NPXVkzxn efwVFwOOQGSiciNm6F23MkNQY38jtpDDpuId0nud9/zUeMR5Q6cqf0HoiDVoUXorIORV xbqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=IWxnAHRXhRNMfGQGkv2KwhS42pK2a1myrY9t22bK0OA=; b=TdSJyeC9fB07CFugZbfK5BsdlDWcU9c/9nMlLRinDLDXyZBfOEa6cSEabZNH6Sa9Yt +1od5MW6gJjocwwVDko9B/Q3fWAmMI68YUb51eth0iHbGcjo7+KjV1JKEyb7a6Y1AZOl h1ZBNC6I10ScQg3O3C+2SnBSX2X+PuDsTrJfWELrrHlrEptJ75DFrTpBMexTmeJLDkZ+ n8Qyg/iwkeYVsGjWNgNBZdKT+NMn8OIdp6rygk75JDx7qj4sE5rS4lLRLXMrXkCW0PDN TnQWxktj3De6Ty9Ugn0fJ/ZDkBlVztJ8yra9nTavQXCaHS2ZCyahLwuiAD9f8dD4Qjei yciQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=MDuZDOZI; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u83si610299pfj.360.2018.03.07.02.03.17; Wed, 07 Mar 2018 02:03:33 -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=@messagingengine.com header.s=fm2 header.b=MDuZDOZI; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751225AbeCGKCL (ORCPT + 99 others); Wed, 7 Mar 2018 05:02:11 -0500 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:45279 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751127AbeCGKCI (ORCPT ); Wed, 7 Mar 2018 05:02:08 -0500 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 18FE820D8D; Wed, 7 Mar 2018 05:02:08 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute1.internal (MEProxy); Wed, 07 Mar 2018 05:02:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=IWxnAHRXhRNMfGQGkv2KwhS42pK2a 1myrY9t22bK0OA=; b=MDuZDOZI6RP43C4e4EFHG9HQsa0dt0wViCA66/T0quHtF sqKyV37tXyKLXE3mO8l7lWb+i1/lICVxd1arVLzvfA4CszjLzeAAuDl7G6TQ9gIc KAO1Pm9Ar1X8z2sGe8pm/cFrEh9uvE3gHfMrJ0eBpIXpYmMZgMRKmAoaXpHqlXeY nlw6oi6RT755M5oUEM079NGFbW15ARCa9uY/ZQYao01K8SUSoSJ1KS9Vu9K/a5+2 /dtMB9s0qfSFmqbvsnZfwMm2ZujKAoKFbbk2hlGsRAIWtzc8pKmrayCPt97yHMkc TRalgKLwjAhaWDNiAgUwtR1ViYXUzcfh7YqLvpoTQ== X-ME-Sender: Received: from localhost (ppp121-44-99-155.bras1.syd7.internode.on.net [121.44.99.155]) by mail.messagingengine.com (Postfix) with ESMTPA id 67E5B7E46B; Wed, 7 Mar 2018 05:02:07 -0500 (EST) Date: Wed, 7 Mar 2018 21:02:05 +1100 From: "Tobin C. Harding" To: Kees Cook Cc: Greg Kroah-Hartman , linux-kernel@vger.kernel.org, "Tobin C. Harding" , Tycho Andersen , Oleg Drokin , Andreas Dilger , James Simmons , Dmitry Eremin , Gargi Sharma , lustre-devel@lists.lustre.org, devel@driverdev.osuosl.org, Kernel Hardening Subject: Re: [PATCH] staging: lustre: Remove VLA usage Message-ID: <20180307100205.GF11750@eros> References: <20180307054608.GA9300@beast> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180307054608.GA9300@beast> X-Mailer: Mutt 1.5.24 (2015-08-30) User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 06, 2018 at 09:46:08PM -0800, Kees Cook wrote: > 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); This is cool. We've had kasprintf() since 2007, who knew?! thanks, Tobin.