Bug 2127301

Summary: Permission denied calling SMBC_getatr when file not exists
Product: [Fedora] Fedora Reporter: Ví­ctor Daniel Martínez O. <vdanielmo>
Component: sambaAssignee: Pavel Filipensky <pfilipen>
Status: CLOSED ERRATA QA Contact: Denis Karpelevich <dkarpele>
Severity: high Docs Contact:
Priority: unspecified    
Version: 37CC: abokovoy, aboscatt, anoopcs, antonraves, asn, awilliam, gdeschner, iboukris, jarrpa, jstephen, lmohanty, madam, oholy, pfilipen, sbose, ssorce
Target Milestone: ---Keywords: Reopened, Triaged
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard: AcceptedFreezeException
Fixed In Version: samba-4.17.1-1.fc38 samba-4.17.1-1.fc37 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-10-24 17:50:50 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2009540    

Description Ví­ctor Daniel Martínez O. 2022-09-15 21:07:08 UTC
Description of problem:
Permission denied calling SMBC_getatr when file not exists

Version-Release number of selected component (if applicable):
$ rpm -qa gvfs-*
gvfs-client-1.50.2-2.fc37.x86_64
gvfs-afc-1.50.2-2.fc37.x86_64
gvfs-fuse-1.50.2-2.fc37.x86_64
gvfs-goa-1.50.2-2.fc37.x86_64
gvfs-afp-1.50.2-2.fc37.x86_64
gvfs-archive-1.50.2-2.fc37.x86_64
gvfs-gphoto2-1.50.2-2.fc37.x86_64
gvfs-mtp-1.50.2-2.fc37.x86_64
gvfs-smb-1.50.2-2.fc37.x86_64

$ rpm -qa gvfs-smb samba-* libsmbclient*
gvfs-smb-1.50.2-2.fc37.x86_64
samba-common-4.17.0-1.fc37.noarch
samba-client-libs-4.17.0-1.fc37.x86_64
samba-common-libs-4.17.0-1.fc37.x86_64
libsmbclient-4.17.0-1.fc37.x86_64
samba-client-4.17.0-1.fc37.x86_64

$ rpm -q glib2
glib2-2.73.3-3.fc37.x86_64

How reproducible:

Steps to Reproduce:

Working:

$ gio mount -u "smb://bar@SERVER/foo/"
$ gio mount "smb://bar@SERVER/foo/"
$ date | gio save /run/user/1000/gvfs/smb-share:server=SERVER\,share=foo\,user=bar/folder/test.txt
$ echo $?
0
$ cat /run/user/1000/gvfs/smb-share:server=SERVER\,share=foo\,user=bar/folder/test.txt
Thu Sep 15 03:49:57 PM -05 2022

Not working (Permission denied):

$ gio mount -u "smb://bar@SERVER/foo/"
$ gio mount "smb://bar@SERVER/foo/"
$ date | tee /run/user/1000/gvfs/smb-share\:server\=SERVER\,share\=foo\,user\=bar/folder/another-test.txt
tee: '/run/user/1000/gvfs/smb-share:server=192.168.44.1,share=backups,user=bar/folder/another-test.txt': Permission denied
Thu Sep 15 03:55:20 PM -05 2022
$ echo $?
1
$ date | tee /run/user/1000/gvfs/smb-share\:server\=SERVER\,share\=foo\,user\=bar/folder/test.txt (the file exists because it was created above with "gio save")
$ echo $?
0


Actual results:

$ date | gio save /run/user/1000/gvfs/smb-share:server=SERVER\,share=foo\,user=bar/folder/test.txt  (OK)

$ date | tee /run/user/1000/gvfs/smb-share\:server\=SERVER\,share\=foo\,user\=bar/folder/another-test.txt  (Fail: Permission denied)


Expected results:

$ date | tee /run/user/1000/gvfs/smb-share\:server\=SERVER\,share\=foo\,user\=bar/folder/another-test.txt  (OK)


Additional info:

Log messages in GVFS_SMB_DEBUG=10 GVFS_DEBUG=1 /usr/libexec/gvfsd --replace:

With "gio save":

smb: backend_dbus_handler org.gtk.vfs.Mount:QueryInfo (pid=4762)
smb: Queued new job 0x7f0b100068f0 (GVfsJobQueryInfo)
smbc_stat(smb://SERVER/foo/folder)
SMBC_getatr: sending qpathinfo
smb: backend_dbus_handler org.gtk.vfs.Mount:QueryInfo (pid=4762)
smb: Queued new job 0x7f0b10006d50 (GVfsJobQueryInfo)
smb: send_reply(0x7f0b100068f0), failed=0 ()
smbc_stat(smb://SERVER/foo/folder)
SMBC_getatr: sending qpathinfo
smb: send_reply(0x7f0b10006d50), failed=0 ()
smb: backend_dbus_handler org.gtk.vfs.Mount:QueryInfo (pid=4762)
smb: Queued new job 0x7f0b10006df0 (GVfsJobQueryInfo)
smbc_stat(smb://SERVER/foo)
SMBC_getatr: sending qpathinfo
smb: send_reply(0x7f0b10006df0), failed=0 ()
smb: backend_dbus_handler org.gtk.vfs.Mount:QueryInfo (pid=4762)
smb: Queued new job 0x7f0b10006c10 (GVfsJobQueryInfo)
smbc_stat(smb://SERVER/foo/folder)
SMBC_getatr: sending qpathinfo
smb: send_reply(0x7f0b10006c10), failed=0 ()
smb: backend_dbus_handler org.gtk.vfs.Mount:OpenForWriteFlags (pid=5003)
smb: Queued new job 0x7f0b08022190 (GVfsJobOpenForWrite)
map_open_params_to_ntcreate: fname = \folder\test.txt, deny_mode = 0x42, open_func = 0x10
map_open_params_to_ntcreate: file \folder\test.txt, access_mask = 0x12019f, share_mode = 0x3, create_disposition = 0x2, create_options = 0x40 private_flags = 0x0
smb: send_reply(0x7f0b08022190), failed=0 ()
smb: Added new job source 0x7f0b08044570 (GVfsWriteChannel)
smb: Queued new job 0x55aefce02eb0 (GVfsJobWrite)
smb: send_reply(0x55aefce02eb0), bytes=32, failed=0 ()
smb: Queued new job 0x55aefcdf5950 (GVfsJobCloseWrite)
smb: send_reply(0x55aefcdf5950), failed=0 ()


With "date | tee":
smb: backend_dbus_handler org.gtk.vfs.Mount:QueryInfo (pid=4762)
smb: Queued new job 0x7f0b10006cb0 (GVfsJobQueryInfo)
smbc_stat(smb://SERVER/foo/folder)
smb: backend_dbus_handler org.gtk.vfs.Mount:QueryInfo (pid=4762)
smb: Queued new job 0x7f0b10006b70 (GVfsJobQueryInfo)
SMBC_getatr: sending qpathinfo
smb: send_reply(0x7f0b10006cb0), failed=0 ()
smbc_stat(smb://SERVER/foo/folder)
SMBC_getatr: sending qpathinfo
smb: send_reply(0x7f0b10006b70), failed=0 ()
smb: backend_dbus_handler org.gtk.vfs.Mount:QueryInfo (pid=4762)
smb: Queued new job 0x7f0b10002400 (GVfsJobQueryInfo)
smbc_stat(smb://SERVER/foo/folder/another-test.txt)
SMBC_getatr: sending qpathinfo
map_errno_from_nt_status: 32 bit codes: code=c0000022
cli_status_to_errno: 0xc0000022 -> 13
smb: send_reply(0x7f0b10002400), failed=1 (Permission denied)

Comment 1 Ví­ctor Daniel Martínez O. 2022-09-16 14:20:04 UTC
Downgrading to samba-4.16.4-1.fc37 fix the issue.

Comment 2 Ví­ctor Daniel Martínez O. 2022-09-19 00:17:23 UTC
Apparently SMBC_getatr no longer uses errno but instead returns NTSTATUS:

https://github.com/samba-team/samba/commit/d4f8fdd69a1278d8473d541dc6b32014a369bcd0

Comment 3 Ví­ctor Daniel Martínez O. 2022-09-21 18:14:20 UTC
Reverting the previous commit fixes the bug:

I rebuilt the samba SRPM using a mock and added the patch to SPEC and everything works perfect:

https://koji.fedoraproject.org/koji/buildinfo?buildID=2062333

$ git format-patch -1 --stdout d4f8fdd69a1278d8473d541dc6b32014a369bcd0 > 0001-libsmb-Convert-SMBC_getatr-to-NTSTATUS.patch
0001-libsmb-Convert-SMBC_getatr-to-NTSTATUS.patch

https://koji.fedoraproject.org/koji/buildinfo?buildID=2062333

...
Patch100:       0001-libsmb-Convert-SMBC_getatr-to-NTSTATUS.patch
...
%prep
xzcat %{SOURCE0} | gpgv2 --quiet --keyring %{SOURCE2} %{SOURCE1} -
%autosetup -n samba-%{version}%{pre_release} -N
%autopatch -M 99
%patch100 -p1 -R
...

Comment 4 Andreas Schneider 2022-10-04 11:52:07 UTC
Could you log an upstream bug for this?

Comment 5 Ví­ctor Daniel Martínez O. 2022-10-07 17:35:33 UTC
Filed the bug in gvfs:
https://gitlab.gnome.org/GNOME/gvfs/-/issues/651

I think this other one is related:
https://gitlab.gnome.org/GNOME/gvfs/-/issues/649

Waiting for my samba bugzilla account to be created.

Comment 6 Ví­ctor Daniel Martínez O. 2022-10-09 00:46:24 UTC
Samba Bugzilla:
https://bugzilla.samba.org/show_bug.cgi?id=15195

Comment 7 Ví­ctor Daniel Martínez O. 2022-10-09 17:21:33 UTC
Fixed issue with Jeremy Allison's patch: https://bugzilla.samba.org/show_bug.cgi?id=15195#c2

Comment 8 Ví­ctor Daniel Martínez O. 2022-10-18 01:12:24 UTC
Merge request: https://gitlab.com/samba-team/samba/-/merge_requests/2756

Comment 9 Pavel Filipensky 2022-10-18 19:33:09 UTC
I am reviewing the MR  https://gitlab.com/samba-team/samba/-/merge_requests/2756 and will patch Fedora 37 once it is ready.

Comment 10 Fedora Update System 2022-10-19 15:37:22 UTC
FEDORA-2022-314a73e994 has been submitted as an update to Fedora 38. https://bodhi.fedoraproject.org/updates/FEDORA-2022-314a73e994

Comment 11 Fedora Update System 2022-10-19 15:41:26 UTC
FEDORA-2022-314a73e994 has been pushed to the Fedora 38 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 12 Fedora Update System 2022-10-19 20:19:38 UTC
FEDORA-2022-1b0ba70aca has been submitted as an update to Fedora 37. https://bodhi.fedoraproject.org/updates/FEDORA-2022-1b0ba70aca

Comment 13 Ben Cotton 2022-10-20 18:55:31 UTC
Reopening since the F37 update isn't in the stable repo. Proposing as a freeze exception.

Comment 14 Fedora Update System 2022-10-21 14:40:52 UTC
FEDORA-2022-1b0ba70aca has been pushed to the Fedora 37 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2022-1b0ba70aca`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2022-1b0ba70aca

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 15 Adam Williamson 2022-10-21 19:10:39 UTC
*** Bug 2131723 has been marked as a duplicate of this bug. ***

Comment 16 Adam Williamson 2022-10-21 19:12:23 UTC
+3 in https://pagure.io/fedora-qa/blocker-review/issue/984 , marking accepted FE.

Comment 17 Fedora Update System 2022-10-24 17:50:50 UTC
FEDORA-2022-1b0ba70aca has been pushed to the Fedora 37 stable repository.
If problem still persists, please make note of it in this bug report.