Bug 92401

Summary: Bug in character conversion (with and without cifs_mapchar enabled)
Product: File System Reporter: t.wede
Component: CIFSAssignee: fs_cifs (fs_cifs)
Status: NEEDINFO ---    
Severity: normal CC: alan, burnsmellfactory, lsahlber, shirishpargaonkar, smfrench, szg00000
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 3.18.x Subsystem:
Regression: Yes Bisected commit-id:
Attachments: cifs downgrade patch to versions of Kernel 3.17.8

Description t.wede 2015-01-31 09:28:54 UTC
Created attachment 165361 [details]
cifs downgrade patch to versions of Kernel 3.17.8

There is a bug in character conversations on clients using cifs.

Files or directories with :, *, ?, >, <, etc. in its name are shown corectly but the access to these files fails. The cifs client can create such files but it is not possible to remove or rename the files.

An access to such files shows an empty file in some circumstances.

My actual solution is to remove all conversion patches since Kernel 3.17.8.

The patch downgrades the cifs module to the state of Kernel 3.17.8 with only the necessary adaptations to work with Kernel 3.18.x.
Comment 1 Alan 2015-02-10 15:34:55 UTC
+smfrench@gmail.com
Comment 2 burnsmellfactory 2015-12-16 07:59:01 UTC
There is a related issue reported in the Samba Bugzilla:
https://bugzilla.samba.org/show_bug.cgi?id=11307
Comment 3 burnsmellfactory 2015-12-16 08:02:00 UTC
This bug is still present in kernel 4.1.12.
Comment 4 Shirish Pargaonkar 2015-12-28 04:07:10 UTC
Looking into this...
Comment 5 Ronnie Sahlberg 2019-02-07 04:16:22 UTC
This is fixed in the current kernel.

$ touch /mnt/foo\<\*\>\?
$ ls -l /mnt/foo\<\*\>\?
-rwxr-xr-x. 1 root root 0 Feb  7 15:15 '/mnt/foo<*>?'
$ echo "Hello World" > /mnt/foo\<\*\>\?
$ cat /mnt/foo\<\*\>\?
Hello World
$ rm /mnt/foo\<\*\>\?
Comment 6 burnsmellfactory 2019-02-07 04:33:46 UTC
(In reply to Ronnie Sahlberg from comment #5)
> This is fixed in the current kernel.
> 
> $ touch /mnt/foo\<\*\>\?
> $ ls -l /mnt/foo\<\*\>\?
> -rwxr-xr-x. 1 root root 0 Feb  7 15:15 '/mnt/foo<*>?'
> $ echo "Hello World" > /mnt/foo\<\*\>\?
> $ cat /mnt/foo\<\*\>\?
> Hello World
> $ rm /mnt/foo\<\*\>\?

Is /mnt/foo/ a CIFS mountpoint?
Comment 7 Ronnie Sahlberg 2019-02-07 04:59:58 UTC
/mnt is an smb mountpoint
foo/</*/>/? is a file in this share

$ mount | grep /mnt
//win16-1/Share on /mnt type cifs (rw,relatime,vers=3.0,cache=strict,username=sahlberg,uid=0,noforceuid,gid=0,noforcegid,addr=192.168.124.198,file_mode=0755,dir_mode=0755,soft,nounix,serverino,mapposix,mfsymlinks,noperm,rsize=4194304,wsize=4194304,echo_interval=60,actimeo=1)
Comment 8 Steve French 2019-02-07 09:55:48 UTC
This was resolved and enabled by default for SMB2/SMB3 mounts more than four years ago, but there was this patch which may be important for your use case which certainly should be in by 4.2 kernel.   Make sure your /proc/mounts mount entry for this cifs mount shows "mapposix"

commit bc8ebdc4f54cc944b0ecc0fb0d18b0ffbaab0468
Author: Nakajima Akira <nakajima.akira@nttcom.co.jp>
Date:   Fri Feb 13 15:35:58 2015 +0900

    Fix that several functions handle incorrect value of mapchars
    
    Cifs client has problem with reserved chars filename.
    
    [BUG1] : several functions handle incorrect value of mapchars
    -       cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
    +       cifs_remap(cifs_sb));
    
    [BUG2] : forget to convert reserved chars when creating SymbolicLink.
    -       CIFSUnixCreateSymLink() calls cifs_strtoUTF16
    +       CIFSUnixCreateSymLink() calls cifsConvertToUTF16() with remap
    
    [BUG3] : forget to convert reserved chars when getting SymbolicLink.
    -       CIFSSMBUnixQuerySymLink() calls cifs_strtoUTF16
    +       CIFSSMBUnixQuerySymLink() calls cifsConvertToUTF16() with remap
    
    [BUG4] : /proc/mounts don't show "mapposix" when using mapposix mount option
    +           cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SFM_CHR)
    +               seq_puts(s, ",mapposix");