Re: Re: PROPOSAL: make PostgreSQL sanitizers-friendly (and prevent information disclosure)

From: Aleksander Alekseev <a(dot)alekseev(at)postgrespro(dot)ru>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Noah Misch <noah(at)leadboat(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Piotr Stefaniak <postgres(at)piotr-stefaniak(dot)me>, Chapman Flack <chap(at)anastigmatix(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Re: PROPOSAL: make PostgreSQL sanitizers-friendly (and prevent information disclosure)
Date: 2016-09-02 15:49:17
Message-ID: 20160902154917.GD83966@e733
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> I'll mark this as "returned with feedback". I'd be happy to take a patch
> that helps to reduce sanitizer complaints, but this seems to need some work.
>
> Aleksander, how did you run the sanitizer? I tried to build with clang
> 4.0, with the -fsanitize=memory option, and ran "make
> installcheck-parallel", but I didn't get any sanitizer errors out of it.
> I did get some errors, from failing to load "regress.so", though:
>
> ERROR: could not load library
> "/home/heikki/git-sandbox-pgsql/master/src/test/regress/regress.so":
> /home/heikki/git-sandbox-pgsql/master/src/test/regress/regress.so:
> undefined symbol: __msan_va_arg_overflow_size_tls
>
> How did you do it?

It's quite simple actually [1][2]. I've just re-checked on Ubuntu 16.04
and Clang 3.8:

```
sudo apt-get install clang git make flex bison libreadline-dev \
zlib1g-dev jade
git clone http://git.postgresql.org/git/postgresql.git
cd postgresql
CC=/usr/bin/clang CFLAGS="-fsanitize=memory -fPIE -pie" ./configure
make -j4 -s
MSAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer-3.8 make check
```

Stacktraces are written to src/test/regress/log/initdb.log.

You can add `printf("%d\n", getpid())` and `sleep(1000)` calls somewhere
in main() procedure. It will give you some time to connect using debugger.
IIRC it's what I did.

[1] http://clang.llvm.org/docs/MemorySanitizer.html
[2] https://github.com/google/sanitizers/wiki/MemorySanitizer

--
Best regards,
Aleksander Alekseev

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andy Grundman 2016-09-02 15:55:31 PATCH: Avoid use of __attribute__ when building with old Sun compiler versions
Previous Message Magnus Hagander 2016-09-02 15:42:49 Re: pg_basebackup, pg_receivexlog and data durability (was: silent data loss with ext4 / all current versions)