Merge ~halves/ubuntu/+source/sudo:lp1895757 into ubuntu/+source/sudo:ubuntu/bionic-devel

Proposed by Heitor Alves de Siqueira
Status: Needs review
Proposed branch: ~halves/ubuntu/+source/sudo:lp1895757
Merge into: ubuntu/+source/sudo:ubuntu/bionic-devel
Diff against target: 108 lines (+86/-0)
3 files modified
debian/changelog (+7/-0)
debian/patches/0001-In-pty_close-close-the-slave-and-remove-any-events-a.patch (+78/-0)
debian/patches/series (+1/-0)
Reviewer Review Type Date Requested Status
Eric Desrochers Pending
git-ubuntu developers Pending
Review via email: mp+391237@code.launchpad.net
To post a comment you must log in.

Unmerged commits

802f9d8... by Heitor Alves de Siqueira

Update d/changelog

dd72a5a... by Heitor Alves de Siqueira

LP: #1895757

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 23f3972..6055a4a 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,10 @@
6+sudo (1.8.21p2-3ubuntu1.3) bionic; urgency=medium
7+
8+ * d/p/0001-In-pty_close-close-the-slave-and-remove-any-events-a.patch:
9+ - fix sudo hangs when IO logging is enabled (LP: #1895757)
10+
11+ -- Heitor Alves de Siqueira <halves@canonical.com> Wed, 23 Sep 2020 14:59:35 +0000
12+
13 sudo (1.8.21p2-3ubuntu1.2) bionic-security; urgency=medium
14
15 * SECURITY UPDATE: buffer overflow in sudo when pwfeedback is enabled
16diff --git a/debian/patches/0001-In-pty_close-close-the-slave-and-remove-any-events-a.patch b/debian/patches/0001-In-pty_close-close-the-slave-and-remove-any-events-a.patch
17new file mode 100644
18index 0000000..3a884be
19--- /dev/null
20+++ b/debian/patches/0001-In-pty_close-close-the-slave-and-remove-any-events-a.patch
21@@ -0,0 +1,78 @@
22+From c4523c6c798464e6a4bdf03d715d04d90c8114d5 Mon Sep 17 00:00:00 2001
23+From: Heitor Alves de Siqueira <halves@canonical.com>
24+Date: Wed, 23 Sep 2020 11:23:43 -0300
25+Subject: [PATCH] In pty_close() close the slave and remove any events associated
26+
27+with it. Fixes a potential hang when performing the final flush
28+on non-BSD systems.
29+
30+Origin: backport, https://github.com/sudo-project/sudo/commit/4df454310dae
31+Bug-ubuntu: https://bugs.launchpad.net/bugs/1895757
32+---
33+ src/exec_pty.c | 20 ++++++++++++++++++--
34+ 1 file changed, 18 insertions(+), 2 deletions(-)
35+
36+Index: sudo/src/exec_pty.c
37+===================================================================
38+--- sudo.orig/src/exec_pty.c
39++++ sudo/src/exec_pty.c
40+@@ -680,12 +680,19 @@ io_buf_new(int rfd, int wfd,
41+ }
42+
43+ static void
44+-pty_close(struct command_status *cstat)
45++pty_close(struct sudo_event_base *evbase, struct command_status *cstat)
46+ {
47+ struct io_buffer *iob;
48+ int n;
49+ debug_decl(pty_close, SUDO_DEBUG_EXEC);
50+
51++ /* Close the pty slave first so reads from the master don't block. */
52++ if (io_fds[SFD_SLAVE] != -1) {
53++ ev_free_by_fd(evbase, io_fds[SFD_SLAVE]);
54++ close(io_fds[SFD_SLAVE]);
55++ io_fds[SFD_SLAVE] = -1;
56++ }
57++
58+ /* Flush any remaining output (the plugin already got it). */
59+ if (io_fds[SFD_USERTTY] != -1) {
60+ n = fcntl(io_fds[SFD_USERTTY], F_GETFL, 0);
61+@@ -713,6 +720,11 @@ pty_close(struct command_status *cstat)
62+ /* Update utmp */
63+ if (utmp_user != NULL)
64+ utmp_logout(slavename, cstat->type == CMD_WSTATUS ? cstat->val : 0);
65++
66++ /* Close pty master. */
67++ if (io_fds[SFD_MASTER] != -1)
68++ close(io_fds[SFD_MASTER]);
69++
70+ debug_return;
71+ }
72+
73+@@ -1409,7 +1421,7 @@ exec_pty(struct command_details *details
74+ }
75+
76+ /* Flush any remaining output, free I/O bufs and events, do logout. */
77+- pty_close(cstat);
78++ pty_close(ec.evbase, cstat);
79+
80+ /* Free things up. */
81+ free_exec_closure_pty(&ec);
82+@@ -1509,6 +1521,8 @@ del_io_events(bool nonblocking)
83+ }
84+ }
85+ }
86++ sudo_debug_printf(SUDO_DEBUG_INFO,
87++ "%s: flushing remaining I/O buffers (nonblocking)", __func__);
88+ (void) sudo_ev_loop(evbase, SUDO_EVLOOP_NONBLOCK);
89+
90+ /*
91+@@ -1534,6 +1548,8 @@ del_io_events(bool nonblocking)
92+ }
93+ }
94+ }
95++ sudo_debug_printf(SUDO_DEBUG_INFO,
96++ "%s: flushing remaining write buffers (blocking)", __func__);
97+ (void) sudo_ev_loop(evbase, 0);
98+
99+ /* We should now have flushed all write buffers. */
100diff --git a/debian/patches/series b/debian/patches/series
101index dfbedfc..64115a9 100644
102--- a/debian/patches/series
103+++ b/debian/patches/series
104@@ -5,3 +5,4 @@ keep_home_by_default.patch
105 CVE-2019-14287.patch
106 CVE-2019-14287-2.patch
107 CVE-2019-18634.patch
108+0001-In-pty_close-close-the-slave-and-remove-any-events-a.patch

Subscribers

People subscribed via source and target branches