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

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