Received: by 10.223.185.116 with SMTP id b49csp1500323wrg; Sun, 11 Feb 2018 13:39:10 -0800 (PST) X-Google-Smtp-Source: AH8x226ykR7kA1dfvzvV4HMDr/mYa0hMa7hyxQhIssSzvIt7oiK0Uy4axwiZRevTFM+Nv8AcI7RD X-Received: by 10.98.150.14 with SMTP id c14mr9613255pfe.210.1518385150644; Sun, 11 Feb 2018 13:39:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518385150; cv=none; d=google.com; s=arc-20160816; b=NWbe40VSGH6VI+mE+kJqaCNkXqBxnocdWQuTPQnlayuATPN5GcG3OWORIVfqqlhLTA GyVWVkJCR6QrIU5CsZquiJigL69zklmkpkdPYzwg4gaVWTe5iPXqpZexC25JxpMQFfRQ t9pX9g6XLAAmyVJHm3eA8sWPgKRt4gWcEKOzYReMlaym/W7xK9o43aElJ2J3ZWVArh5H wnXLiy+JAzVY5FhASyFAtLVhy23Z37mEFImARkfA0bRdS1NlB+BW1jH9dnlzkjEIWDNt coGBfxm0H8JHlo6qFt6jPDqQHkrNRzIJpWtKfryqbaUahBSPD4g0z7EKAGwGwIAJh/3W 58rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=g1ecqs6KCKouTjurhPlsjflTpMif4W1Uz4lQR9WbcuU=; b=Pn9GXnoP3Il2TqAXxcjim5cQrFFJjU3SIbzMB4wWCCa3ynKZ+mlsjbb6OwIYU6k7FS D9+SbdQA4Vxzf1xsxOCPajuVE/NJptHUkdtNtMm+sbm85n/JUwr8BoHFu2bRvrGFuQSd YQ8CM/Pomi9xmgx9pQWKFIxpu8VeN4NVk3PAlWU00xOvTbFNnveAuOGrfBbqmgMb4AeC tz0AekqWxZVmQ99f3tOBEnXdHSKs/ijKn/d6auN3YWeAUbc5LvO+oH1uDpY8hVZZDK9D ZfwXevqxraT37Cz8JwCSaG6zIx8+RGtqMueJZbSCvGCnedPaDNBjvGIOIWExoSJDOnNS cmYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=dRnoIFnj; 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 bc9-v6si4922086plb.12.2018.02.11.13.38.56; Sun, 11 Feb 2018 13:39:10 -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=fail header.i=@infradead.org header.s=casper.20170209 header.b=dRnoIFnj; 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 S932161AbeBKViJ (ORCPT + 99 others); Sun, 11 Feb 2018 16:38:09 -0500 Received: from casper.infradead.org ([85.118.1.10]:34900 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753503AbeBKViI (ORCPT ); Sun, 11 Feb 2018 16:38:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: Message-ID:In-Reply-To:Subject:cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=g1ecqs6KCKouTjurhPlsjflTpMif4W1Uz4lQR9WbcuU=; b=dRnoIFnjUjA4IzqKr56BToQDZ B/cHPoaMMwfrASI0Yxcbxi1qavYQswiX68dHFxH0jfL0u8Uq5+E21QNpxXg5qDJd+xy/nsxywljHt k2UqGY/KVhl+c24nLjy2d6L6/e2tI8km1TAt+/M8qMKTfxCjEanu/YVXA9SI4100+L34TY/5I3DsR uYUfP9sOOepRLs2bwy98UgwgyyrJehKzNcZhDt6zkquTYQw1TBGT1JOZuPub486vR0AKU+1jA1U+i fSmMfO9qFY+QDAmIiJKzJCVmX01ollPxOiYX6GU3Wd8KuympG9EHMH6D9DFI8yiFYyLj1Y+ZpmBI8 EHsKrjIrw==; Received: from jsimmons (helo=localhost) by casper.infradead.org with local-esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ekzJy-0001HK-4s; Sun, 11 Feb 2018 21:38:04 +0000 Date: Sun, 11 Feb 2018 21:38:01 +0000 (GMT) From: James Simmons To: Sven Dziadek cc: "Dilger, Andreas" , Greg Kroah-Hartman , "Drokin, Oleg" , lkml , "devel@driverdev.osuosl.org" , lustre-devel , "Eremin, Dmitry" Subject: Re: [PATCH] staging: lustre: llite: replace variable length array In-Reply-To: <58963c7f-139c-1156-0179-13decf0bcddf@gmx.de> Message-ID: References: <20180127214228.26986-1-sven.dziadek@gmx.de> <58963c7f-139c-1156-0179-13decf0bcddf@gmx.de> User-Agent: Alpine 2.21 (LFD 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180211_213802_191253_BBEAD002 X-CRM114-Status: GOOD ( 29.27 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on casper.infradead.org summary: Content analysis details: (-1.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 NO_RELAYS Informational: message was not relayed via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On 01/30/2018 03:04 AM, Dilger, Andreas wrote: > > On Jan 27, 2018, at 14:42, Sven Dziadek wrote: > >> > >> The functionality of the removed variable length array is already > >> implemented by the function xattr_full_name in fs/xattr.c > >> > >> This fixes the sparse warning: > >> warning: Variable length array is used. > >> > >> Signed-off-by: Sven Dziadek > >> --- > >> drivers/staging/lustre/lustre/llite/xattr.c | 12 ++++-------- > >> 1 file changed, 4 insertions(+), 8 deletions(-) > >> > >> diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c > >> index 532384c91447..4fd28213c6a1 100644 > >> --- a/drivers/staging/lustre/lustre/llite/xattr.c > >> +++ b/drivers/staging/lustre/lustre/llite/xattr.c > >> @@ -87,7 +87,6 @@ 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; > >> @@ -141,9 +140,8 @@ ll_xattr_set_common(const struct xattr_handler *handler, > >> return -EPERM; > >> } > >> > >> - sprintf(fullname, "%s%s\n", handler->prefix, name); > >> - rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode), > >> - valid, fullname, pv, size, 0, flags, > >> + rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode), valid, > >> + xattr_full_name(handler, name), pv, size, 0, flags, > >> ll_i2suppgid(inode), &req); > > > > Hi Sven, > > thanks for the patch. > > > > Looking at the details of "xattr_full_name()", this seems quite risky. This > > is essentially returning the pointer _before_ "name" on the assumption that > > it contains the full "prefix.name" string. IMHO, that is not necessarily a > > safe assumption to make several layers down in the code. > Thanks for your reply. And yeah, it feels strange, right. > > But it really looks like this is how the name and the prefix is handled > in the xattr code. > It seems this helper function has been introduced with commit > e409de992e3ea (which also removes some fullname pointer) and indeed, > fs/xattr.c splits the prefix and the name in xattr_resolve_name. > > So I still think the patch should be correct..? > > > James, I thought you had a patch for this to use kasprintf() instead of the > > on-stack "fullname" declaration? > Sorry for replying that late, I though James would maybe know if the > above assumption is correct.. Yes I do have a patch for this. I pushed them several months ago but they got missed. It happens. I will the patches again very soon. > >> if (rc) { > >> if (rc == -EOPNOTSUPP && handler->flags == XATTR_USER_T) { > >> @@ -364,7 +362,6 @@ 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]; > >> struct ll_sb_info *sbi = ll_i2sbi(inode); > >> #ifdef CONFIG_FS_POSIX_ACL > >> struct ll_inode_info *lli = ll_i2info(inode); > >> @@ -411,9 +408,8 @@ 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); > >> + return ll_xattr_list(inode, xattr_full_name(handler, name), > >> + handler->flags, buffer, size, OBD_MD_FLXATTR); > >> } > >> > >> static ssize_t ll_getxattr_lov(struct inode *inode, void *buf, size_t buf_size) > >> -- > >> 2.11.0 > >> > >