[PATCH] Fix bug #10564 - Lock order violation and file lost

Volker Lendecke Volker.Lendecke at SerNet.DE
Fri May 2 11:58:35 MDT 2014


On Thu, May 01, 2014 at 11:21:00AM -0700, Jeremy Allison wrote:
> Volker, here is the patchset we discussed
> on the phone earlier this week. It finally
> removes open_file_fchmod() and protects
> INTERNAL_OPEN_ONLY from causing deadlocks
> when the share mode locking db has already
> been locked across an atomic rename() operation.
> 
> Tested here and fixes the smb_panic call
> reported by the caller.
> 
> Please review and push if appropriate !

The two cosmetic patches attached are necessary from my pov.
With those squashed appropriately it's Reviewed-by: me.

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
>From c743dfadb8bc9c66dd258d1cdd5a866d96f14b68 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 May 2014 16:22:50 +0000
Subject: [PATCH 1/2] smbd: Correct error return from file_set_dosmode

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/smbd/dosmode.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c
index 22ab4eb..a99f6f2 100644
--- a/source3/smbd/dosmode.c
+++ b/source3/smbd/dosmode.c
@@ -789,6 +789,7 @@ int file_set_dosmode(connection_struct *conn, struct smb_filename *smb_fname,
 	struct timespec new_create_timespec;
 	files_struct *fsp = NULL;
 	bool need_close = false;
+	NTSTATUS status;
 
 	if (!CAN_WRITE(conn)) {
 		errno = EROFS;
@@ -961,11 +962,13 @@ int file_set_dosmode(connection_struct *conn, struct smb_filename *smb_fname,
 	 * metadata operation under root.
 	 */
 
-	if (!NT_STATUS_IS_OK(get_file_handle_for_metadata(conn,
-					smb_fname,
-					&fsp,
-					&need_close))) {
-		return false;
+	status = get_file_handle_for_metadata(conn,
+					      smb_fname,
+					      &fsp,
+					      &need_close);
+	if (!NT_STATUS_IS_OK(status)) {
+		errno = map_errno_from_nt_status(status);
+		return -1;
 	}
 
 	become_root();
-- 
1.8.1.2


>From d0e826a85292596acd82755dec37f752cd7072e2 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 May 2014 16:23:03 +0000
Subject: [PATCH 2/2] smbd: Avoid an empty 'else'

I bet there will be static analysis tools around confused by this :-)

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/smbd/files.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/source3/smbd/files.c b/source3/smbd/files.c
index 5676bc9..2a0f6ce 100644
--- a/source3/smbd/files.c
+++ b/source3/smbd/files.c
@@ -109,7 +109,8 @@ NTSTATUS file_new(struct smb_request *req, connection_struct *conn,
 		fsp->fnum = op->local_id;
 		fsp->fh->gen_id = smbXsrv_open_hash(op);
 	} else {
-		/* INTERNAL_OPEN_ONLY */
+		DEBUG(10, ("%s: req==NULL, INTERNAL_OPEN_ONLY, smbXsrv_open "
+			   "allocated\n", __func__));
 	}
 
 	/*
-- 
1.8.1.2



More information about the samba-technical mailing list