The Samba-Bugzilla – Attachment 16388 Details for
Bug 14596
vfs_fruit may close wrong backend fd
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for 4.12 backported from master
bug14596-v412.patch (text/plain), 9.55 KB, created by
Ralph Böhme
on 2021-01-11 11:24:34 UTC
(
hide
)
Description:
Patch for 4.12 backported from master
Filename:
MIME Type:
Creator:
Ralph Böhme
Created:
2021-01-11 11:24:34 UTC
Size:
9.55 KB
patch
obsolete
>From 322a8bad5a3d84c0f89c1bd7059c0fa136859ee2 Mon Sep 17 00:00:00 2001 >From: Stefan Metzmacher <metze@samba.org> >Date: Fri, 18 Dec 2020 14:03:09 +0100 >Subject: [PATCH 1/6] s3:smbd: add vfs_fake_fd_close() helper > >When we used vfs_fake_fd() we should use vfs_fake_fd_close() >in order to have things symetric. > >This makes code easier to understand and may allow us to change >vfs_fake_fd() internally if required. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=14596 > >Signed-off-by: Stefan Metzmacher <metze@samba.org> >Reviewed-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> >(back-ported from commit 8f057333466b2d9845cd8bc2b794d98252ade2a4) >--- > source3/smbd/proto.h | 2 ++ > source3/smbd/vfs.c | 9 +++++++++ > 2 files changed, 11 insertions(+) > >diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h >index ac021ad93fe1..2ea90405b477 100644 >--- a/source3/smbd/proto.h >+++ b/source3/smbd/proto.h >@@ -1281,6 +1281,8 @@ NTSTATUS vfs_streaminfo(connection_struct *conn, > unsigned int *num_streams, > struct stream_struct **streams); > void init_smb_file_time(struct smb_file_time *ft); >+int vfs_fake_fd(void); >+int vfs_fake_fd_close(int fd); > > /* The following definitions come from smbd/avahi_register.c */ > >diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c >index 411999c38561..740088628c58 100644 >--- a/source3/smbd/vfs.c >+++ b/source3/smbd/vfs.c >@@ -1579,6 +1579,15 @@ NTSTATUS vfs_streaminfo(connection_struct *conn, > streams); > } > >+/* >+ * This is just a helper to make >+ * users of vfs_fake_fd() more symetric >+ */ >+int vfs_fake_fd_close(int fd) >+{ >+ return close(fd); >+} >+ > /* > generate a file_id from a stat structure > */ >-- >2.26.2 > > >From 6ca10914ba962f17e4949afb8271643464345aae Mon Sep 17 00:00:00 2001 >From: Stefan Metzmacher <metze@samba.org> >Date: Fri, 18 Dec 2020 14:36:00 +0100 >Subject: [PATCH 2/6] vfs_fruit: make use of vfs_fake_fd_close() > >When we used vfs_fake_fd() we should use vfs_fake_fd_close() >in order to have things symetric. > >That may allows us to change vfs_fake_fd() internally if required. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=14596 > >Signed-off-by: Stefan Metzmacher <metze@samba.org> >Reviewed-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> >(back-ported from commit 719c83b4dc4cef16429ec2803621039545f6885e) >--- > source3/modules/vfs_fruit.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > >diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c >index b2d0901a8007..a376cc2f82d3 100644 >--- a/source3/modules/vfs_fruit.c >+++ b/source3/modules/vfs_fruit.c >@@ -1647,7 +1647,7 @@ static int fruit_close_meta(vfs_handle_struct *handle, > break; > > case FRUIT_META_NETATALK: >- ret = close(fsp->fh->fd); >+ ret = vfs_fake_fd_close(fsp->fh->fd); > fsp->fh->fd = -1; > break; > >@@ -1676,7 +1676,7 @@ static int fruit_close_rsrc(vfs_handle_struct *handle, > break; > > case FRUIT_RSRC_XATTR: >- ret = close(fsp->fh->fd); >+ ret = vfs_fake_fd_close(fsp->fh->fd); > fsp->fh->fd = -1; > break; > >-- >2.26.2 > > >From 9158971b2f718c1e47b89bea3b02ca08cb664003 Mon Sep 17 00:00:00 2001 >From: Stefan Metzmacher <metze@samba.org> >Date: Fri, 18 Dec 2020 14:36:00 +0100 >Subject: [PATCH 3/6] vfs_streams_xattr: make use of vfs_fake_fd_close() > >When we used vfs_fake_fd() we should use vfs_fake_fd_close() >in order to have things symetric. > >That may allows us to change vfs_fake_fd() internally if required. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=14596 > >Signed-off-by: Stefan Metzmacher <metze@samba.org> >Reviewed-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> >(back-ported from commit 40e70cbd3c3a1df9205a7b18d07784c1754cc340) >--- > source3/modules/vfs_streams_xattr.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > >diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c >index 85efe2bcc376..7d0617507e34 100644 >--- a/source3/modules/vfs_streams_xattr.c >+++ b/source3/modules/vfs_streams_xattr.c >@@ -490,7 +490,7 @@ static int streams_xattr_open(vfs_handle_struct *handle, > > fail: > if (fakefd >= 0) { >- close(fakefd); >+ vfs_fake_fd_close(fakefd); > fakefd = -1; > } > >@@ -512,7 +512,7 @@ static int streams_xattr_close(vfs_handle_struct *handle, > return SMB_VFS_NEXT_CLOSE(handle, fsp); > } > >- ret = close(fd); >+ ret = vfs_fake_fd_close(fd); > fsp->fh->fd = -1; > > return ret; >-- >2.26.2 > > >From 5e9905ba53567d0c700db96e70d65bbd4eafa43e Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Fri, 11 Dec 2020 13:00:09 +0100 >Subject: [PATCH 4/6] vfs_fruit: use "fake_fd" instead of "created" > >Both have basically the same semantics. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=14596 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Stefan Metzmacher <metze@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> >(back-ported from commit 36eb30fd7d4b82bffd0e1ab471c088f678d700a4) >--- > source3/modules/vfs_fruit.c | 11 +---------- > 1 file changed, 1 insertion(+), 10 deletions(-) > >diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c >index a376cc2f82d3..a61a7393adac 100644 >--- a/source3/modules/vfs_fruit.c >+++ b/source3/modules/vfs_fruit.c >@@ -178,9 +178,6 @@ struct fio { > /* Denote stream type, meta or rsrc */ > adouble_type_t type; > >- /* Whether the create created the stream */ >- bool created; >- > /* > * AFP_AfpInfo stream created, but not written yet, thus still a fake > * pipe fd. This is set to true in fruit_open_meta if there was no >@@ -2300,7 +2297,7 @@ static ssize_t fruit_pread_meta(vfs_handle_struct *handle, > return -1; > } > >- if (nread == -1 && fio->created) { >+ if (nread == -1 && fio->fake_fd) { > AfpInfo *ai = NULL; > char afpinfo_buf[AFP_INFO_SIZE]; > >@@ -3999,7 +3996,6 @@ static NTSTATUS fruit_create_file(vfs_handle_struct *handle, > NTSTATUS status; > struct fruit_config_data *config = NULL; > files_struct *fsp = NULL; >- struct fio *fio = NULL; > bool internal_open = (oplock_request & INTERNAL_OPEN_ONLY); > int ret; > >@@ -4072,11 +4068,6 @@ static NTSTATUS fruit_create_file(vfs_handle_struct *handle, > goto fail; > } > >- fio = (struct fio *)VFS_FETCH_FSP_EXTENSION(handle, fsp); >- if (fio != NULL && pinfo != NULL && *pinfo == FILE_WAS_CREATED) { >- fio->created = true; >- } >- > if (is_named_stream(smb_fname) > || fsp->is_directory) { > return status; >-- >2.26.2 > > >From 630d31b4925de95a1ed73502975ed91f99845416 Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Fri, 11 Dec 2020 13:00:56 +0100 >Subject: [PATCH 5/6] vfs_fruit: check fake_fd in fruit_pread_meta_stream() > >Don't call into the next VFS backend if we know we still have a fake-fd. Just >return -1 and the caller has the logic to handle this, which results in >returning a AFP_AfpInfo blob initialized with some defaults. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=14596 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Stefan Metzmacher <metze@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> >(back-ported from commit c5da08422990dfc1e082bc01aa10d6e415eebe3f) >--- > source3/modules/vfs_fruit.c | 5 +++++ > 1 file changed, 5 insertions(+) > >diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c >index a61a7393adac..5f0ac1d28b3b 100644 >--- a/source3/modules/vfs_fruit.c >+++ b/source3/modules/vfs_fruit.c >@@ -2186,9 +2186,14 @@ static ssize_t fruit_pread_meta_stream(vfs_handle_struct *handle, > files_struct *fsp, void *data, > size_t n, off_t offset) > { >+ struct fio *fio = (struct fio *)VFS_FETCH_FSP_EXTENSION(handle, fsp); > ssize_t nread; > int ret; > >+ if (fio->fake_fd) { >+ return -1; >+ } >+ > nread = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset); > if (nread == -1 || nread == n) { > return nread; >-- >2.26.2 > > >From 0e70c30a65f681fb39d337209f7e8b75c57ccb54 Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Fri, 11 Dec 2020 12:59:28 +0100 >Subject: [PATCH 6/6] vfs_fruit: fix close for fake_fd > >If the next backend doesn't use kernel fd's should not >pass a fake_fd to the next backend. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=14596 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Stefan Metzmacher <metze@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> > >Autobuild-User(master): Jeremy Allison <jra@samba.org> >Autobuild-Date(master): Fri Jan 8 21:38:18 UTC 2021 on sn-devel-184 > >(back-ported from commit 564b62a6f7c0a9b9712946d723118122b9c3785f) >--- > source3/modules/vfs_fruit.c | 14 ++++++++++---- > 1 file changed, 10 insertions(+), 4 deletions(-) > >diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c >index 5f0ac1d28b3b..a3b823fc6afb 100644 >--- a/source3/modules/vfs_fruit.c >+++ b/source3/modules/vfs_fruit.c >@@ -1632,6 +1632,7 @@ static int fruit_open(vfs_handle_struct *handle, > static int fruit_close_meta(vfs_handle_struct *handle, > files_struct *fsp) > { >+ struct fio *fio = (struct fio *)VFS_FETCH_FSP_EXTENSION(handle, fsp); > int ret; > struct fruit_config_data *config = NULL; > >@@ -1640,7 +1641,12 @@ static int fruit_close_meta(vfs_handle_struct *handle, > > switch (config->meta) { > case FRUIT_META_STREAM: >- ret = SMB_VFS_NEXT_CLOSE(handle, fsp); >+ if (fio->fake_fd) { >+ ret = vfs_fake_fd_close(fsp->fh->fd); >+ fsp->fh->fd = -1; >+ } else { >+ ret = SMB_VFS_NEXT_CLOSE(handle, fsp); >+ } > break; > > case FRUIT_META_NETATALK: >@@ -2529,13 +2535,13 @@ static ssize_t fruit_pwrite_meta_stream(vfs_handle_struct *handle, > } > > if (fio->fake_fd) { >- int fd; >+ int fd = fsp->fh->fd; > >- ret = SMB_VFS_NEXT_CLOSE(handle, fsp); >+ ret = vfs_fake_fd_close(fd); >+ fsp->fh->fd = -1; > if (ret != 0) { > DBG_ERR("Close [%s] failed: %s\n", > fsp_str_dbg(fsp), strerror(errno)); >- fsp->fh->fd = -1; > return -1; > } > >-- >2.26.2 >
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:
jra
:
review+
Actions:
View
Attachments on
bug 14596
:
16387
| 16388 |
16389