0

I have a theoretical question, What would happen if I clean up all the swap space while running, Would the operating system crash because of page faults that would happen in the kernel?

  • What do you mean by "clean up"? Turn swap off? Overwrite with random values? – Jens Apr 9 '16 at 20:14
  • Overwrite with random values – Lee Apr 10 '16 at 7:05
4

If you just mean running "swapoff -a" when you say "clean up", then no.

If you corrupt/overwrite the swap device/file, an application that gets swapped back in (with corrupted data) is very likely to crash, yes. The kernel does not get swapped out, so the "system" would not crash.

  • The kernel does not get swapped out at all? Is it possible to configure that? – Lee Apr 10 '16 at 7:02
  • @Lee No, because the kernel does the swapping. Otherwise you would have a chicken-and-egg problem. – Jens Apr 10 '16 at 10:44
6

Overwriting swap with random values is equivalent to overwriting process images in memory with random values.

If a text segment with random values is executed, the most likely result is process termination due to an illegal instruction (signal SIGILL).

If a data segment with random values is read, the result is most likely process termination due to a segmentation fault (signal SIGSEGV), because pointers will point outside the process's address space. Note that pointers are data, just like scalars. Especially the stack usually contains several pointers; when a return instruction is executed, a random stack entry causes a jump to a random address.

  • You refer to pointers, not content. Perhaps you can clarify that in your good answer. – Nils Apr 10 '16 at 12:57
  • @Nils Thanks for the suggestion. I've added a bit more to clarify. – Jens Apr 10 '16 at 14:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.