Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3695819imm; Mon, 18 Jun 2018 02:28:41 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLDHGnfTmRUqKbANBCjPLWkEBtgmSKcBVL0KUzXKXMN/zMqH0O4JUQ4WIQutdPk9sJ3q0Kt X-Received: by 2002:a63:714e:: with SMTP id b14-v6mr10086173pgn.73.1529314121611; Mon, 18 Jun 2018 02:28:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529314121; cv=none; d=google.com; s=arc-20160816; b=DJ+WKKdJyqU2GQ9IkOv6b+2r425At5ygvkuRk2IMjuU/U4KvWCqu1glmH6mEZmf7gy 1hWQGCfR3ls6Z8tCZAMhk/3sidSV6QmA6jXHGTLgmp/2zxxhI65lRhAc9t6Hy8+5hmaI +TMCceFp5+beRSBZyHpI7evSUnwmFZuNcvHwZouc/VGz9oavEamzOY6cR5oABkvDtXSH 5EW1bUB1JH1M6xjP77OTnM8Kkido5Wt6pjIBkDC/D4edtgCey91nfcatTWOoiaOiR/g3 JuxKBwIIaGisPf5ADQehd6cq+QW8aNqPj+Uh8thOoaKUAp5Lh1H87hB7nhB29z/mhqp7 qLsw== 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 :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=W9Otc8ya7kmDacrdDKA6kkeGN7CS9ym24/OU+OKE1S0=; b=THEMXkaMG3Dex1cYo756ADgGm89PpVz9ZuJ4E5fgm0y70wvb1pSfGacBEgx2H2387A tc5cYyqFx4vh8VND3VVFljFhxXX0+6zXWLFOCbB0AayQG1Y3x2tYRNwV9eyncPXzRTOS 1EwJGxd/uGlB+rWDE1yXWi2kT8a3Iqcbg2Asgl+ziscMa+lCauo9HoPs1KQV+WQifMKJ Wx1YJcLHRzJAosl/TKBFpElNmBbwHquUOf5b3kLsLsH5U7nrV1j4h22n6b89akpfNcAx Wo/A6lTr0igvE7SDgA5UsgK0HsyzlrqqjeSaLv08SBoeUbV7WFe1yNtEl4FUvgTrj7/S /ZUQ== ARC-Authentication-Results: i=1; mx.google.com; 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 33-v6si14515999plq.348.2018.06.18.02.28.27; Mon, 18 Jun 2018 02:28:41 -0700 (PDT) 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; 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 S965978AbeFRI0A (ORCPT + 99 others); Mon, 18 Jun 2018 04:26:00 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:57056 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965887AbeFRIZy (ORCPT ); Mon, 18 Jun 2018 04:25:54 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id BBDABBAD; Mon, 18 Jun 2018 08:25:51 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paulo Alcantara , Aurelien Aptel , Steve French , Sasha Levin Subject: [PATCH 4.16 209/279] cifs: smb2ops: Fix listxattr() when there are no EAs Date: Mon, 18 Jun 2018 10:13:14 +0200 Message-Id: <20180618080617.532558186@linuxfoundation.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618080608.851973560@linuxfoundation.org> References: <20180618080608.851973560@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Paulo Alcantara [ Upstream commit ae2cd7fb478b8da707906ee1706ae1379968a8f9 ] As per listxattr(2): On success, a nonnegative number is returned indicating the size of the extended attribute name list. On failure, -1 is returned and errno is set appropriately. In SMB1, when the server returns an empty EA list through a listxattr(), it will correctly return 0 as there are no EAs for the given file. However, in SMB2+, it returns -ENODATA in listxattr() which is wrong since the request and response were sent successfully, although there's no actual EA for the given file. This patch fixes listxattr() for SMB2+ by returning 0 in cifs_listxattr() when the server returns an empty list of EAs. Signed-off-by: Paulo Alcantara Reviewed-by: Aurelien Aptel Signed-off-by: Steve French Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/cifs/smb2ops.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -589,9 +589,15 @@ smb2_query_eas(const unsigned int xid, s SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid); + /* + * If ea_name is NULL (listxattr) and there are no EAs, return 0 as it's + * not an error. Otherwise, the specified ea_name was not found. + */ if (!rc) rc = move_smb2_ea_to_cifs(ea_data, buf_size, smb2_data, SMB2_MAX_EA_BUF, ea_name); + else if (!ea_name && rc == -ENODATA) + rc = 0; kfree(smb2_data); return rc;