Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1825511imm; Mon, 3 Sep 2018 10:24:54 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda5iVohUjPuV2oMDHkkXjiWXa1kWjTV2hZNKL6tvr1ezFPGIDfhBsD1uqXmhMKQ8aVt/1aL X-Received: by 2002:a17:902:7c0a:: with SMTP id x10-v6mr29442730pll.77.1535995494443; Mon, 03 Sep 2018 10:24:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535995494; cv=none; d=google.com; s=arc-20160816; b=0kMzWEc5B+zshJAappbUsFd17BKdeTrIuyV205cPCrnKj+Tot8ulLFcMWagOVqCHqh B0rsRiMLyU7JZV5Go225yV1/rKQtkfIV2XanrMo0D6qbaRumumAJ1wXIHqtzsW7j8sf2 zZa5m0q3P8A4SYrdRovYvPztE5ZPzI+CD5r2J9LmErDrhWcB5b+KEAmrrZoM4Df96z+S 57xgwARY0AsCvkL0ABl52LFR/ELunOhYR+GoP5R7Zup1v1IeiGKJshvxOBmiRG/bkefH FFDBOWDAMwdFiJwRKCLWcjTX3h3BrOZw2SYtfp4yY+khpFH/mPnymjwONGOyV9LMRQSB vx0A== 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=sJSjIZxn9I8/z/mxDp6vUGc4zf5luBlfGHjBDqUesMM=; b=XCdPp5hheDyLo6xT05wbOxabpBZ6drhqDz3W31G58o5F2achgY1YPBxonnNyATu+MX Sb/OJZC41r5nlhIFQ8/837TNgzQ7MMPSy6msyfWhNX7+wnr3CEmx6bGNCGIzujuKYYkf y88l0ITbFpOsngqlYhFZB9XXxne53OnmgwjdgzFZDzAjuzjaVeShqvmzFSYymMjHw2Jq v7NsncIuFoYWxVmjPHeyqrQF9o54z6iYGmRH3Gj0tHCCiKdo+tOzPSzS7DvvrG2UYfmj hEA+auU8IqkCK5yOpybGuGBY2EUNpfKtlKXVbv5F/LdwGl8TL3MD52m9gj+u9fKpXqap /yng== 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 y9-v6si18371527plk.427.2018.09.03.10.24.39; Mon, 03 Sep 2018 10:24:54 -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 S1730445AbeICVoB (ORCPT + 99 others); Mon, 3 Sep 2018 17:44:01 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45360 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728372AbeICVoA (ORCPT ); Mon, 3 Sep 2018 17:44:00 -0400 Received: from localhost (ip-213-127-74-90.ip.prioritytelecom.net [213.127.74.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 131E7D24; Mon, 3 Sep 2018 17:22:52 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Steve French , Aurelien Aptel Subject: [PATCH 4.14 089/165] smb3: fill in statfs fsid and correct namelen Date: Mon, 3 Sep 2018 18:56:15 +0200 Message-Id: <20180903165659.928373222@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180903165655.003605184@linuxfoundation.org> References: <20180903165655.003605184@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.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Steve French commit 21ba3845b59c733a79ed4fe1c4f3732e7ece9df7 upstream. Fil in the correct namelen (typically 255 not 4096) in the statfs response and also fill in a reasonably unique fsid (in this case taken from the volume id, and the creation time of the volume). In the case of the POSIX statfs all fields are now filled in, and in the case of non-POSIX mounts, all fields are filled in which can be. Signed-off-by: Steve French CC: Stable Reviewed-by: Aurelien Aptel Signed-off-by: Greg Kroah-Hartman --- fs/cifs/cifsfs.c | 18 ++++++++++-------- fs/cifs/smb2ops.c | 2 ++ fs/cifs/smb2pdu.c | 8 ++++++++ fs/cifs/smb2pdu.h | 11 +++++++++++ 4 files changed, 31 insertions(+), 8 deletions(-) --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -197,14 +197,16 @@ cifs_statfs(struct dentry *dentry, struc xid = get_xid(); - /* - * PATH_MAX may be too long - it would presumably be total path, - * but note that some servers (includinng Samba 3) have a shorter - * maximum path. - * - * Instead could get the real value via SMB_QUERY_FS_ATTRIBUTE_INFO. - */ - buf->f_namelen = PATH_MAX; + if (le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength) > 0) + buf->f_namelen = + le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength); + else + buf->f_namelen = PATH_MAX; + + buf->f_fsid.val[0] = tcon->vol_serial_number; + /* are using part of create time for more randomness, see man statfs */ + buf->f_fsid.val[1] = (int)le64_to_cpu(tcon->vol_create_time); + buf->f_files = 0; /* undefined */ buf->f_ffree = 0; /* unlimited */ --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -333,6 +333,8 @@ smb3_qfs_tcon(const unsigned int xid, st SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid, FS_DEVICE_INFORMATION); SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid, + FS_VOLUME_INFORMATION); + SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid, FS_SECTOR_SIZE_INFORMATION); /* SMB3 specific */ SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid); return; --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -3455,6 +3455,9 @@ SMB2_QFS_attr(const unsigned int xid, st } else if (level == FS_SECTOR_SIZE_INFORMATION) { max_len = sizeof(struct smb3_fs_ss_info); min_len = sizeof(struct smb3_fs_ss_info); + } else if (level == FS_VOLUME_INFORMATION) { + max_len = sizeof(struct smb3_fs_vol_info) + MAX_VOL_LABEL_LEN; + min_len = sizeof(struct smb3_fs_vol_info); } else { cifs_dbg(FYI, "Invalid qfsinfo level %d\n", level); return -EINVAL; @@ -3495,6 +3498,11 @@ SMB2_QFS_attr(const unsigned int xid, st tcon->ss_flags = le32_to_cpu(ss_info->Flags); tcon->perf_sector_size = le32_to_cpu(ss_info->PhysicalBytesPerSectorForPerf); + } else if (level == FS_VOLUME_INFORMATION) { + struct smb3_fs_vol_info *vol_info = (struct smb3_fs_vol_info *) + (offset + (char *)rsp); + tcon->vol_serial_number = vol_info->VolumeSerialNumber; + tcon->vol_create_time = vol_info->VolumeCreationTime; } qfsattr_exit: --- a/fs/cifs/smb2pdu.h +++ b/fs/cifs/smb2pdu.h @@ -1108,6 +1108,17 @@ struct smb3_fs_ss_info { __le32 ByteOffsetForPartitionAlignment; } __packed; +/* volume info struct - see MS-FSCC 2.5.9 */ +#define MAX_VOL_LABEL_LEN 32 +struct smb3_fs_vol_info { + __le64 VolumeCreationTime; + __u32 VolumeSerialNumber; + __le32 VolumeLabelLength; /* includes trailing null */ + __u8 SupportsObjects; /* True if eg like NTFS, supports objects */ + __u8 Reserved; + __u8 VolumeLabel[0]; /* variable len */ +} __packed; + /* partial list of QUERY INFO levels */ #define FILE_DIRECTORY_INFORMATION 1 #define FILE_FULL_DIRECTORY_INFORMATION 2