Smallest C code to Crash an Operating System?

5

A shortest C program, that can crash the Operating system, either on a Windows or a Linux PC...

Rules:

  • The code is to be developed in C language, but it may use other api, specific to linux or windows systems.
  • The Operating System is said to have been put out of commission, if either it has come to a state[Standstill or otherwise] , where no matter how much time passes, the system is rendered inoperable or (even better), self restarts itself, or something similar to a blue screen of death.
  • To be most effective, the program will be run as a normal user and not as superuser or an administrator.
  • For every valid program that is able to crash the PC, countermeasures can be suggested by others in the comments, successful measures that can nullify the effect of the program gets the answer invalidated. For Example - If an answer suggests use of fork Bombs, i would suggest measures like this in the comments.
  • Since Linux OS is considered more stable, a program that crashes linux is always a better one, even if it takes extra code than it takes to crash windows, but still the smallest program to crash the OS wins, independent of the platform.
  • The community is free to edit the question to add more sensible rules, provided the new rules maintain compatibility with existing answers.

Note: This above question is asked with the purpose of demonstrating the raw power of C[or the lack of it] as a low level/mid level language. Also hopefully, to become more aware of OS security, and possible measures that can be taken.

EDIT:

A similar question lies here Code Golf of Death...

But here are the reasons my question differs from the above mentioned one...

  1. I am looking for the answers to only be in C language.
  2. Though the above question has one answer in C, the code works only for a rare version of pentium 5. So in short there is no C language based answer in the above question to achieve the end purpose.
  3. In the other question Kernel-mode drivers are allowed, but my question concentrates mainly on user space processes.
  4. Some of the answers in the above question allow the programs to run in supervisor/administrator mode, but such privileged execution of the program is not allowed in the rules stated by my question.
  5. In the similar question the answer with highest upvotes win, in my question answer which crashes the OS , using the shortest code, and does so without any suggestion of countermeasure to be taken against the method employed by the answer.
  6. In short, apart from the same intention of crashing the OS , the two questions differ in every other aspect.

Barath Bushan

Posted 2013-05-08T17:47:03.490

Reputation: 159

Question was closed 2013-05-08T23:27:57.700

1@PeterTaylor Tried searching for a similar question before posting this one , but could not find any(why would i think of searching "Code Golf of Death" :) ). Thanks for giving a link to a similiar question. But the question is not an exact duplicate , since i want my code to be short , and to be in C, not bash or any other language. Also i've added the option where countermeasures are given in comments.Though the intention of the questions are same , the approach and purpose of doing so is different. – Barath Bushan – 2013-05-08T18:35:33.443

I found it by searching for "crash", but I did have the advantage of a vague memory that there had been a similar question before. I agree that it's not an exact duplicate, but it's close enough that any answer to this question would be a valid answer to the other one, and the existing C answers to the other question would be valid answers to this one. I regard the wording "exact" in the close reason as unhelpful; if the essence of the question is the same, there's no benefit to splitting or duplicating the answers. Feel free to start a topic in meta about what "duplicate" means. – Peter Taylor – 2013-05-08T18:45:00.840

@PeterTaylor, if you say its a duplicate, then it sure is, since you have been using this site for 2 years....But still am not satisfied enough with the C solutions in the other question ,simply because there is none, and the only solution (which is a really good one) , relies on a very rare version of pentium 5(and outdated too)....But still please free to close the question if you still feel it is appropriate to do so.... – Barath Bushan – 2013-05-08T18:59:58.290

I am fine with the question being closed as duplicate, but why the downvotes...I have adhered to the faq guidelines as far as possible, is there something i missed ?? – Barath Bushan – 2013-05-09T01:11:47.347

1Shame it's closed. You said the community can edit the rules as long as they accept existing answers. I was gonna add a rule "boothby's solutions are allowed to presume the use of a sledgehammer" and win with a zero character program! – boothby – 2013-05-09T03:20:31.613

Answers

6

29 chars

Linux

int main(){system("init 6");}

I know, very lame. But hey, it reboots the system. Wasn't that the task?

Windows 38 chars

int main(){system("shutdown.exe /r");}

Works as normal user.

Johannes Kuhn

Posted 2013-05-08T17:47:03.490

Reputation: 7 122

1+1 for exploiting the vulnerability in the rules of the question itself, but clearly in the context of the question, self restarts itself means typically the system self restarting after a crash....so this answer is a no go... – Barath Bushan – 2013-05-08T19:06:40.943

Depends if you see init as part of the system or not (I just tell init to reboot). – Johannes Kuhn – 2013-05-08T19:11:39.167

True...Init is part of the system ,...But the reboot is a graceful one, not a crash... – Barath Bushan – 2013-05-08T19:19:11.193

Why not halt? You shave 2 chars and it doesn't even come back... – boothby – 2013-05-09T03:16:04.207

according to the task, restart is better. – Johannes Kuhn – 2013-05-09T09:27:58.373