Bug 15453 - File doesn't show when user doesn't have permission if aio_pthread is loaded
Summary: File doesn't show when user doesn't have permission if aio_pthread is loaded
Status: RESOLVED FIXED
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: VFS Modules (show other bugs)
Version: 4.15.13
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Jule Anger
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-08-15 08:50 UTC by Mike Liu
Modified: 2023-09-27 08:16 UTC (History)
1 user (show)

See Also:


Attachments
git-am fix for 4.19.next, 4.18.next. 4.17.next (2.12 KB, patch)
2023-08-24 17:03 UTC, Jeremy Allison
metze: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Liu 2023-08-15 08:50:27 UTC
Samba version 4.15.13

[share1]$ mkdir folder ; chmod 700 folder
[share1]$ ls -al .
total 16
drwxrwxrwx  4 admin administrators 4096 2023-08-15 16:12 ./
drwxrwxrwx 41 admin administrators 4096 2023-08-15 16:12 ../
drwx------  2 mike  everyone       4096 2023-08-15 16:12 folder/

---

If aio_pthread is loaded, folder(or file) doesn't show when user doesn't have permission 

[global]
vfs objects = aio_pthread

$ smbclient //localhost/share1 -U aaa -c 'ls'
  .                                   D        0  Tue Aug 15 16:12:49 2023
  ..                                  D        0  Tue Aug 15 16:12:01 2023

If aio_pthread is not loaded, folder is shown.

[global]
vfs objects = 

$ smbclient //localhost/share1 -U aaa -c 'ls'
  .                                   D        0  Tue Aug 15 16:12:49 2023
  ..                                  D        0  Tue Aug 15 16:12:01 2023
  folder                              D        0  Tue Aug 15 16:12:49 2023
  
  
strace can show the difference:
* aio_pthread is not loaded
openat(45, "second", O_RDONLY|O_DIRECTORY |O_PATH ) = 15
* aio_pthread is loaded
openat(15, "second", O_RDONLY|O_DIRECTORY) = -1 EACCES (Permission denied)

---

After commit cf3c48cb08811e45b6d88a4c27b873485321beb0
vfswrap_openat() support O_PATH (pathref) but aio_pthread_openat_fn not.
Should we use SMB_VFS_NEXT_OPENAT if aio_allow_open = false ?

static int aio_pthread_openat_fn(vfs_handle_struct *handle,
				 const struct files_struct *dirfsp,
				 const struct smb_filename *smb_fname,
				 struct files_struct *fsp,
				 int flags,
				 mode_t mode)
{
        /* ... */

	if (!aio_allow_open) {
		/* aio opens turned off. */
		- return openat(fsp_get_pathref_fd(dirfsp),
		-	      smb_fname->base_name,
		-	      flags,
		-	      mode);
		+ return SMB_VFS_NEXT_OPENAT(handle,
		+			   dirfsp,
		+			   smb_fname,
		+			   fsp,
		+			   flags,
		+			   mode);
	}

        /* ... */
}
Comment 1 Jeremy Allison 2023-08-15 19:58:40 UTC
Yes, inside aio_pthread_openat_fn() it's safe to call SMB_VFS_NEXT_OPENAT() for all the existing openat() calls.

Obviously not for the openat() inside aio_open_do() of course.
Comment 4 Samba QA Contact 2023-08-22 17:44:04 UTC
This bug was referenced in samba master:

81226b5179e6ba806a0a690806ca2f9004f7c9f9
Comment 5 Jeremy Allison 2023-08-24 17:03:27 UTC
Created attachment 18067 [details]
git-am fix for 4.19.next, 4.18.next. 4.17.next

Cherry-picked from master. Applies cleanly to all branches.
Comment 6 Jule Anger 2023-09-04 07:40:00 UTC
Pushed to autobuild-v4-{19,18,17}-test.
Comment 7 Samba QA Contact 2023-09-04 09:36:08 UTC
This bug was referenced in samba v4-17-test:

1361e545452faca0d2f85d4a82aa06535c129d76
Comment 8 Samba QA Contact 2023-09-04 09:50:04 UTC
This bug was referenced in samba v4-18-test:

14380eb832dff7f6c9e80206f2035bfb4a8e1a6b
Comment 9 Samba QA Contact 2023-09-04 10:18:05 UTC
This bug was referenced in samba v4-19-test:

8a34b378932930825f4c189d2f0bcacb682ff816
Comment 10 Jule Anger 2023-09-04 10:44:56 UTC
Closing out bug report.

Thanks!
Comment 11 Samba QA Contact 2023-09-04 12:56:19 UTC
This bug was referenced in samba v4-19-stable (Release samba-4.19.0):

8a34b378932930825f4c189d2f0bcacb682ff816
Comment 12 Samba QA Contact 2023-09-07 09:04:07 UTC
This bug was referenced in samba v4-17-stable (Release samba-4.17.11):

1361e545452faca0d2f85d4a82aa06535c129d76
Comment 13 Samba QA Contact 2023-09-27 08:16:03 UTC
This bug was referenced in samba v4-18-stable (Release samba-4.18.7):

14380eb832dff7f6c9e80206f2035bfb4a8e1a6b