From patchwork Fri Dec 11 12:15:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Gruenbacher X-Patchwork-Id: 7829251 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 7C172BEEE1 for ; Fri, 11 Dec 2015 12:16:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B3C6820454 for ; Fri, 11 Dec 2015 12:16:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DD4552041B for ; Fri, 11 Dec 2015 12:16:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755253AbbLKMPv (ORCPT ); Fri, 11 Dec 2015 07:15:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41374 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755007AbbLKMPu (ORCPT ); Fri, 11 Dec 2015 07:15:50 -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 DF7A78E70F; Fri, 11 Dec 2015 12:15:49 +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 tBBCFkAv007000; Fri, 11 Dec 2015 07:15:47 -0500 From: Andreas Gruenbacher To: Alexander Viro , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: Andreas Gruenbacher Subject: [PATCH] nfs: Fix listxattr regression Date: Fri, 11 Dec 2015 13:15:46 +0100 Message-Id: <1449836146-5674-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 Al, the xattr cleanup patches which are meanwhile in your for-next branch broke listxattr on nfs. Could you please add this fix? Thanks, Andreas --- In removing the list operation of nfs4_xattr_nfs4_label_handler, commit d77ae742 has introduced a NULL pointer dereference in generic_listxattr. Fix by checking for NULL list operations. In addition, skip prefix (as opposed to full-name) xattr handlers there: listing a prefix is not meaningful. Signed-off-by: Andreas Gruenbacher --- fs/xattr.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/xattr.c b/fs/xattr.c index bfd4a85..477bda2 100644 --- a/fs/xattr.c +++ b/fs/xattr.c @@ -723,15 +723,18 @@ 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)