简体   繁体   English

从exec系统调用返回时使用iret

[英]Use of iret when returning from exec system call

I noticed that at the end of the start_thread function, which is called after most of the work of exec is done, there is a call to force_iret : 我注意到在exec大部分工作完成后调用的start_thread函数的末尾,有一个对force_iret的调用:

    static void
    start_thread_common(struct pt_regs *regs, unsigned long new_ip,
        unsigned long new_sp,
        unsigned int _cs, unsigned int _ss, unsigned int _ds)
    {
         loadsegment(fs, 0);
         loadsegment(es, _ds);
         loadsegment(ds, _ds);
         load_gs_index(0);
         regs->ip       = new_ip;
         regs->sp       = new_sp;
         regs->cs       = _cs;
         regs->ss       = _ss;
         regs->flags        = X86_EFLAGS_IF;
         force_iret();
    }    

I presume that this is done to ensure that that sysexit is not used to return to user space. 我认为这样做是为了确保不使用sysexit返回用户空间。 So why does iret have to be used when returning from exec ? 那么,为什么从exec返回时必须使用iret呢?

This function modifies registers that sysret / sysexit would not restore. 该函数修改了sysret / sysexit无法恢复的寄存器。

Here's arch/x86/include/asm/thread_info.h : 这是arch/x86/include/asm/thread_info.h

/*
 * Force syscall return via IRET by making it look as if there was
 * some work pending. IRET is our most capable (but slowest) syscall
 * return path, which is able to restore modified SS, CS and certain
 * EFLAGS values that other (fast) syscall return instructions
 * are not able to restore properly.
 */
#define force_iret() set_thread_flag(TIF_NOTIFY_RESUME)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 exec 系统调用中运行别名命令 - Run alias command in exec system call 在fork之后的exec系统调用中调度策略 - Scheduling Policy in an exec system call after a fork 就呼叫返回行为而言,fork()和exec()系统调用与其他系统调用有何不同? - In terms of call-return behaviour, how are the fork() and exec() system calls different from other system calls? fork-exec易于使用system() - fork-exec with ease of use of system() 当我用C语言用char数组发送命令时,system()调用或exec()函数不起作用 - system() call or exec() functions not working when i send command with char array in c language 从关联的函数返回后,克隆系统调用退出 - Clone system call exits after returning from its associated function 它应该在c中的exec函数不返回-1 - Exec function in c is not returning -1 when it should 在C中将系统的使用更改为Fork和exec - Changing the use of system to Fork and exec in C 如何将 exec() 系统调用的 output 从 stdout 重定向到 pipe 并将结果从父进程读入缓冲区? - How can I redirect the output of an exec() system call from stdout to a pipe and read the result into a buffer from the parent process? 当我从Julia代码调用它时,midiOutOpen返回未知错误 - midiOutOpen is returning an unknown error when I call it from Julia code
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM