Projects STRLCPY criu Commits ce437d3d
🤬
  • x86/kdat: Check PTRACE_TRACEME return value

    Coverity has informed:
    
    *** CID 188251:  Error handling issues  (CHECKED_RETURN)
    /criu/arch/x86/crtools.c: 196 in kdat_x86_has_ptrace_fpu_xsave_bug_child()
    190             return 0;
    191     }
    192     #endif
    193
    194     static int kdat_x86_has_ptrace_fpu_xsave_bug_child(void *arg)
    195     {
    >>>     CID 188251:  Error handling issues  (CHECKED_RETURN)
    >>>     Calling "ptrace" without checking return value (as is done elsewhere 46 out of 51 times).
    196             ptrace(PTRACE_TRACEME, 0, 0, 0);
    197             kill(getpid(), SIGSTOP);
    198             pr_err("Continue after SIGSTOP.. Urr what?\n");
    199             _exit(1);
    200     }
    201
    
    Also added checks for kill() and waitpid().
    
    Signed-off-by: Dmitry Safonov <[email protected]>
    Signed-off-by: Andrei Vagin <[email protected]>
  • Loading...
  • Dmitry Safonov committed with Andrei Vagin 6 years ago
    ce437d3d
    1 parent b2473542
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■
    criu/arch/x86/kerndat.c
    skipped 177 lines
    178 178   
    179 179  static int kdat_x86_has_ptrace_fpu_xsave_bug_child(void *arg)
    180 180  {
    181  - ptrace(PTRACE_TRACEME, 0, 0, 0);
    182  - kill(getpid(), SIGSTOP);
     181 + if (ptrace(PTRACE_TRACEME, 0, 0, 0)) {
     182 + pr_perror("%d: ptrace(PTRACE_TRACEME) failed", getpid());
     183 + _exit(1);
     184 + }
     185 + 
     186 + if (kill(getpid(), SIGSTOP))
     187 + pr_perror("%d: failed to kill myself", getpid());
     188 + 
    183 189   pr_err("Continue after SIGSTOP.. Urr what?\n");
    184 190   _exit(1);
    185 191  }
    skipped 57 lines
    243 249   ret = !xsave.i387.mxcsr;
    244 250   
    245 251  out_kill:
    246  - kill(child, SIGKILL);
    247  - waitpid(child, &stat, 0);
     252 + if (kill(child, SIGKILL))
     253 + pr_perror("Failed to kill my own child");
     254 + if (waitpid(child, &stat, 0) < 0)
     255 + pr_perror("Failed wait for a dead child");
     256 + 
    248 257   return ret;
    249 258  }
    250 259   
Please wait...
Page is in error, reload to recover