From b1c823dc8c2824ec89921601d8e5e95f6d18fca8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 22 Sep 2015 18:02:53 -0700 Subject: [PATCH] s3: smbd: Fix mkdir race condition. Found by Max of LoadDynamix BUG: https://bugzilla.samba.org/show_bug.cgi?id=11486 Signed-off-by: Jeremy Allison Reviewed-by: Volker Lendecke --- source3/smbd/open.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 809fa352dfc..162e8347b94 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -3488,6 +3488,25 @@ static NTSTATUS open_directory(connection_struct *conn, nt_errstr(status))); return status; } + + /* + * If mkdir_internal() returned + * NT_STATUS_OBJECT_NAME_COLLISION + * we still must lstat the path. + */ + + if (SMB_VFS_LSTAT(conn, smb_dname) + == -1) { + DEBUG(2, ("Could not stat " + "directory '%s' just " + "opened: %s\n", + smb_fname_str_dbg( + smb_dname), + strerror(errno))); + return map_nt_error_from_unix( + errno); + } + info = FILE_WAS_OPENED; } }