5

As written in book of Peter Baer Galvin's Operating System Concepts , there are two modes of operation -

1.user mode
2.kernel mode

So, my question is when we root our android do we alter the linux kernel to get permissions of kernel mode ?

  • A root user can use all the system calls provided by the kernel (API) without any restrictions, whereas by running in kernel mode, kernel can literally do anything, from bit-level operations to direct control of hardware and memory.. – Gokul NC Aug 31 '16 at 16:23
14

Root permissions and kernel mode are not the same thing. Programs with root access can access part of the kernel, but root is not the kernel itself.

The Android (and Linux) user model has a set of users, each part of a set of groups. These groups are used to manage which users are allowed access to what. For example, in Linux you could set up all printer devices to be owned by the printing group, so only users that are part of the printing group can access printers.

In Android every app gets its own user account to prevent apps from accessing each others data.

Amongst all of these users, there's one special user: root. This is the user with the highest set of permissions, also called the "super user". Basically, all permission checks are disabled for this user. Root can do things like change ownership of files, add users to groups, manage system components and more.

Kernel mode is slightly different. When a Linux-based system boots, the kernel is the first thing loaded by the bootloader. The kernel takes care of processing system commands ("write byte x to file y", "list all devices attached to the USB bus"). It's also where many drivers reside, which help the system understand how to communicate to a device.

After initializing the kernel starts a program in user mode. Programs running in this mode are not allowed direct memory access to devices, they can't modify page tables, basically they can't do anything the kernel is supposed to do. The only way to execute a system command is to go though the kernel, and the kernel decides whether or not a program is allowed to do so.

In Android, the kernel starts an initialization program that in turn starts some background processes and the Android system you can interact with.

The kernel decides what user is allowed to execute certain system functions. Many system functions, such as mounting a partition to make it writable, are only accessible to programs running as root. Root can contact and control the kernel, but in the end the kernel decides what root can and can not do.

So: generally kernel mode refers to code running inside the kernel, while root refers to the permissions a program has.

For the sake of clarity I'm ignoring tools like SELinux which is designed to limit the files programs running as root can access. This is a security measure so that even if a system program running as root gets exploited and starts executing code from hackers, it can't compromise the system. This is done using a special module in the kernel.

  • 1
    One way to think about this is that kernel mode is a mode which can do anything that the CPU permits. Code running as root is not in kernel mode, but instead is running in a mode which the kernel permits to do just about anything. A kernel module could change what root can run, but root cannot change what the kernel can do (unless the kernel lets root make such a change) – Cort Ammon - Reinstate Monica Aug 31 '16 at 21:33
0

When you root, your granting full permissions to the device. You already utilize the kernel(drivers, commands) so root is allowing for you to modify the entire system(add users, modify system files). My answer is extremely simple, other answer explores the same thing.

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.