Re: [PATCH 2/2] exit_notify: kill the wrong capable(CAP_KILL) check

Serge E. Hallyn
2009-02-25T22:11:22Z

Quoting Oleg Nesterov (oleg@redhat.com):
> On 02/25, Serge E. Hallyn wrote:
> >
> > Quoting Roland McGrath (roland@redhat.com):
> > > > I can't understand why exit_notify() checks capable(CAP_KILL), but this
> > > > looks just wrong.
> > >
> > > I don't know either why it's there. My guess is that it was not actually
> > > thought out specifically, just a "unless capable" exception added when the
> > > security-motivated exclusions (exec_id stuff) were added.
> > >
> > > I can't think of any reason not to drop this check.
> >
> > Because of the following test?
> >
> > #include <stdio.h>
> > #include <sched.h>
> > #include <signal.h>
> > #include <stdlib.h>
> >
> > int childfn(void *data)
> > {
> > printf("hi there, i'm the child\n");
> > sleep(10);
> > exit(0);
> > }
> >
> > int main()
> > {
> > int stacksize = 4*getpagesize();
> > void *stack, *stacktop;
> >
> > stack = malloc(stacksize);
> > stacktop = stack + stacksize;
> >
> > int p = clone(childfn, stacktop, CLONE_PARENT|SIGSTOP, NULL);
> > exit(0);
> > }
>
> Can't understand... Why do you think CAP_KILL makes things better?
>
> Actually, how can it make any difference in this case?

Well the check by itself isn't quite right - it seems to me it
should also check whether tsk->euid == parent->uid. But letting
an unprivileged task send SIGSTOP to a privileged one bc of
some fluke in the task hierarchy doesn't seem right.

-serge