SMBv2+ does not show all files when mounting a windows share

Bug #1572132 reported by majo on 2016-04-19
38
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Linux
Unknown
Unknown
cifs-utils (Debian)
Confirmed
Unknown
linux (Ubuntu)
Medium
Unassigned

Bug Description

When using the SMBv2 Protocol to mount a top level windows share (such as C:\) not all files (or directories) are shown that exist on the server side. Exactly 2 files are always missing...

Steps to reproduce:
On a windows7 PC (or Server) e.g. C:\ must be published as Share (must be top level share - a subfolder like C:\data\ seems to work)

sudo mount -t cifs //SERVER/SHARE_NAME /mnt -o domain=DOMAIN_NAME,username=${USER},uid=1000,gid=1000,nounix,vers=2.0

As a result always 2 Files (or directories) are missing in the mounted directory of the ubuntu installation.

Seems to be a kernel bug (source tree: linux/fs/cifs).

The ubuntu versions I have checked:
Ubuntu 14.04LTS amd64
Ubuntu 15.10 amd64
Ubuntu 16.04 amd64

ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: ubuntu-release-upgrader-core 1:16.04.12
ProcVersionSignature: Ubuntu 4.4.0-18.34-generic 4.4.6
Uname: Linux 4.4.0-18-generic x86_64
ApportVersion: 2.20.1-0ubuntu2
Architecture: amd64
CrashDB: ubuntu
CurrentDesktop: KDE
Date: Tue Apr 19 14:50:02 2016
InstallationDate: Installed on 2016-04-19 (0 days ago)
InstallationMedia: Kubuntu 16.04 LTS "Xenial Xerus" - Release amd64 (20160417.1)
PackageArchitecture: all
SourcePackage: ubuntu-release-upgrader
Symptom: ubuntu-release-upgrader
UpgradeStatus: No upgrade log present (probably fresh install)

majo (majo-huber) wrote :
affects: ubuntu-release-upgrader (Ubuntu) → samba (Ubuntu)

Hi,
reproducing is hard as most that come by the bug don't have a win machine around most of the time.
But this seems to me a bit like:
https://bugs.launchpad.net/ubuntu/karmic/+source/linux/+bug/406466

Could you try to test with the noserverino mount option if it would fix your issue?
so something like:
//1.1.1.1/share/ /mnt/mountpoint smbfs noserverino,nolinux,rw,user=MrBen,pass=ShopKeeper,dirmode=0777,filemode=0777 0 0

Uwe Honermann (u-honermann) wrote :

Hi,

I tried it with noserverino, no difference.

Exact Mount command used was:

sudo mount -t cifs //SERVER/SHARE_NAME /mnt -o domain=DOMAIN_NAME,username=USER_NAME,uid=1000,gid=1000,noserverino,nounix,vers=2.0

It looks like the problem has to do with the fact, that the directories . and .. do not exist in a Windows root Folder.

Nish Aravamudan (nacc) wrote :

This seems like a sort of known issue (unclear still). Cursory grepping in fs/cifs:

readdir.c::find_cifs_entry

        /*
         * If first entry in buf is zero then is first buffer
         * in search response data which means it is likely . and ..
         * will be in this buffer, although some servers do not return
         * . and .. for the root of a drive and for those we need
         * to start two entries earlier.
         */

It might be helpful to enable some more cifs debugging by booting with

dyndbg="file fs/cifs/readdir.c +p"

appended to the kernel commandline?

Also, is there a reason you are passing 'nounix' specifically? It seems like an uncommon option to need.

Uwe Honermann (u-honermann) wrote :

I know, we had some other Problems without the "nounix", but can't really remember.

I tried without it, doesn't make any difference.

I'll try with additional debugging, but I'll have to find out, how this works, since I'm not very familiar with Linux.

Uwe Honermann (u-honermann) wrote :

As I understand it, I would have to build a new kernel, to do this.

Unfortunately, I don't think, I can do that, since I don't have any idea, how this works.

majo (majo-huber) wrote :

Hi@all,

I activated the dynamic debugging for readdir.c as Nish Aravamudan suggested.
However this does not produce any output in the kernel log since (as I understand) most of the debug logging (cifs_dbg) is of type FYI which must be activated seperately in the code by setting cifsFYI (in fs/cifs/cifsfs.c) to CIFS_INFO. I think to do so, I have to recompile the kernel as Uwe Honermann suggested.
Doing so, will that help anybody here?
As a reminder: The problem only persists for the smb2 protocol, so removing the mounting option vers=2.0 fixes the issue. This is not an option for me, since I need that protocol version.

Thanks in advance.

Andreas Hasenack (ahasenack) wrote :

Curious indeed. I can reproduce this on xenial mounting a share from a windows 7 enterprise VM:

With vers 2.1 (same with 2.0):
root@nsn7:~# l /c
total 3,0G
drwxr-xr-x 2 andreas andreas 4,0K Jun 12 16:58 .
drwxr-xr-x 33 root root 4,0K Jun 27 15:56 ..
-rwxr-xr-x 1 andreas andreas 24 Jun 10 2009 autoexec.bat
-rwxr-xr-x 1 andreas andreas 10 Jun 10 2009 config.sys
drwxr-xr-x 2 andreas andreas 4,0K Out 23 2013 Documents and Settings
-rwxr-xr-x 1 andreas andreas 3,0G Jun 27 15:45 pagefile.sys
drwxr-xr-x 2 andreas andreas 0 Jul 13 2009 PerfLogs
drwxr-xr-x 2 andreas andreas 0 Jun 12 16:10 ProgramData
dr-xr-xr-x 2 andreas andreas 0 Jun 12 21:05 Program Files
drwxr-xr-x 2 andreas andreas 0 Out 23 2013 Recovery
drwxr-xr-x 2 andreas andreas 0 Nov 26 2014 System Volume Information
dr-xr-xr-x 2 andreas andreas 0 Out 23 2013 Users
drwxr-xr-x 2 andreas andreas 0 Out 23 2013 Wallpaper
drwxr-xr-x 2 andreas andreas 0 Jun 12 16:53 Windows
root@nsn7:~# mount|grep cifs
//10.0.7.128/c on /c type cifs (rw,relatime,vers=2.1,sec=ntlmssp,cache=strict,username=IEUser,domain=WORKGROUP,uid=1000,forceuid,gid=1000,forcegid,addr=10.0.7.128,file_mode=0755,dir_mode=0755,nounix,mapposix,rsize=1048576,wsize=1048576,actimeo=1)

Without the vers= parameter we get two extra directories: "Arquivos de Programas RFB" and "$Recycle.Bin":
root@nsn7:~# l /c
total 3,0G
drwxr-xr-x 2 andreas andreas 4,0K Jun 12 16:58 .
drwxr-xr-x 33 root root 4,0K Jun 27 15:56 ..
drwxr-xr-x 2 andreas andreas 0 Jun 12 20:52 Arquivos de Programas RFB
-rwxr-xr-x 1 andreas andreas 24 Jun 10 2009 autoexec.bat
-rwxr-xr-x 1 andreas andreas 10 Jun 10 2009 config.sys
drwxr-xr-x 2 andreas andreas 0 Jul 14 2009 Documents and Settings
-rwxr-xr-x 1 andreas andreas 3,0G Jun 27 15:45 pagefile.sys
drwxr-xr-x 2 andreas andreas 0 Jul 13 2009 PerfLogs
drwxr-xr-x 2 andreas andreas 0 Jun 12 16:10 ProgramData
dr-xr-xr-x 2 andreas andreas 0 Jun 12 21:05 Program Files
drwxr-xr-x 2 andreas andreas 0 Out 23 2013 Recovery
drwxr-xr-x 2 andreas andreas 0 Out 23 2013 $Recycle.Bin
drwxr-xr-x 2 andreas andreas 0 Nov 26 2014 System Volume Information
dr-xr-xr-x 2 andreas andreas 0 Out 23 2013 Users
drwxr-xr-x 2 andreas andreas 0 Out 23 2013 Wallpaper
drwxr-xr-x 2 andreas andreas 0 Jun 12 16:53 Windows
# mount|grep cifs
//10.0.7.128/c on /c type cifs (rw,relatime,vers=1.0,cache=strict,username=IEUser,domain=WORKGROUP,uid=1000,forceuid,gid=1000,forcegid,addr=10.0.7.128,file_mode=0755,dir_mode=0755,nounix,serverino,mapposix,rsize=61440,wsize=65536,actimeo=1)

Changed in samba (Ubuntu):
status: New → Confirmed
Andreas Hasenack (ahasenack) wrote :

And the moment I created another entry on C:\, one of the missing directories showed up on the linux side :)

Andreas Hasenack (ahasenack) wrote :

smbclient sees all files without issues, so I'm changing the affected package

affects: samba (Ubuntu) → cifs-utils (Ubuntu)
Andreas Hasenack (ahasenack) wrote :

Check some debug options that can be enabled on-the-fly, taken from bug https://bugs.launchpad.net/ubuntu/karmic/+source/linux/+bug/406466/comments/8.

In particular:

echo 1 > /proc/fs/cifs/traceSMB

showed that the missing files/directories are sent to the client when "ls -l /mountpoint" is issued.

affects: cifs-utils (Ubuntu) → linux (Ubuntu)
Joseph Salisbury (jsalisbury) wrote :

Would it be possible for you to test the latest upstream kernel? Refer to https://wiki.ubuntu.com/KernelMainlineBuilds . Please test the latest v4.12 kernel[0].

If this bug is fixed in the mainline kernel, please add the following tag 'kernel-fixed-upstream'.

If the mainline kernel does not fix this bug, please add the tag: 'kernel-bug-exists-upstream'.

Once testing of the upstream kernel is complete, please mark this bug as "Confirmed".

Thanks in advance.

[0] http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.12

Changed in linux (Ubuntu):
importance: Undecided → Medium
status: Confirmed → Incomplete
tags: added: kernel-da-key
Uwe Honermann (u-honermann) wrote :

I'm not a real Linux expert, but I'll do my very best.

Uwe Honermann (u-honermann) wrote :

I checked it with the 4.12.0 kernel, Problem still exists.
I also verified the correct kernel version with uname -r.

I added the tag kernel-bug-exists-upstream.

tags: added: kernel-bug-exists-upstream
Launchpad Janitor (janitor) wrote :

[Expired for linux (Ubuntu) because there has been no activity for 60 days.]

Changed in linux (Ubuntu):
status: Incomplete → Expired
Andreas Hasenack (ahasenack) wrote :

This should have been moved back to "confirmed" before the expiration, fixing that now.

Changed in linux (Ubuntu):
status: Expired → Confirmed
Javiar C (jchamp) wrote :

I'm also experiencing this bug on Ubuntu 16.04.3.
I don't think Windows supports SMB 1.0 any longer due to security issues. (mount error(121): Remote I/O error)
Adding vers=2.0 or 2.1 to the mount command line options successfully mounts the share, but using rsync to back up this Windows share is not reliable if it is missing 2 files.

Andreas Hasenack (ahasenack) wrote :

@jchamp what's your kernel version?

Andreas Hasenack (ahasenack) wrote :

I filed a bug in bugzilla.samba.org in the CifsVFS "project", but I'm not 100% it's the right place. I don't know if they are upstream of the cifs code in the kernel, or if that's some old implementation that is no longer used.

Javiar C (jchamp) wrote :

@ahasenack 4.10.0-35-generic (buildd@lcy01-33) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) ) #39~16.04.1-Ubuntu SMP Wed Sep 13 09:02:42 UTC 2017 (Ubuntu 4.10.0-35.39~16.04.1-generic 4.10.17)

In my case the files do not appear only on directory listing. I can, however, do touch, edit, rm and other file operations, and they work fine.

Gerald Hopf (o-ubuntu-y) wrote :

Same problem here with uBuntu 16.04 using Kernel "4.13.0-37-generic #42~16.04.1-Ubuntu SMP Mar 7 x86_64".

A mounted share called "D" from a Windows 10 (1709) computer has at least one important directory just missing when mounted. I can enter the non-existing directory manually though by cd "directoryName" and then once inside see its contents (unsure if this listig is complete though).

This is a major bug.

Andreas Hasenack (ahasenack) wrote :

I'm seeing files (ok, one file) disappear from a share when it's mounted with vers=3.0. But it's not a top-level share, it's just "c:\Shares\jsmith" on a windows 2016 server: https://bugs.launchpad.net/ubuntu/+source/sssd/+bug/1764778/comments/15

Walter Cheuk (wwycheuk) wrote :

Same problem happened to Ubuntu 16.04.5. I have to specify "vers=1.0" to mount a NAS drive successfully. The help said the default version is 1.0, so I spent a lot of time to check other options. Anyone please update the help text.

Do you get a notice in dmesg when you don't specify the version at mount
time?

On Fri, Apr 27, 2018, 03:05 Walter Cheuk <email address hidden> wrote:

> Same problem happened to Ubuntu 16.04.5. I have to specify "vers=1.0" to
> mount a NAS drive successfully. The help said the default version is
> 1.0, so I spent a lot of time to check other options. Anyone please
> update the help text.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1572132
>
> Title:
> SMB driver (SMBv2) does not show all files when mounting a windows top
> level share
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/linux/+bug/1572132/+subscriptions
>

Hi all,

Experiencing the same issue under debian stable (kernel 4.9.88-1). I opened a bugreport a few months ago with some network captures. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=871779

The funny thing is you can enter or list the "hidden" folder if your force the path.

Kaito (kto-2) wrote :

> The funny thing is you can enter or list the "hidden" folder if your force the path.

The bug has been confirmed and there are explanations and patches but the maintainers don't seem ready to apply it which is unfortunate as it is a very nefarious bug (Windows 10 doesn't support SMB1.0 by default). If you aren't aware of this bug you could mistakenly think all files of a share are being backed up when they aren't.

https://bugzilla.samba.org/show_bug.cgi?id=13107

https://www.spinics.net/lists/linux-cifs/msg14170.html

Explanation of bug:
https://www.spinics.net/lists/linux-cifs/msg14405.html

Unfortunately I'm not sure how to apply the patches and recompile just the cifs module.

summary: - SMB driver (SMBv2) does not show all files when mounting a windows top
- level share
+ SMBv2+ does not show all files when mounting a windows share
Changed in cifs-utils (Debian):
status: Unknown → Confirmed
Thibault (darxmurf) wrote :

Hi all,

Still no news about a fix for this issue ?
I tried with version 2:6.8-2 and the problem persists :-/

Cheers,

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.