Re: [PATCH] [RFC] signal: Add KUnit tests
From: Kees Cook
Date: Thu Aug 17 2023 - 12:58:10 EST
On Wed, Aug 16, 2023 at 11:08:21PM -0500, Eric W. Biederman wrote:
> Kees Cook <keescook@xxxxxxxxxxxx> writes:
>
> > This is a continuation of the proposal[1] for mocking init_task for
> > KUnit testing. Changing the behavior of kill_something_info() is moving
> > forward[2] and I'd _really_ like to have some unit tests in place to
> > actually test the behavioral changes.
> >
> > I tried to incorporate feedback from Daniel and David, and I think the
> > result is fairly workable -- the only tricky part is building valid
> > task_struct instances. :)
> >
> > Notably, I haven't actually gotten as far as testing the actual proposed
> > behavioral change since I wanted to make sure this approach wasn't going
> > to totally crash and burn.
> >
> > Thoughts?
>
> Overall this looks like a nice start. More comments below.
>
> I do wonder though. Would it perhaps be easier to create a pid
> namespace with just the processes you want in it?
Do you have a short example of how I could do this correctly? It's not
obvious to me how to actually set all that up (and tear it down).
> I am wondering because you failed to mock find_vpid and so you
> are actually testing sending signals to kernel threads.
Hah. Eek.
--
Kees Cook