From patchwork Fri Dec 11 16:09:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Gruenbacher X-Patchwork-Id: 7830961 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9EB6BBEEE1 for ; Fri, 11 Dec 2015 16:09:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C84F220444 for ; Fri, 11 Dec 2015 16:09:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E5E10201E4 for ; Fri, 11 Dec 2015 16:09:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755345AbbLKQJa (ORCPT ); Fri, 11 Dec 2015 11:09:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38895 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755323AbbLKQJ2 (ORCPT ); Fri, 11 Dec 2015 11:09:28 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 72157347A57; Fri, 11 Dec 2015 16:09:28 +0000 (UTC) Received: from nux.redhat.com (vpn1-6-237.ams2.redhat.com [10.36.6.237]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tBBG9O87025864; Fri, 11 Dec 2015 11:09:26 -0500 From: Andreas Gruenbacher To: Al Viro Cc: Andreas Gruenbacher , LKML , linux-fsdevel Subject: Re: [PATCH] nfs: Fix listxattr regression (2) Date: Fri, 11 Dec 2015 17:09:23 +0100 Message-Id: <1449850163-20050-1-git-send-email-agruenba@redhat.com> References: <1449836146-5674-1-git-send-email-agruenba@redhat.com> <20151211125528.GJ20997@ZenIV.linux.org.uk> <1449846859-19375-1-git-send-email-agruenba@redhat.com> In-Reply-To: <1449846859-19375-1-git-send-email-agruenba@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Fri, Dec 11, 2015 at 4:14 PM, Andreas Gruenbacher wrote: > Al, > > here is another fix for the same botched nfs commit. Could you please > also merge / fold that? Sorry for the mess. I've pushed a branch with those two fixes here: git://git.kernel.org/pub/scm/linux/kernel/git/agruen/linux xattr-wip2 This is your work.xattr branch with the fixes folded in and with your Signed-off-by tags removed from the two commits that have been modified: nfs: Move call to security_inode_listsecurity into nfs_listxattr xattr handlers: Simplify list operation Diff between work.xattr and xattr-wip2 below. Thanks, Andreas --- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index e9db118..c57d133 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -6296,8 +6296,8 @@ nfs4_listxattr_nfs4_label(struct inode *inode, char *list, size_t list_len) int len = 0; if (nfs_server_capable(inode, NFS_CAP_SECURITY_LABEL)) { - len = security_inode_listsecurity(inode, list, len); - if (len > list_len) + len = security_inode_listsecurity(inode, list, list_len); + if (list_len && len > list_len) return -ERANGE; } return len; diff --git a/fs/xattr.c b/fs/xattr.c index bfd4a85..d7f5037 100644 --- a/fs/xattr.c +++ b/fs/xattr.c @@ -723,21 +723,23 @@ generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size) if (!buffer) { for_each_xattr_handler(handlers, handler) { - if (handler->list(dentry)) - size += strlen(handler->name) + 1; + if (!handler->name || + (handler->list && !handler->list(dentry))) + continue; + size += strlen(handler->name) + 1; } } else { char *buf = buffer; size_t len; for_each_xattr_handler(handlers, handler) { - if (!handler->list(dentry)) + if (!handler->name || + (handler->list && !handler->list(dentry))) continue; len = strlen(handler->name); if (len + 1 > buffer_size) return -ERANGE; - memcpy(buf, handler->name, len); - buf[len] = 0; + memcpy(buf, handler->name, len + 1); buf += len + 1; buffer_size -= len + 1; }