How do kernels stop programs from executing high privelige/potentially malicious instructions

Discussion in 'Computer Programming, Emulation, and Game Modding' started by StackMasher, Jan 23, 2017.

  1. StackMasher

    StackMasher GBAtemp Regular

    Nov 29, 2016
  2. Mrrraou

    Mrrraou GBAtemp Advanced Maniac

    Oct 17, 2015
    they dont
    x65943 and hobbledehoy899 like this.
  3. nero99

    nero99 GBAtemp Addict

    Sep 18, 2014
    United States
    silly OP, kernels are for popping in the microwave, not stopping code :rofl2:
    KapuDaKoopa likes this.
  4. x65943

    x65943 Dr. Rabbi Prince X, Sr., Ed. D.

    GBAtemp Patron
    x65943 is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    Jun 23, 2014
    United States
    One common method is to make user programs only run in userspace (a specific section of ram) that cannot access/execute kernel commands.
    Minnow and StackMasher like this.
  5. FAST6191

    FAST6191 Techromancer

    pip Reporter
    Nov 21, 2005
    United Kingdom
    If you want to look specifically at the x86 family then have a look at the concept called rings. You might have met it before when people speak of a ring 0 rootkit.

    Otherwise yeah would be here all day discussing security.

    Edit. Another thing that might be worth looking at.
    I recall linking a talk from possibly Defcon or Blackhat (one of the big US security/hacker conferences anyway) detailing return oriented programming, however part of the run up to that was going through the previous measures that ultimately led to ROP becoming a thing. DEP and how it failed, ASLR and how it failed and so on. I can't recall specifically which talk and ROP is a fairly hot topic among hackers which is unfortunate if you go searching but it might be worth looking for.
    Last edited by FAST6191, Jan 24, 2017
    StackMasher likes this.
  6. Futurdreamz

    Futurdreamz GBAtemp Addict

    Jun 15, 2014
    What kind of Kernel are we talking about? There are very many different types, with their own practices. Some outsource everything to subcomponents with limited access, some require all executable code to be cryptographically signed before they will be executed, and some use use an obscure and unpopular OS so nobody will want to hack it.
  7. gudenau

    gudenau Largely ignored

    GBAtemp Patron
    gudenau is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    Jul 7, 2010
    United States
    The way that it is handled is multiple CPU modes of operation, normally "supervisor" and "user".

    The CPU processes instructions differently when in the different modes, the lower the privilege level the less instructions can be executed. When the CPU attempts to execute an instruction that the current privilege mode does not have access to it throws an exception that an upper layer catches. This upper layer is normally the kernel, but can be other things depending on virtualization extensions and other low level details. From there whatever handles the exception will either terminate the process that executed it, crash or make the process think that it worked.

    It varies from architecture to architecture, but that is basically how it works.