Re: [PATCH 1/4] INIT_TASK() should initialize ->thread_group list

From: Oleg Nesterov
Date: Wed May 12 2010 - 11:59:09 EST


On 05/11, Sukadev Bhattiprolu wrote:
>
> Oleg Nesterov [oleg@xxxxxxxxxx] wrote:
> | The trivial /sbin/init doing
> |
> | int main(void)
> | {
> | kill(0, SIGKILL)
> | }
> |
> | crashes the kernel.
>
> Really subtle. Good catch.

Thanks to Mathias ;)

> So, now init is not part of any process group until it calls setsid().
> So the above SIGKILL is lost right ? - i.e it does not kill even init
> itself.

No, no. swapper != init. With or without these patches (more precisely,
the next patch) /sbin/init still belongs to the 0 pgrp/sid.

> In my quick test, the following init process lives on inspite of the
> SIGKILL.

Yes, /sbin/init is not killable, that is why it survies.

But:

> main()
> {
> kill(0, SIGKILL);
>
> while(1)
> sleep(1);
> }

Yes. if /sbin/init exits the kernel panics. The real test-case shouldn't
exit, like your example.

> I don't have a better solution. Maybe a hung init is better than a
> crashed kernel.

Agreed!!! I sent the patch a long ago. But security people do not
like it, they use exit() from init to provoke the crash intentionally.
And I still think they are wrong, but this is another story.

> Acked-by: Sukadev Bhattiprolu <sukadev@xxxxxxxxxxxxxxxxxx>

Thanks!

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/