solve/kernel_rop.c
void save_state() {
  __asm__(".intel_syntax noprefix;"
          "mov user_cs, cs;"
          "mov user_ss, ss;"
          "mov user_sp, rsp;"
          "pushf;"
          "pop user_rflags;"
          ".att_syntax;");
  printf("Saved cs, ss, rsp, rflags registers\n");
}
/*
 * When going from kernel mode to user mode
 * we need to restore the register state.
 */
When going from kernel mode to user mode
we need to restore the register state.
When going from kernel mode to user mode we need to restore the register state .
void save_state() {
  __asm__(".intel_syntax noprefix;"
          "mov user_cs, cs;"
          "mov user_ss, ss;"
          "mov user_sp, rsp;"
          "pushf;"
          "pop user_rflags;"
          ".att_syntax;");
  printf("Saved cs, ss, rsp, rflags registers\n");
}
void save_state ( ) { __asm__ ( " " " " " " " " " " " " " " ) ; printf ( " \n " ) ; }
When going from kernel mode to user mode
 we need to restore the register state.
When going from kernel mode to user mode we need to restore the register state .