Blame SOURCES/0010-daemon-chroot-Fix-long-standing-possible-deadlock.patch

13e635
From 3435938f43ca3737ec1d73da4d8cad756b5c9508 Mon Sep 17 00:00:00 2001
13e635
From: "Richard W.M. Jones" <rjones@redhat.com>
13e635
Date: Fri, 26 Mar 2021 16:04:43 +0000
13e635
Subject: [PATCH] daemon: chroot: Fix long-standing possible deadlock.
13e635
13e635
The child (chrooted) process wrote its answer on the pipe and then
13e635
exited.  Meanwhile the parent waiting for the child to exit before
13e635
reading from the pipe.  Thus if the output was larger than a Linux
13e635
pipebuffer then the whole thing would deadlock.
13e635
13e635
(cherry picked from commit 94e64b28bee3b8dc7ed354a366d6a8f7ba5f245c)
13e635
---
13e635
 daemon/chroot.ml | 8 ++++----
13e635
 1 file changed, 4 insertions(+), 4 deletions(-)
13e635
13e635
diff --git a/daemon/chroot.ml b/daemon/chroot.ml
13e635
index 5e856c91f..7da8ae29e 100644
13e635
--- a/daemon/chroot.ml
13e635
+++ b/daemon/chroot.ml
13e635
@@ -62,6 +62,10 @@ let f t func arg =
13e635
   (* Parent. *)
13e635
   close wfd;
13e635
 
13e635
+  let chan = in_channel_of_descr rfd in
13e635
+  let ret = input_value chan in
13e635
+  close_in chan;
13e635
+
13e635
   let _, status = waitpid [] pid in
13e635
   (match status with
13e635
    | WEXITED 0 -> ()
13e635
@@ -76,10 +80,6 @@ let f t func arg =
13e635
       failwithf "chroot ā€˜%sā€™ stopped by signal %d" t.name i
13e635
   );
13e635
 
13e635
-  let chan = in_channel_of_descr rfd in
13e635
-  let ret = input_value chan in
13e635
-  close_in chan;
13e635
-
13e635
   match ret with
13e635
   | Either ret -> ret
13e635
   | Or exn -> raise exn
13e635
-- 
13e635
2.18.4
13e635