Bug 90031 - can not cd DIRECTORY, can not cat SymbolicLink, when client refer file directly.
Summary: can not cd DIRECTORY, can not cat SymbolicLink, when client refer file directly.
Status: NEW
Alias: None
Product: File System
Classification: Unclassified
Component: CIFS (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: fs_cifs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-18 09:03 UTC by Nakajima Akira
Modified: 2014-12-19 04:28 UTC (History)
0 users

See Also:
Kernel Version: 3.18.0
Subsystem:
Regression: No
Bisected commit-id:


Attachments
patch__if different file type, then return error (1.06 KB, application/octet-stream)
2014-12-18 09:03 UTC, Nakajima Akira
Details
patch__if different file type, then overwrite inode cache (4.88 KB, patch)
2014-12-18 09:05 UTC, Nakajima Akira
Details | Diff

Description Nakajima Akira 2014-12-18 09:03:04 UTC
Created attachment 161161 [details]
patch__if different file type, then return error

//////////////////////////////////////////////////////////
Description of problem:
Old inode cache is used, when same filename and using ls -li <filename>.
This causes that client can not cd DIR, can not cat SymLink.

When server is Windows, client has same problem.
//////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////
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. create file share service 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:53 a

4. remove and create DIR as same name at samba server

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

5. list file "directly" at CIFS client

client# ls -li a
ls: cannot open directory a: Not a directory
client# cd a
bash: cd: a: Not a directory

////////////////////////
SymbolicLink

Do 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 10:01 a

6. create SymLink as same name at samba server

server# echo ok > b; rm -f a; ln -s b a; ls -li
total 4
2400376 lrwxrwxrwx. 1 root root 1 Dec 18 10:01 a -> b
2400377 -rw-r--r--. 1 root root 3 Dec 18 10:01 b

7. list file "directly" at CIFS client

client# ls -li a
ls: cannot read symbolic link a: Invalid argument
2400376 lrwxrwxrwx. 1 root root 1 Dec 18 10:01 a
client# cat a
cat: a: Too many levels of symbolic links

=====================================================
This is patch
003-cifs-fix-different-mode-return-error_WhenDirectRefer.patch

But this patch send same SMB request "Query File Unix Basic" again
 when file type(i_mode and cf_mode) is different.

=====================================================

You look similar problem at https://bugzilla.kernel.org/show_bug.cgi?id=90011
and
https://bugzilla.kernel.org/show_bug.cgi?id=90021
  but there need different patches.
Patching all 001 and 002 and 003 is better.
Comment 1 Nakajima Akira 2014-12-18 09:05:07 UTC
Created attachment 161171 [details]
patch__if different file type, then overwrite inode cache

To avoid sending same SMB request,
I tried to overwrite inode cache.
This is this way patch. (for UNIX)
004-cifs-fix-different-mode-overwrite-inodecache_WhenDirectRefer.patch


Before make modules, Maybe we need copy
security/selinux/flask.h and security/selinux/av_permissions.h
to
security/selinux/include/
Comment 2 Nakajima Akira 2014-12-19 04:25:11 UTC
I posted new patch (attachment 161301 [details]) to
https://bugzilla.kernel.org/show_bug.cgi?id=90021
With above patch, this problem is limited at the time of the
 "same inode number".


=====================================================
Reproducible sample:

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 19 11:53 a

4. remove and create DIR as same name, "same inode number" at samba server

(**Repeat rm and mkdir 4 times until same inode number is made**)
(When server is RHEL6.6 , always same inode number is made)

server# rm -rf a; mkdir a; ls -li
total 0
2400376 drwxr-xr-x. 2 root root 6 Dec 19 11:53 a

5. list file "directly" at CIFS client

client#  ls -li a
ls: cannot open directory a: Not a directory
=====================================================


But patch (attachment 161161 [details]) is effective.

Note You need to log in before you can comment on or make changes to this bug.