From: Stefan Metzmacher Date: Fri, 7 Nov 2014 23:57:40 +0000 (-0800) Subject: s3:smbd: fix file corruption using "write cache size != 0" X-Git-Tag: samba-4.0.23~39 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7e486b942c7e5cd923bb9ced6b7bc9649bc7100e;p=thirdparty%2Fsamba.git s3:smbd: fix file corruption using "write cache size != 0" A client can: - open a handle (h1) - write some data to h1. - open a 2nd handle h2 (downgrades both handles to level II) - try to read the data on h2 (this gets old data) Bug: https://bugzilla.samba.org/show_bug.cgi?id=10921 Signed-off-by: Stefan Metzmacher Autobuild-User(v4-0-test): Karolin Seeger Autobuild-Date(v4-0-test): Sun Nov 9 22:51:19 CET 2014 on sn-devel-104 --- diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c index 95d88ef3813..045fd46967d 100644 --- a/source3/smbd/oplock.c +++ b/source3/smbd/oplock.c @@ -151,6 +151,9 @@ static void downgrade_file_oplock(files_struct *fsp) sconn->oplocks.level_II_open++; fsp->sent_oplock_break = NO_BREAK_SENT; + flush_write_cache(fsp, OPLOCK_RELEASE_FLUSH); + delete_write_cache(fsp); + TALLOC_FREE(fsp->oplock_timeout); }