Who says that it is legal or illegal?
Machines themselves have no rights. IF the owner of the machine claims a malicious process, then that owner would have the right for her machine to not be trespassed (and also would be a likely target for jail), but if the owner of the machine makes no such claim (the odds on favorite since making such a claim would send you to jail), then the rogue process in question has no legal owner.
Without a legal owner, and since machines themselves have no legal rights, who is to say whether or not someone being attacked by that rogue process can shut it down or not?