Is kernel mode of operating system and root permissions in android same thing?


Question

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 ?


Answer

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.


Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes