Tuesday, September 26, 2017

Fix pledge(2) on x11/st

Hi ports@

If st's window is deleted then it will dump core due to a missing pledge
promise, specifically proc. Once the window is deleted it will try to send
a SIGHUP through kill(2), but since proc is missing from the pledge applied
once the parent process then it will abort.

Additionally the pledge applied on the child process can be further reduced if
called later on because getpwuid(3) is only called once and from the on getpw
promise is not needed anymore.

OK?

Index: patches/patch-st_c
===================================================================
RCS file: /cvs/ports/x11/st/patches/patch-st_c,v
retrieving revision 1.3
diff -u -p -u -r1.3 patch-st_c
--- patches/patch-st_c 5 Apr 2017 21:29:57 -0000 1.3
+++ patches/patch-st_c 26 Sep 2017 21:43:38 -0000
@@ -1,18 +1,22 @@
$OpenBSD: patch-st_c,v 1.3 2017/04/05 21:29:57 juanfra Exp $
---- st.c.orig Thu Aug 11 16:25:58 2016
-+++ st.c Wed Mar 29 14:20:44 2017
-@@ -1454,9 +1454,15 @@ ttynew(void)
- die("ioctl TIOCSCTTY failed: %s\n", strerror(errno));
- close(s);
- close(m);
-+
-+ if (pledge("stdio getpw proc exec", NULL) == -1)
-+ die("pledge\n");
+Index: st.c
+--- st.c.orig
++++ st.c
+@@ -1366,6 +1366,9 @@ execsh(void)
+ signal(SIGTERM, SIG_DFL);
+ signal(SIGALRM, SIG_DFL);
+
++ if (pledge("stdio proc exec", NULL) == -1)
++ die("pledge\n");
+
+ execvp(prog, args);
+ _exit(1);
+ }
+@@ -1457,6 +1460,8 @@ ttynew(void)
execsh();
break;
default:
-+ if (pledge("stdio rpath tty", NULL) == -1)
++ if (pledge("stdio rpath tty proc", NULL) == -1)
+ die("pledge\n");
close(s);
cmdfd = m;

No comments:

Post a Comment