Skip to content

File system capabilities break leak sanitizer #55944

Open
@wintersteiger

Description

@wintersteiger

Not sure whether this is an actual bug or just an unexpected consequence, but it would be good to get an experts opinion:

When I use setcap to give my binary permission to bind to privileged ports, the leak sanitizer throws a fatal error.

For example:

$ cat setcapleakchk.cpp
int main() { return 1; }

$ clang++-15 -o setcapleakchk setcapleakchk.cpp -fsanitize=leak
$ sudo setcap CAP_NET_BIND_SERVICE=+eip setcapleakchk
$ ./setcapleakchk
==2203001==LeakSanitizer has encountered a fatal error.
==2203001==HINT: For debugging, try setting environment variable LSAN_OPTIONS=verbosity=1:log_threads=1
==2203001==HINT: LeakSanitizer does not work under ptrace (strace, gdb, etc)

The suggested environment variable settings make no difference and it works as intended without the setcap command. Tested with clang 10 and 15:

$ clang++-10 --version
clang version 10.0.0-4ubuntu1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

$ clang++-15 --version
Ubuntu clang version 15.0.0-++20220530092253+14cc4674bf5a-1~exp1~20220530092306.267
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions