Bug 8111 - CIFS VFS: unexpected error on SMB posix open
Summary: CIFS VFS: unexpected error on SMB posix open
Alias: None
Product: Samba 3.5
Classification: Unclassified
Component: File services (show other bugs)
Version: 3.5.8
Hardware: All All
: P5 normal
Target Milestone: ---
Assignee: Karolin Seeger
QA Contact: Samba QA Contact
Depends on:
Reported: 2011-04-29 17:01 UTC by Luc Lalonde
Modified: 2011-05-06 18:46 UTC (History)
0 users

See Also:

network cifs dump (35.18 KB, application/octet-stream)
2011-04-29 17:01 UTC, Luc Lalonde
no flags Details
patch -- handle SMB_O_TRUNC without O_CREAT correctly (1.08 KB, patch)
2011-04-29 19:47 UTC, Jeff Layton
no flags Details
git-am fix for 3.5.next (2.94 KB, patch)
2011-04-29 21:25 UTC, Jeremy Allison
jlayton: review+

Note You need to log in before you can comment on or make changes to this bug.
Description Luc Lalonde 2011-04-29 17:01:32 UTC
Created attachment 6431 [details]
network cifs dump

Description of problem:

I get this error while trying to mount home directory from Samba 3.5.8 server:

Apr 27 14:39:44 localhost kernel: [14858.888596] CIFS VFS: server
of type Samba 3.5.8 returned unexpected error on SMB posix open, disabling
posix open support. Check if server update available.

We use the 'pam_mount' package to mount Samba home directories.  It is working
in our labs with Fedora 13... However, now that this error disables 'SMB posix
open' we are unable to use Samba for home directories.

Here are our mount options (/etc/security/pam_mount.conf.xml):

<volume fstype="cifs" server="ada.info.polymtl.ca" user="*" path="%(USER)"
options="dir_mode=0700,file_mode=0600,serverino,nobrl" />

On the server side, 'unix extensions' are enabled.

Kernel version on the fedora-15-beta1 client:

A bug report was first published at RedHat:


I'm also including a dump of the network communications I sent them...
Comment 1 Jeff Layton 2011-04-29 19:17:14 UTC
This was originally opened as a kernel bug against Fedora, but it looks like a samba bug. I was able to reproduce this by opening a file with O_WRONLY|O_TRUNC. That's a valid combination of flags, that samba always returns an error on. From a smbd -d10 log:

call_trans2setfilepathinfo(6) testfile (fnum -1) info_level=521 totdata=18
smbd_do_setfilepathinfo: testfile (fnum -1) info_level=521 totdata=18
smb_posix_open: invalid create mode 0x40
error packet at smbd/error.c(160) cmd=50 (SMBtrans2)

The part of smb_posix_open that sets up the create_disp looks wrong, as it seems to throw an error as it seems to indicate that SMB_O_TRUNC without SMB_O_CREAT is invalid, when that really shouldn't be the case.
Comment 2 Jeremy Allison 2011-04-29 19:27:55 UTC
True. There's no way in the server POSIX open code to get to :


which is what is required for (O_TRUNC|O_WRONLY). I'll attach a patch asap.

Comment 3 Jeff Layton 2011-04-29 19:47:18 UTC
Created attachment 6432 [details]
patch -- handle SMB_O_TRUNC without O_CREAT correctly

Proposed patch. I believe this will fix the bug, but there may be a better way to do this and clean up this nasty if statement at the same time.
Comment 4 Jeremy Allison 2011-04-29 20:00:46 UTC
Yes there's a better way :-). Please wait until I've finished the fix.

The problem was we are conflating the O_CREAT|O_EXCL with the O_TRUNC processing, they need to be separate. We need to chose using (O_CREAT|O_EXCL) first, then modify if O_TRUNC is set. This needs 2 separate switch statements.

Comment 5 Jeremy Allison 2011-04-29 21:25:26 UTC
Created attachment 6433 [details]
git-am fix for 3.5.next

Jeff please test. I'm adding this to master with an additional test in the run_simple_posix_open_test() code.

Comment 6 Jeff Layton 2011-04-30 01:42:40 UTC
Comment on attachment 6433 [details]
git-am fix for 3.5.next

ACK. Patch seems to fix the reproducer.
Comment 7 Luc Lalonde 2011-05-02 18:36:23 UTC
Hello Jeff and Jeremy,

I can confirm that this error is fixed for me.   I recompiled samba-3.5.8 with the patch provided (git-am fix for 3.5.next) and no longer see the error message in my kernel logs.

However, I'm still seeing a problem when I use KDE-6.2 (Fedora 15 beta1 + testing updates).   When I use 'pam_mount' to automatically mount the user's home directory via CIFS I am not able to properly logout.  I have to key in 'CTRL-ALT-BACKSPACE' to close the active session.

I don't get this behaviour with a home that is local or via NFS with the above described client.  

I have a configuration working that uses Fedora 13 + KDE 4.5.5 + pam_mount on the client side.

I've already opened a ticket at RedHat thinking that the above CIFS-VFS bug was not related:


Should I wait to see what the Redhat developer says before going upstream on this Bugzilla?
Comment 8 Jeremy Allison 2011-05-02 23:49:38 UTC
Luc, that looks like a different issue. I'm going to re-assign this to Karolin so she can include the fix and get it into 3.5.next.

Comment 9 Karolin Seeger 2011-05-06 18:46:22 UTC
Pushed to v3-5-test.
Closing out bug report.

Please feel free to open a new bug report concerning the other issue.