[llvm-bugs] [Bug 43871] New: false positive: VforkChecker::isCallWhitelisted() prohibits IO-related functions, which is wrong.

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Oct 31 19:04:39 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=43871

            Bug ID: 43871
           Summary: false positive: VforkChecker::isCallWhitelisted()
                    prohibits IO-related functions, which is wrong.
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Static Analyzer
          Assignee: dcoughlin at apple.com
          Reporter: shyouhei at ruby-lang.org
                CC: dcoughlin at apple.com, llvm-bugs at lists.llvm.org

Created attachment 22757
  --> https://bugs.llvm.org/attachment.cgi?id=22757&action=edit
reproduction code

zsh % cat tmp.c
#include <sys/types.h>
#include <unistd.h>

void
test(void)
{
    pid_t p = vfork();
    if (p == 0) {
        close(STDIN_FILENO);
        execl("/bin/sh", "/bin/sh", 0);
    }
}
zsh % scan-build-10 clang-10 -c tmp.c
scan-build: Using '/usr/lib/llvm-10/bin/clang' for static analysis
tmp.c:7:15: warning: Call to function 'vfork' is insecure as it can lead to
denial of service situations in the parent process. Replace calls to vfork with
calls to the safer 'posix_spawn' function
    pid_t p = vfork();
              ^~~~~
tmp.c:9:9: warning: This function call is prohibited after a successful vfork
        close(STDIN_FILENO);
        ^~~~~~~~~~~~~~~~~~~
2 warnings generated.
scan-build: 2 bugs found.
scan-build: Run 'scan-view /tmp/scan-build-2019-11-01-104537-23752-1' to
examine bug reports.
zsh %  


This warning #2 is wrong.  AFAIK there has never been any operating system
which prohibits closing file descriptor after a successful vfork.  A file
descriptor is an in-kernel resource thus not shared among vfork parent/child.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191101/657244b6/attachment.html>


More information about the llvm-bugs mailing list