Bug 90011

Summary: can not cd DIRECTORY, can not cat SymbolicLink, because of using old inode caches.
Product: File System Reporter: Nakajima Akira (nakajima.akira)
Component: CIFSAssignee: fs_cifs (fs_cifs)
Status: RESOLVED CODE_FIX    
Severity: normal CC: jlayton, smfrench, szg00000
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 3.18.0 Subsystem:
Regression: No Bisected commit-id:
Attachments: patch__if different file type, then return error

Description Nakajima Akira 2014-12-18 08:51:15 UTC
Created attachment 161141 [details]
patch__if different file type, then return error

//////////////////////////////////////////////////////////
Description of problem:
In spite of different file type,
 if file is same name and same inode number, then old inode cache is used.
This causes that you can not cd directory, can not cat SymbolicLink.
//////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////
Version-Release number of selected component (if applicable):
CIFS client: kernel-3.18.0
samba server: samba-4.1.12-5.rc20
//////////////////////////////////////////////////////////

How reproducible:
Steps to Reproduce:

1. start smb at samba server

server# setenforce 0
server# vi /etc/samba/smb.conf
[share]
path = /home/share
public = yes
writable = yes

server# smbpasswd -a XXX(username)
server# systemctl restart smb

2. mount cifs at CIFS client

client# mount -o user=XXX,serverino //server/share /mnt/share

3. create and list file at CIFS client

client# cd /mnt/share
client# touch a; ls -li
total 0
2400376 -rw-r--r--. 1 root root 0 Dec 18 09:37 a

4. remove file and create Directory at samba server
   (Maybe you need repeat rm and mkdir 4 times
    until same inode number directory is made.)

server# rm -rf a; mkdir a; ls -li
total 0
2400376 drwxr-xr-x. 2 root root 0 Dec 18 09:38 a

5. list at CIFS client

client# ls -li
total 0
2400376 drwxr-xr-x. 2 root root 0 Dec 18 09:38 a
client# cd a
bash: cd: a: Not a directory

6. cannot remove DIR at CIFS client

client# rm -rf a
clinet$ ls -li
total 0
2400376 drwxr-xr-x. 2 root root 0 Dec 18 09:38 a

<<Fedora20 when SELinux is Enforcing, can not remove DIR>>
client# getenforce
Enforcing
client# rm -rf a
rm: cannot remove 'a': Permission denied

=====================================================
This is patch.
001-cifs-fix-different-mode-return-error.patch

=====================================================
Comment 1 Jeff Layton 2014-12-18 12:40:19 UTC
Huh -- wonder why the inode number didn't change? Is it just the lower fs recycling inode numbers?

In any case, patch looks reasonable to me. You should go ahead and send it (along with a description of the problem) to linux-cifs@vger.kernel.org.
Comment 2 Nakajima Akira 2014-12-19 06:10:55 UTC
Thanks for review.

You repeat rm and mkdir 4 times at server, then server recycles same inode number.
Comment 3 Steve French 2015-01-20 02:59:11 UTC
Fix merged into cifs-2.6.git and mainline