9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] [PATCH] kernel: disallow executing from #| or #d
@ 2022-05-10  6:40 Jacob Moody
  2022-05-10 14:40 ` ori
  2022-05-10 20:52 ` [9front] " Anthony Martin
  0 siblings, 2 replies; 13+ messages in thread
From: Jacob Moody @ 2022-05-10  6:40 UTC (permalink / raw)
  To: 9front

Hello,

I noticed that you could execute from #| and #d.
ex:

cpu% bind '#|' /n/pipetest
cpu% /n/pipetest/data1 &
cpu% echo '#!/bin/rc' >> /n/pipetest/data
cpu% echo 'echo hello' >> /n/pipetest/data
cpu% hello

I believe this would also work for binaries
if the writer could predict what parts of the binary
the kernel will want to read. I am inclined to
block this behavior but would be curious what others
think. Included is a patch to error on OEXEC opens
in devdup and devpipe.

thanks,
moody

---
diff 6ca8e6bbafcc871301a90aa7bd4ca10533b1999a 521f304f5db4c74740b3e00503e2bf22e9f60dc6
--- a/sys/src/9/port/devdup.c	Mon May  9 11:22:00 2022
+++ b/sys/src/9/port/devdup.c	Tue May 10 00:35:16 2022
@@ -63,7 +63,7 @@
 	Chan *f;
 	int fd, twicefd;

-	if(omode & ORCLOSE)
+	if(omode & ORCLOSE || omode & OEXEC)
 		error(Eperm);
 	if(c->qid.type & QTDIR){
 		if(omode != 0)
--- a/sys/src/9/port/devpipe.c	Mon May  9 11:22:00 2022
+++ b/sys/src/9/port/devpipe.c	Tue May 10 00:35:16 2022
@@ -228,6 +228,8 @@
 		c->offset = 0;
 		return c;
 	}
+	if(omode == OEXEC)
+		error(Eperm);

 	p = c->aux;
 	qlock(p);

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-05-15 16:34 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-10  6:40 [9front] [PATCH] kernel: disallow executing from #| or #d Jacob Moody
2022-05-10 14:40 ` ori
2022-05-10 16:34   ` Jacob Moody
2022-05-10 19:59     ` Amavect
2022-05-10 22:47       ` Jacob Moody
2022-05-11  4:21         ` Amavect
2022-05-11  6:31           ` Jacob Moody
2022-05-11 16:32             ` Amavect
2022-05-11 16:50               ` Jacob Moody
2022-05-15  2:43                 ` Amavect
2022-05-15 15:26                   ` Amavect
2022-05-15 16:28                     ` Jacob Moody
2022-05-10 20:52 ` [9front] " Anthony Martin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).