pledge csh nice = death

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

pledge csh nice = death

Ian McWilliam-2


        Oct 19 11:55:52 ianm-openbsd /bsd: csh(29463): syscall 96

        Oct 19 11:55:52 ianm-openbsd /bsd: csh(6081): syscall 96

        Oct 19 11:55:52 ianm-openbsd /bsd: csh(18068): syscall 96

        Oct 19 11:57:14 ianm-openbsd /bsd: csh(31019): syscall 96

        Oct 19 11:57:14 ianm-openbsd /bsd: csh(20634): syscall 96

        Oct 19 11:57:14 ianm-openbsd /bsd: csh(6171): syscall 96

        96 STD { int sys_setpriority(int which, id_t who, int prio); }

        Some of my csh scripts set 'nice' priorities on some things they do.

        Ian McWilliam
Reply | Threaded
Open this post in threaded view
|

Re: pledge csh nice = death

Theo Buehler
On Mon, Oct 19, 2015 at 12:23:21PM +1100, Ian McWilliam wrote:

>
>
> Oct 19 11:55:52 ianm-openbsd /bsd: csh(29463): syscall 96
>
> Oct 19 11:55:52 ianm-openbsd /bsd: csh(6081): syscall 96
>
> Oct 19 11:55:52 ianm-openbsd /bsd: csh(18068): syscall 96
>
> Oct 19 11:57:14 ianm-openbsd /bsd: csh(31019): syscall 96
>
> Oct 19 11:57:14 ianm-openbsd /bsd: csh(20634): syscall 96
>
> Oct 19 11:57:14 ianm-openbsd /bsd: csh(6171): syscall 96
>
> 96 STD { int sys_setpriority(int which, id_t who, int prio); }
>
> Some of my csh scripts set 'nice' priorities on some things they do.
>
> Ian McWilliam

As a temporary workaround you could call /usr/bin/nice to avoid csh's
builtin.

It looks like csh would currently need to pledge("id") in order for the
builtin nice to work --- setpriority() is called in three places
depending on how nice is invoked.  However, adding "id" to a shell
seems a bit scary.

Would it be preferable to mark
[SYS_setpriority] = PLEDGE_PROC | PLEDGE_ID?

Index: bin/csh/csh.c
===================================================================
RCS file: /cvs/src/bin/csh/csh.c,v
retrieving revision 1.29
diff -u -p -r1.29 csh.c
--- bin/csh/csh.c 18 Oct 2015 03:09:11 -0000 1.29
+++ bin/csh/csh.c 19 Oct 2015 10:04:28 -0000
@@ -104,7 +104,7 @@ main(int argc, char *argv[])
     cshout = stdout;
     csherr = stderr;
 
-    if (pledge("stdio rpath wpath cpath fattr getpw proc exec tty",
+    if (pledge("stdio rpath wpath cpath fattr getpw proc exec tty id",
  NULL) == -1)
     perror("pledge");

Reply | Threaded
Open this post in threaded view
|

Re: pledge csh nice = death

Theo de Raadt
> It looks like csh would currently need to pledge("id") in order for the
> builtin nice to work --- setpriority() is called in three places
> depending on how nice is invoked.  However, adding "id" to a shell
> seems a bit scary.
>
> Would it be preferable to mark
> [SYS_setpriority] = PLEDGE_PROC | PLEDGE_ID?

I prefer that, and will do that.

However I'd like a semantic where priority can only be adjusted downwards.
semarie was talking about that as well.  I'll commit PLEDGE_PROC | PLEDGE_ID,
and hope you two write such a diff...