The Samba-Bugzilla – Attachment 8829 Details for
Bug 9778
Samba directory code uses dirfd() without vectoring through a VFS call.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
git-am fix for 4.0.next that went into master.
bug-9778-4.0.next.patchset (text/plain), 6.61 KB, created by
Jeremy Allison
on 2013-04-29 20:55:51 UTC
(
hide
)
Description:
git-am fix for 4.0.next that went into master.
Filename:
MIME Type:
Creator:
Jeremy Allison
Created:
2013-04-29 20:55:51 UTC
Size:
6.61 KB
patch
obsolete
>From a6c491a18350ab531dadfa998d669ccd14d0b7f8 Mon Sep 17 00:00:00 2001 >From: Jeremy Allison <jra@samba.org> >Date: Wed, 10 Apr 2013 16:21:39 -0700 >Subject: [PATCH 1/5] Maintain a back-pointer to the fsp in struct smb_Dir when > opening with FDOPENDIR. > >Signed-off-by: Jeremy Allison <jra@samba.org> >Reviewed-by: Andreas Schneider <asn@samba.org> >(cherry picked from commit e89ec641fc98ffd7f7193deb3728b0a284a093eb) >--- > source3/smbd/dir.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > >diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c >index a06fc5f..0dd75b1 100644 >--- a/source3/smbd/dir.c >+++ b/source3/smbd/dir.c >@@ -50,6 +50,8 @@ struct smb_Dir { > struct name_cache_entry *name_cache; > unsigned int name_cache_index; > unsigned int file_number; >+ files_struct *fsp; /* Back pointer to containing fsp, only >+ set from OpenDir_fsp(). */ > }; > > struct dptr_struct { >@@ -1537,7 +1539,9 @@ static struct smb_Dir *OpenDir_fsp(TALLOC_CTX *mem_ctx, connection_struct *conn, > > if (fsp->is_directory && fsp->fh->fd != -1) { > dirp->dir = SMB_VFS_FDOPENDIR(fsp, mask, attr); >- if (dirp->dir == NULL) { >+ if (dirp->dir != NULL) { >+ dirp->fsp = fsp; >+ } else { > DEBUG(10,("OpenDir_fsp: SMB_VFS_FDOPENDIR on %s returned " > "NULL (%s)\n", > dirp->dir_path, >-- >1.8.2.1 > > >From b5ddd6d24c0dfd9695b2fcf37a4e5e9b0b3bf2ae Mon Sep 17 00:00:00 2001 >From: Jeremy Allison <jra@samba.org> >Date: Wed, 10 Apr 2013 16:24:15 -0700 >Subject: [PATCH 2/5] In the struct smb_Dir destructor, use the fsp back > pointer to release resources. > >Removes one use of dirfd(). > >Signed-off-by: Jeremy Allison <jra@samba.org> >Reviewed-by: Andreas Schneider <asn@samba.org> >(cherry picked from commit ea14c9443178da9ae6ccbe71e573156396f6f699) >--- > source3/smbd/dir.c | 23 +++++++++++++---------- > 1 file changed, 13 insertions(+), 10 deletions(-) > >diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c >index 0dd75b1..ad6826c 100644 >--- a/source3/smbd/dir.c >+++ b/source3/smbd/dir.c >@@ -1444,18 +1444,21 @@ bool is_visible_file(connection_struct *conn, const char *dir_path, > > static int smb_Dir_destructor(struct smb_Dir *dirp) > { >- if (dirp->dir) { >-#ifdef HAVE_DIRFD >- if (dirp->conn->sconn) { >- files_struct *fsp = file_find_fd(dirp->conn->sconn, >- dirfd(dirp->dir)); >- if (fsp) { >- /* The call below closes the underlying fd. */ >- fsp->fh->fd = -1; >+ if (dirp->dir != NULL) { >+ SMB_VFS_CLOSEDIR(dirp->conn,dirp->dir); >+ if (dirp->fsp != NULL) { >+ /* >+ * The SMB_VFS_CLOSEDIR above >+ * closes the underlying fd inside >+ * dirp->fsp. >+ */ >+ dirp->fsp->fh->fd = -1; >+ if (dirp->fsp->dptr != NULL) { >+ SMB_ASSERT(dirp->fsp->dptr->dir_hnd == dirp); >+ dirp->fsp->dptr->dir_hnd = NULL; > } >+ dirp->fsp = NULL; > } >-#endif >- SMB_VFS_CLOSEDIR(dirp->conn,dirp->dir); > } > if (dirp->conn->sconn && !dirp->conn->sconn->using_smb2) { > dirp->conn->sconn->searches.dirhandles_open--; >-- >1.8.2.1 > > >From cd30f1a8c5e6fb6f6ad5c72cddebde04dae37ec3 Mon Sep 17 00:00:00 2001 >From: Jeremy Allison <jra@samba.org> >Date: Wed, 10 Apr 2013 16:29:03 -0700 >Subject: [PATCH 3/5] Remove the "Ugly hack" that was the second use of > dirfd(). > >The destructor does all the resource deallocation needed. > >Signed-off-by: Jeremy Allison <jra@samba.org> >Reviewed-by: Andreas Schneider <asn@samba.org> >(cherry picked from commit 0fe894fb89f4867e266bb04670a58101311e0234) >--- > source3/smbd/dir.c | 18 +++++------------- > 1 file changed, 5 insertions(+), 13 deletions(-) > >diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c >index ad6826c..63f0227 100644 >--- a/source3/smbd/dir.c >+++ b/source3/smbd/dir.c >@@ -677,20 +677,12 @@ done: > void dptr_CloseDir(files_struct *fsp) > { > if (fsp->dptr) { >-/* >- * Ugly hack. We have defined fdopendir to return ENOSYS if dirfd also isn't >- * present. I hate Solaris. JRA. >- */ >-#ifdef HAVE_DIRFD >- if (fsp->fh->fd != -1 && >- fsp->dptr->dir_hnd && >- dirfd(fsp->dptr->dir_hnd->dir)) { >- /* The call below closes the underlying fd. */ >- fsp->fh->fd = -1; >- } >-#endif >+ /* >+ * The destructor for the struct smb_Dir >+ * (fsp->dptr->dir_hnd) now handles >+ * all resource deallocation. >+ */ > dptr_close_internal(fsp->dptr); >- fsp->dptr = NULL; > } > } > >-- >1.8.2.1 > > >From 23e2bd1df762901d981cff7212c70cf82f840a6f Mon Sep 17 00:00:00 2001 >From: Jeremy Allison <jra@samba.org> >Date: Wed, 10 Apr 2013 16:30:10 -0700 >Subject: [PATCH 4/5] Remove dependency on detection of HAVE_DIRFD for use of > fdopendir(). > >Signed-off-by: Jeremy Allison <jra@samba.org> >Reviewed-by: Andreas Schneider <asn@samba.org> > >Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> >Autobuild-Date(master): Fri Apr 12 16:21:10 CEST 2013 on sn-devel-104 >(cherry picked from commit 7a4dd845958f1411daa8031ca242987001ab2f26) >--- > source3/lib/system.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > >diff --git a/source3/lib/system.c b/source3/lib/system.c >index d69f1c6..8dbf7dc 100644 >--- a/source3/lib/system.c >+++ b/source3/lib/system.c >@@ -634,13 +634,11 @@ void kernel_flock(int fd, uint32 share_mode, uint32 access_mask) > > /******************************************************************* > An fdopendir wrapper. >- Ugly hack - we need dirfd for this to work correctly in the >- calling code.. JRA. > ********************************************************************/ > > DIR *sys_fdopendir(int fd) > { >-#if defined(HAVE_FDOPENDIR) && defined(HAVE_DIRFD) >+#if defined(HAVE_FDOPENDIR) > return fdopendir(fd); > #else > errno = ENOSYS; >-- >1.8.2.1 > > >From b85a90e88f8fc207368034240bd2925061335898 Mon Sep 17 00:00:00 2001 >From: Jeremy Allison <jra@samba.org> >Date: Fri, 26 Apr 2013 10:47:41 -0700 >Subject: [PATCH 5/5] Fix bug #9822 - Samba crashing during Win8 sync. > >When refactoring the dptr desctructor in the >fix for bug: > >9778 (Samba directory code uses dirfd() without vectoring through a VFS call) > >I removed the code to NULL out the struct smb_Dir * >pointer inside the fsp struct by mistake. > >Re-add the NULLing out of that pointer when >closing a directory pointer associated with >an open file. > >Reporter confirms it fixes the crash. > >Signed-off-by: Jeremy Allison <jra@samba.org> >Reviewed-by: David Disseldorp <ddiss@samba.org> > >Autobuild-User(master): David Disseldorp <ddiss@samba.org> >Autobuild-Date(master): Sat Apr 27 20:44:55 CEST 2013 on sn-devel-104 >(cherry picked from commit 251767cde9a146d8122d76e257ab232c05ad452a) >--- > source3/smbd/dir.c | 1 + > 1 file changed, 1 insertion(+) > >diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c >index 63f0227..52bd6a1 100644 >--- a/source3/smbd/dir.c >+++ b/source3/smbd/dir.c >@@ -683,6 +683,7 @@ void dptr_CloseDir(files_struct *fsp) > * all resource deallocation. > */ > dptr_close_internal(fsp->dptr); >+ fsp->dptr = NULL; > } > } > >-- >1.8.2.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
ddiss
:
review+
Actions:
View
Attachments on
bug 9778
:
8760
|
8762
|
8806
|
8822
| 8829 |
8942