From 6efb555132586352958e2d91bc6ec06444ac7c3d Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Mon, 31 Jul 2017 16:16:02 +0200 Subject: crash on dlopen --- README | 5 ++++- fail.1 | 7 +++++++ fail.c | 14 ++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/README b/README index c0ab3f2..025f93e 100644 --- a/README +++ b/README @@ -10,6 +10,9 @@ DESCRIPTION fail crashes in various possible ways to help you debug how other software reacts to this. + In addition to the crashes below, fail will also cause a segmentation + fault when its binary is loaded using dlopen(3) or LD_PRELOAD. + The options are as follows: -1 Return with exit status -1. @@ -54,6 +57,6 @@ LICENSE To the extent possible under law, the creator of this work has waived all copyright and related or neighboring rights to this work. - http://creativecommons.org/publicdomain/zero/1.0/ + http://creativecommons.org/publicdomain/zero/1.0/ Void Linux July 14, 2017 Void Linux diff --git a/fail.1 b/fail.1 index c47fbd5..c5af510 100644 --- a/fail.1 +++ b/fail.1 @@ -12,6 +12,13 @@ crashes in various possible ways to help you debug how other software reacts to this. .Pp +In addition to the crashes below, +.Nm +will also cause a segmentation fault when its binary is loaded using +.Xr dlopen 3 +or +.Ev LD_PRELOAD . +.Pp The options are as follows: .Bl -tag -width Ds .It Fl 1 diff --git a/fail.c b/fail.c index a08253a..90f6cb7 100644 --- a/fail.c +++ b/fail.c @@ -2,6 +2,7 @@ #include +#include #include #include #include @@ -20,6 +21,19 @@ segfault() *nullp = 42; } +void _start(); + +__attribute__((__constructor__)) +void +dlcrash() +{ + volatile int *nullp = 0; + + // don't trigger if we are executed as a program + if (getauxval(AT_ENTRY) != (unsigned long)_start) + *nullp = 1337; +} + // can lockup your machine void oom() -- cgit 1.4.1