开发者

Can Kernel use virtual memory In Linux [duplicate]

开发者 https://www.devze.com 2023-03-30 19:08 出处:网络
This question already has answers here: What can cause segmentation faults in C++? [closed] (9 answers)
This question already has answers here: What can cause segmentation faults in C++? [closed] (9 answers) Closed 9 years ago.

My question is whether linux kernel c开发者_运维问答an use virtual memory or does it always uses fixed memory? Another question is that if due to some soft error, the kernel memory is corrupted, what will happen then? Does Linux has any mechanism to protect itself from such faults?


Kernel uses virtual adresses. Allocated memory, function pointers etc... are all virtual adress. You only manipulate physical adress when speaking to some devices or when doing certain kind of DMA.

"Linux" or "The linux kernel" run on many architecture. Some of these architecture can have memory error detection or correction hardware. I don't know how these device are supported. But on most architecture, there is no protection against memory corruption.

But you are speaking of soft error. There is no protection from kernel code writing at random adresses. Some function test the parameters they get to catch bug, but if you overflow a buffer or the stack in kernel mode, then various funny things can happen.

Const data and code is usually placed in read-only pages, so that a write can be detected. The memory protection of the kernel is thus limited to :

  • Parameter checking in some places.
  • magic value in some structure.
  • read only attribute for code and const sections.

read only attribute is only possible because the kernel uses virtual memory

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号