The Samba-Bugzilla – Attachment 16387 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]
git-am fix for 4.13.next.
bug-14596-4.13 (text/plain), 10.61 KB, created by
Jeremy Allison
on 2021-01-08 22:10:46 UTC
(
hide
)
Description:
git-am fix for 4.13.next.
Filename:
MIME Type:
Creator:
Jeremy Allison
Created:
2021-01-08 22:10:46 UTC
Size:
10.61 KB
patch
obsolete
>From 56441187c8b9d39e0905598d1f82b6ebac94d10b Mon Sep 17 00:00:00 2001 >From: Stefan Metzmacher <metze@samba.org> >Date: Tue, 8 Dec 2020 15:47:53 +0100 >Subject: [PATCH 1/7] s4:torture/fruit: avoid sleep(10000000); if > write_stream() fails > >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 f9b2559c4208d680d43fa39823b2d5eb048bcf19) >--- > source4/torture/vfs/fruit.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > >diff --git a/source4/torture/vfs/fruit.c b/source4/torture/vfs/fruit.c >index a094ce0ab65..0be1da765d0 100644 >--- a/source4/torture/vfs/fruit.c >+++ b/source4/torture/vfs/fruit.c >@@ -1962,9 +1962,8 @@ static bool write_stream(struct smb2_tree *tree, > if (value == NULL) { > return true; > } else { >- torture_comment(tctx, "Unable to open stream %s\n", >- full_name); >- sleep(10000000); >+ torture_comment(tctx, "Unable to open stream %s: %s\n", >+ full_name, nt_errstr(status)); > return false; > } > } >-- >2.27.0 > > >From 6fb9a9d1c2ff4e3f7f0e0b2e181b4aed2933bd47 Mon Sep 17 00:00:00 2001 >From: Stefan Metzmacher <metze@samba.org> >Date: Fri, 18 Dec 2020 14:03:09 +0100 >Subject: [PATCH 2/7] 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 7d59ca5242f..fea3abfee7d 100644 >--- a/source3/smbd/proto.h >+++ b/source3/smbd/proto.h >@@ -1333,6 +1333,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 f8c71014955..c4978fe5212 100644 >--- a/source3/smbd/vfs.c >+++ b/source3/smbd/vfs.c >@@ -1582,6 +1582,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.27.0 > > >From 25ab4a10295f9e30165fd882d189d0ed722ceb68 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/7] 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 51251b7b86b..a959389bcdc 100644 >--- a/source3/modules/vfs_fruit.c >+++ b/source3/modules/vfs_fruit.c >@@ -1691,7 +1691,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; > >@@ -1720,7 +1720,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.27.0 > > >From 9e7595dee3c2d07a33fab6db7470a4ccafcc0de2 Mon Sep 17 00:00:00 2001 >From: Stefan Metzmacher <metze@samba.org> >Date: Fri, 18 Dec 2020 14:36:00 +0100 >Subject: [PATCH 4/7] 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 2e4105fec49..14532395e8a 100644 >--- a/source3/modules/vfs_streams_xattr.c >+++ b/source3/modules/vfs_streams_xattr.c >@@ -504,7 +504,7 @@ static int streams_xattr_openat(struct vfs_handle_struct *handle, > > fail: > if (fakefd >= 0) { >- close(fakefd); >+ vfs_fake_fd_close(fakefd); > fakefd = -1; > } > >@@ -526,7 +526,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.27.0 > > >From 17e06debff74c383abe77b54bd1e717d77e8588d Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Fri, 11 Dec 2020 13:00:09 +0100 >Subject: [PATCH 5/7] 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 a959389bcdc..15bd368ff86 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 >@@ -2251,7 +2248,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]; > >@@ -3954,7 +3951,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; > >@@ -4027,11 +4023,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->fsp_flags.is_directory) { > return status; > } >-- >2.27.0 > > >From d955b3bac12e6358bc268642294a48d26ef115e6 Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Fri, 11 Dec 2020 13:00:56 +0100 >Subject: [PATCH 6/7] 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 15bd368ff86..e17c08e8664 100644 >--- a/source3/modules/vfs_fruit.c >+++ b/source3/modules/vfs_fruit.c >@@ -2137,9 +2137,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.27.0 > > >From 401d7b1cf43d4bef5175f719c14aab4b0bbd1125 Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Fri, 11 Dec 2020 12:59:28 +0100 >Subject: [PATCH 7/7] 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 e17c08e8664..d0a321780e6 100644 >--- a/source3/modules/vfs_fruit.c >+++ b/source3/modules/vfs_fruit.c >@@ -1676,6 +1676,7 @@ static int fruit_openat(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; > >@@ -1684,7 +1685,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: >@@ -2480,13 +2486,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.27.0 >
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:
slow
:
review-
Actions:
View
Attachments on
bug 14596
:
16387
|
16388
|
16389