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

Bug #1572132 reported by majo
68
This bug affects 10 people
Affects Status Importance Assigned to Milestone
Linux
Unknown
Unknown
Release Notes for Ubuntu
Fix Released
Undecided
Unassigned
linux (Debian)
Fix Released
Unknown
linux (Ubuntu)
Incomplete
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)

Revision history for this message
majo (majo-huber) wrote :
affects: ubuntu-release-upgrader (Ubuntu) → samba (Ubuntu)
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

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

Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
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
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

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

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

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

affects: samba (Ubuntu) → cifs-utils (Ubuntu)
Revision history for this message
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)
Revision history for this message
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
Revision history for this message
Uwe Honermann (u-honermann) wrote :

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

Revision history for this message
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
Revision history for this message
Launchpad Janitor (janitor) wrote :

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

Changed in linux (Ubuntu):
status: Incomplete → Expired
Revision history for this message
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
Revision history for this message
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.

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

@jchamp what's your kernel version?

Revision history for this message
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.

Revision history for this message
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)

Revision history for this message
Rostislav (rostislav-kouznetsov) wrote :

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.

Revision history for this message
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.

Revision history for this message
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

Revision history for this message
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.

Revision history for this message
Andreas Hasenack (ahasenack) wrote : Re: [Bug 1572132] Re: SMB driver (SMBv2) does not show all files when mounting a windows top level share

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
>

Revision history for this message
Thibault (darxmurf) wrote : Re: SMB driver (SMBv2) does not show all files when mounting a windows top level share

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.

Revision history for this message
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.

Mathew Hodson (mhodson)
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
Revision history for this message
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,

Revision history for this message
Disassembler (disassembler-k) wrote :

I have still the same problem even on Ubuntu 18.04.2 with cifs-utils 2:6.8-1 when mounting a drive from SMB hosts on both Win Server 2012 R2 and Win Server 2016.

With
echo 1 > /proc/fs/cifs/traceSMB
I see in kern.log that following directories are sent
 - $RECYCLE.BIN
 - <directory I need>
 - System Volume Information

But then only 'System Volume Information' is shown when listing the directory with ls -la

With vers=1.0 I can see the files, however SMBv1 is disabled and support for it removed on our company's production systems.

Revision history for this message
Benn (jammin84) wrote :

I wanted to leave a note that even though the directory is not listed you can still access it.

# ls -lah .
total 8.0K
drwxrwxrwx 2 root root 4.0K Dec 20 10:42 .
drwxr-xr-x 8 root root 4.0K Jan 30 13:45 ..
# ls Shares/
 Accounts Company Design IT

On top of this. I create a new folder and it then displays the missing folder, but now the new folder is missing.

# ls -la
total 8
drwxrwxrwx 2 root root 4096 Mar 14 15:42 .
drwxr-xr-x 8 root root 4096 Jan 30 13:45 ..
# mkdir New\ Folder
# ls -la
total 8
drwxrwxrwx 2 root root 4096 Mar 14 15:42 .
drwxr-xr-x 8 root root 4096 Jan 30 13:45 ..
drwxrwxrwx 2 root root 0 Mar 1 10:34 Shares

If i then remove "New Folder" then the "Shares" folder disappears again.

This to me kind of sounds like an issue with however this package is looping through the folder listing?

Mathew Hodson (mhodson)
affects: cifs-utils (Debian) → linux (Debian)
Revision history for this message
Felipe Aranda (felipemaranda) wrote :

This issue is gone to me after I updated the kernel to v4.19. I tried v5.1.9 first, but my WiFi stopped working, so I rolled back a bit. I'm running Linux Mint 19 that was on kernel 4.15.

A couple of folders were missing on a particular samba share mounted via fstab. I was able to access them by manually entering their paths.

Brad Figg (brad-figg)
tags: added: cscc
Mathew Hodson (mhodson)
Changed in ubuntu-release-notes:
status: New → Fix Released
Revision history for this message
volker mischo (volker-i) wrote :

same problem: ls -al 516.p* - > file or dir not found
 BUT ls -al 516.pdf ->then file is shown

Revision history for this message
volker mischo (volker-i) wrote :

bug is not fixed until today ! Not in Ubuntu 16.04 nor in Ubuntu 18.04.3 LTS (5.15.0-70-generic )

Revision history for this message
Gerald Hopf (o-ubuntu-y) wrote :

Why is this tagged as fixed when obviously it was never fixed?

Revision history for this message
Andreas Hasenack (ahasenack) wrote : Re: [Bug 1572132] Re: SMBv2+ does not show all files when mounting a windows share
Download full text (3.3 KiB)

It's just the release notes task of this bug that is marked as fixed,
meaning the release notes got an entry about this known problem.

On Wed, Jan 1, 2020, 15:34 Gerald Hopf <email address hidden> wrote:

> Why is this tagged as fixed when obviously it was never fixed?
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1572132
>
> Title:
> SMBv2+ does not show all files when mounting a windows share
>
> Status in Linux:
> Unknown
> Status in Release Notes for Ubuntu:
> Fix Released
> Status in linux package in Ubuntu:
> Confirmed
> Status in linux package in Debian:
> Confirmed
>
> 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)
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/linux/+bug/1572132/+subscriptions
>
> Launchpad-Notification-Type: bug
> Launchpad-Bug: product=linux; status=Unknown; importance=Unknown;
> assignee=None;
> Launchpad-Bug: product=ubuntu-release-notes; status=Fix Released;
> importance=Undecided; assignee=None;
> Launchpad-Bug: distribution=ubuntu; sourcepackage=linux; component=main;
> status=Confirmed; importance=Medium; assignee=None;
> Launchpad-Bug: distribution=debian; sourcepackage=linux; component=main;
> status=Confirmed; importance=Unknown; assignee=None;
> Launchpad-Bug-Tags: amd64 apport-bug cscc dist-upgrade
> kernel-bug-exists-upstream kernel-da-key xenial
> Launchpad-Bug-Information-Type: Public
> Launchpad-Bug-Private: no
> Launchpad-Bug-Security-Vulnerability: no
> Launchpad-Bug-Commenters: ahasenack darxmurf disassembler-k felipemaranda
> jammin84 janitor jchamp jsalisbury kto-2 majo-huber nacc o-ubuntu-y paelzer
> rostislav-kouznetsov u-honermann volker-i wwycheuk
> Launchpad-Bug-...

Read more...

Changed in linux (Debian):
status: Confirmed → Fix Released
Revision history for this message
Tristan Engel (tristan-engel) wrote :

When will this be fixed? Not fixed in 20.04

Revision history for this message
DooMMasteR (winrootkit-w) wrote :

And still not fixed in 21.10

Revision history for this message
Paride Legovini (paride) wrote :

Hi and thanks for the additional feedback. This bug has been forwarded to the Samba project [1], and marked as resolved by the patch [2], applied to the Linux kernel. The patch landed in Linux >= 4.19, that is in Ubuntu >= Focal (in linux-image-generic) and even in Bionic via linux-image-generic-hwe-18.04.

However there are reports here about this bug *not* being fixed in Focal and Impish (current devel release). In order to move this forward we need to double-check that we're actually speaking about the same bug. What I'd ask to >= Focal users affected by this bug is to setup the reproducer prepared by Andreas in [1] and double check if that's indeed what happens.

If the bug is still reproducible in >= Focal we may need to reopen the upstream bug. Otherwise, if the behavior is buggy but not *exactly* as described, let's open a new bug.

Waiting for feedback I'm marking this as Incomplete.

[1] https://bugzilla.samba.org/show_bug.cgi?id=13107
[1] https://github.com/torvalds/linux/commit/0595751f267994c3c7027377058e4185b3a28e75

Changed in linux (Ubuntu):
status: Confirmed → Incomplete
Revision history for this message
Tristan Engel (tristan-engel) wrote (last edit ):

I tried [1] and could not reproduce.

I guess most of it is not really a Bug, but missing Docs.
You have to add two Mount-Options so that it works and change a Gnome Setting.
(1) "nobrl"-Option
(2) "mfsymlinks"-Option
(3) service-db:keyfile/user in /etc/dconf/profile/user

https://help.gnome.org/admin/system-admin-guide/stable/dconf-nfs-home.html.en

To post a comment you must log in.
This report contains Public information  
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.