Skip to contentSkip to conversation

Change in openvpn[master]: dns: close first pipe if creating the second one fails

Openvpn-devel In review Răzvan Cojocaru (Code Review) via Openvpn-devel 3 participants 6 messages Nov 2 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1793625001000.I73efe00fddbd919897489c975ec65ed4b4628cc8@gerrit.openvpn.net

#1 lore raw

Attention is currently required from: Arne Schwabe.

Hello Arne Schwabe,

I'd like you to do a code review.
Please visit

    https://gerrit.openvpn.net/c/openvpn/+/2091?usp=email

to review the following change.

Change subject: dns: close first pipe if creating the second one fails
......................................................................

dns: close first pipe if creating the second one fails

run_updown_runner() leaked dns_pipe_fd when pipe(ack_pipe_fd) failed.

Broken since 1dfe8729 ("dns: support running up/down command with privsep").

Change-Id I73efe00fddbd919897489c975ec65ed4b4628cc8

---
M src/openvpn/dns.c

1 file changed, 8 insertions(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/91/2091/1

src/openvpn/dns.c +8 -1
index e5ed1bc..abe30ed 100644
@@ -608,11 +608,18 @@
 {
     int dns_pipe_fd[2];
     int ack_pipe_fd[2];
-    if (pipe(dns_pipe_fd) != 0 || pipe(ack_pipe_fd) != 0)
+    if (pipe(dns_pipe_fd) != 0)
     {
         msg(M_WARN | M_ERRNO, "run_dns_up_down: unable to create pipes");
         return false;
     }
+    if (pipe(ack_pipe_fd) != 0)
+    {
+        msg(M_WARN | M_ERRNO, "run_dns_up_down: unable to create pipes");
+        close(dns_pipe_fd[0]);
+        close(dns_pipe_fd[1]);
+        return false;
+    }
     updown_runner->pid = fork();
     if (updown_runner->pid == -1)
     {

--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2091?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I73efe00fddbd919897489c975ec65ed4b4628cc8
Gerrit-Change-Number: 2091
Gerrit-PatchSet: 1
Gerrit-Owner: Răzvan Cojocaru <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: Arne Schwabe <[email protected]>

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: Arne Schwabe, Răzvan Cojocaru.

Frank Lichtenheld has posted comments on this change by Răzvan Cojocaru. ( https://gerrit.openvpn.net/c/openvpn/+/2091?usp=email )

Change subject: dns: close first pipe if creating the second one fails
......................................................................

Patch Set 2: Code-Review+2

--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2091?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I73efe00fddbd919897489c975ec65ed4b4628cc8
Gerrit-Change-Number: 2091
Gerrit-PatchSet: 2
Gerrit-Owner: Răzvan Cojocaru <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-Reviewer: Frank Lichtenheld <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: Răzvan Cojocaru <[email protected]>
Gerrit-Attention: Arne Schwabe <[email protected]>
Gerrit-Comment-Date: Mon, 02 Nov 2026 17:05:12 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#3 lore raw

PATCH v2 1/1 dns: close first pipe if creating the second one fails

In reply to a message not in the archive

From: Razvan Cojocaru <[email protected]>

run_updown_runner() leaked dns_pipe_fd when pipe(ack_pipe_fd) failed.

Broken since 1dfe8729 ("dns: support running up/down command with privsep").

Change-Id I73efe00fddbd919897489c975ec65ed4b4628cc8

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2091
---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2091
This mail reflects revision 2 of this Change.

Acked-by according to Gerrit (reflected above):
Frank Lichtenheld <[email protected]>

src/openvpn/dns.c +8 -1
index e5ed1bc..abe30ed 100644
@@ -608,11 +608,18 @@
 {
     int dns_pipe_fd[2];
     int ack_pipe_fd[2];
-    if (pipe(dns_pipe_fd) != 0 || pipe(ack_pipe_fd) != 0)
+    if (pipe(dns_pipe_fd) != 0)
     {
         msg(M_WARN | M_ERRNO, "run_dns_up_down: unable to create pipes");
         return false;
     }
+    if (pipe(ack_pipe_fd) != 0)
+    {
+        msg(M_WARN | M_ERRNO, "run_dns_up_down: unable to create pipes");
+        close(dns_pipe_fd[0]);
+        close(dns_pipe_fd[1]);
+        return false;
+    }
     updown_runner->pid = fork();
     if (updown_runner->pid == -1)
     {

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Acked-by Frank Lichtenheld on v2 1/1
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: dns: close first pipe if creating the second one fails

This should be unlikely to happen, but then, resource exhaustion does happen... and then we shouldn't leak.

Just stared at the code & did a test compile & BB all green :-)

Your patch has been applied to the master and release/2.7 branch (bugfix).

commit 4a6c1db218c71a4c7a8346f7508242a315fb587d (master) commit 685c12392fa8fa107657066a4077233e1f7206ff (release/2.7)

Author: Razvan Cojocaru
Date:   Mon Nov 2 18:05:25 2026 +0100

dns: close first pipe if creating the second one fails

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2091
Message-Id: <[email protected]>
URL: https://lore.kernel.org/openvpn-devel/[email protected]

--
kind regards,

Gert Doering

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#5 lore raw
In reply to a message not in the archive

Gert Doering has submitted this change. ( https://gerrit.openvpn.net/c/openvpn/+/2091?usp=email )

Change subject: dns: close first pipe if creating the second one fails
......................................................................

dns: close first pipe if creating the second one fails

run_updown_runner() leaked dns_pipe_fd when pipe(ack_pipe_fd) failed.

Broken since 1dfe8729 ("dns: support running up/down command with privsep").

Change-Id I73efe00fddbd919897489c975ec65ed4b4628cc8

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2091
Message-Id: <[email protected]>
URL: https://lore.kernel.org/openvpn-devel/[email protected]

---
M src/openvpn/dns.c

1 file changed, 8 insertions(+), 1 deletion(-)
src/openvpn/dns.c +8 -1
index e5ed1bc..abe30ed 100644
@@ -608,11 +608,18 @@
 {
     int dns_pipe_fd[2];
     int ack_pipe_fd[2];
-    if (pipe(dns_pipe_fd) != 0 || pipe(ack_pipe_fd) != 0)
+    if (pipe(dns_pipe_fd) != 0)
     {
         msg(M_WARN | M_ERRNO, "run_dns_up_down: unable to create pipes");
         return false;
     }
+    if (pipe(ack_pipe_fd) != 0)
+    {
+        msg(M_WARN | M_ERRNO, "run_dns_up_down: unable to create pipes");
+        close(dns_pipe_fd[0]);
+        close(dns_pipe_fd[1]);
+        return false;
+    }
     updown_runner->pid = fork();
     if (updown_runner->pid == -1)
     {

--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2091?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I73efe00fddbd919897489c975ec65ed4b4628cc8
Gerrit-Change-Number: 2091
Gerrit-PatchSet: 3
Gerrit-Owner: Răzvan Cojocaru <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-Reviewer: Frank Lichtenheld <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#6 lore raw
In reply to a message not in the archive

Gert Doering has uploaded a new patch set (#3) to the change originally created by Răzvan Cojocaru. ( https://gerrit.openvpn.net/c/openvpn/+/2091?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by Frank Lichtenheld

Change subject: dns: close first pipe if creating the second one fails
......................................................................

dns: close first pipe if creating the second one fails

run_updown_runner() leaked dns_pipe_fd when pipe(ack_pipe_fd) failed.

Broken since 1dfe8729 ("dns: support running up/down command with privsep").

Change-Id I73efe00fddbd919897489c975ec65ed4b4628cc8

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2091
Message-Id: <[email protected]>
URL: https://lore.kernel.org/openvpn-devel/[email protected]

---
M src/openvpn/dns.c

1 file changed, 8 insertions(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/91/2091/3

src/openvpn/dns.c +8 -1
index e5ed1bc..abe30ed 100644
@@ -608,11 +608,18 @@
 {
     int dns_pipe_fd[2];
     int ack_pipe_fd[2];
-    if (pipe(dns_pipe_fd) != 0 || pipe(ack_pipe_fd) != 0)
+    if (pipe(dns_pipe_fd) != 0)
     {
         msg(M_WARN | M_ERRNO, "run_dns_up_down: unable to create pipes");
         return false;
     }
+    if (pipe(ack_pipe_fd) != 0)
+    {
+        msg(M_WARN | M_ERRNO, "run_dns_up_down: unable to create pipes");
+        close(dns_pipe_fd[0]);
+        close(dns_pipe_fd[1]);
+        return false;
+    }
     updown_runner->pid = fork();
     if (updown_runner->pid == -1)
     {

--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2091?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I73efe00fddbd919897489c975ec65ed4b4628cc8
Gerrit-Change-Number: 2091
Gerrit-PatchSet: 3
Gerrit-Owner: Răzvan Cojocaru <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-Reviewer: Frank Lichtenheld <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel