Thread (29 messages) 29 messages, 5 authors, 2022-06-22

Re: [PATCH mdadm v1 04/14] mdadm/Grow: Fix use after close bug by closing after fork

From: Mariusz Tkaczyk <hidden>
Date: 2022-06-20 15:01:47

On Thu,  9 Jun 2022 15:11:20 -0600
Logan Gunthorpe [off-list ref] wrote:
quoted hunk ↗ jump to hunk
---
 Grow.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/Grow.c b/Grow.c
index 8a242b0f8725..ba5dc1aead64 100644
--- a/Grow.c
+++ b/Grow.c
@@ -3506,7 +3506,6 @@ started:
 			return 0;
 		}
 
-	close(fd);
 	/* Now we just need to kick off the reshape and watch, while
 	 * handling backups of the data...
 	 * This is all done by a forked background process.
@@ -3527,6 +3526,9 @@ started:
 		break;
 	}
 
+	/* Close unused file descriptor in the forked process */
+	close(fd);
+
 	/* If another array on the same devices is busy, the
 	 * reshape will wait for them.  This would mean that
 	 * the first section that we suspend will stay suspended
Please use close_fd() helper to invalidate fd too.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help