Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Based on part of the first answer of this questions:

read from a file (the kernel must check that the permissions allow you to read from said file, and then the kernel carries out the actual instructions to the disk to read the file)

It requires to have root privilege to change permission to a file. With root privilege, user can access any files without worrying about permission. So, are the any relationships between root and kernel?

share|improve this question

closed as unclear what you're asking by psusi, slm, Flup, jasonwryan, Braiam Mar 27 at 16:37

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

    
Question is too vague / unclear to be answerable. –  psusi Mar 27 at 13:47
    
This question practically involves several things. It may require one to read about system call, privilege and privilege level. I do not know how to word the question better. Somehow, Steven D understands what I mean. –  Ron Vince Mar 28 at 14:03

1 Answer 1

up vote 5 down vote accepted

First, a clarification:

It requires to have root privilege to change permission to a file.

From man 2 chmod we can see that the chmod() system call will return EPERM (a permissions error) if:

The effective UID does not match the owner of the file, and the process is not privileged (Linux: it does not have the CAP_FOWNER capability).

This typically means that you either need to be the owner of the file or the root user. But we can see that the situation in Linux might be a bit more complicated.

So, are the any relationships between root and kernel?

As the text you quoted has pointed out, the kernel is responsible for checking that the UID of the process making a system call (that is, the user it is running as) is allowed to do what it is asking. Thus, root's superpowers come from the fact that the kernel has been programmed to always permit an operation requested by the root user (UID=0).

In the case of Linux, most of the various permissions checks that happen check whether the given UID has the necessary capability. The capabilities system allows more fine grained control over who is allowed to do what.

However, in order to preserve the traditional UNIX meaning of the "root" user, a process executed with the UID of 0 has all capabilities.

Note that while processes running as UID=0 have superuser privileges they still have to make requests of the kernel via the system call interface.

Thus, a userspace process, even running as root, is still limited in what it can do as it is running in "user mode" and the kernel is running in "kernel mode" which are actually distinct modes of operation for the CPU itself. In kernel mode a process can access any memory or issue any instruction. In user mode (on x86 CPUs there are actually a number of different protected modes), a process can only access its own memory and can only issue some instructions. Thus a userspace process running as root still only has access to the kernel mode features that the kernel exposes to it.

share|improve this answer
    
Should we say that root or UID=0 has the kernel level privilege? Or are there any restrictions applied by the kernel to the root? –  Ron Vince Mar 27 at 5:45
    
Processes running as UID=0 have superuser privileges; however, they still make requests of the kernel via the system call interface. A userspace process, even running as root, is still limited in what it can do as it is running in "user mode" and the kernel is running in "kernel mode" which are actually distinct modes of operation for the CPU itself. A userspace process running as root still only has access to the kernel mode features that the kernel exposes to it. See linfo.org/kernel_mode.html for more info. –  Steven D Mar 27 at 6:00
    
I've added my commend to the answer with some links. –  Steven D Mar 27 at 6:11
    
Do you have any recommendations of Unix books? –  Ron Vince Mar 27 at 12:13
    
@RonVince If you feel you have gotten an answer to the question you asked, please tick the big question mark next to the answer to indicate such. I notice of the five questions you have asked here, all of them have at least one decent answer, but you have not accepted any answer to any question. This is A) Contra to how the site is supposed to work, B) A potential route to getting yourself ignored in the future. Thank you! –  goldilocks Mar 27 at 14:58

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