[PATCH] tests/pc: try to avoid creating a coredump
Renaud Métrich
rmetrich at redhat.com
Tue Oct 12 08:40:10 UTC 2021
Indeed, disabling coredump completely is better.
New patch attached.
On 10/12/21 01:42, Dmitry V. Levin wrote:
> On Wed, Oct 06, 2021 at 08:29:27PM +0200, Renaud Métrich wrote:
>> The small patch attached tries to avoid having the SEGV signal create a
>> coredump which is then stored in /var/lib/systemd/coredump/ directory on
>> systemd enabled systems.
>>
>> Also available as a PR: https://github.com/strace/strace/pull/196
>>
>> The code coverage indicates a false positive since the patch only deals
>> with tests/ directory, not src/, hence IMHO it's not possible that
>> src/pidns.c gets affected or I'm missing something here.
>>
>>
>> Renaud.
>>
>> From f4050e08e6abd406ad6cdef912dc962f31686de2 Mon Sep 17 00:00:00 2001
>> From: =?UTF-8?q?Renaud=20M=C3=A9trich?= <rmetrich at redhat.com>
>> Date: Wed, 6 Oct 2021 16:07:15 +0200
>> Subject: [PATCH] tests/pc: avoid program from creating a coredump
>>
>> ---
>> tests/pc.c | 6 ++++++
>> 1 file changed, 6 insertions(+)
>>
>> diff --git a/tests/pc.c b/tests/pc.c
>> index 342169f5d..0ffefa771 100644
>> --- a/tests/pc.c
>> +++ b/tests/pc.c
>> @@ -14,6 +14,8 @@
>> #include <sys/mman.h>
>> #include <sys/wait.h>
>> #include <sys/sendfile.h>
>> +#include <sys/time.h>
>> +#include <sys/resource.h>
>>
>> int main(void)
>> {
>> @@ -27,6 +29,10 @@ int main(void)
>> error_msg_and_skip("s390: si_addr is unreliable");
>> #endif
>>
>> + /* Avoid creating core dumps for real, if possible */
>> + struct rlimit rlim = { 0 };
>> + (void) setrlimit(RLIMIT_CORE, &rlim);
>> +
>> /* write instruction pointer length to the log */
>> assert(syscall(__NR_write, -1, (void *) 8UL, 2 * sizeof(void *)) < 0);
>>
> I don't think <sys/time.h> is needed here, and this still allows dumping
> core e.g. to pipes. Wouldn't we better off clearing the dumpable attribute
> by invoking PR_SET_DUMPABLE right before raising SIGSEGV?
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-tests-pc-avoid-program-from-creating-a-coredump.patch
Type: text/x-patch
Size: 795 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20211012/90c66f9c/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20211012/90c66f9c/attachment-0001.bin>
More information about the Strace-devel
mailing list