public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "russkubik at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug malloc/29283] New: assert when ptrace(PTRACE_POKEDATA) on allocated buffer
Date: Fri, 24 Jun 2022 01:26:08 +0000 [thread overview]
Message-ID: <bug-29283-131@http.sourceware.org/bugzilla/> (raw)
https://sourceware.org/bugzilla/show_bug.cgi?id=29283
Bug ID: 29283
Summary: assert when ptrace(PTRACE_POKEDATA) on allocated
buffer
Product: glibc
Version: 2.35
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: malloc
Assignee: unassigned at sourceware dot org
Reporter: russkubik at gmail dot com
Target Milestone: ---
Created attachment 14165
--> https://sourceware.org/bugzilla/attachment.cgi?id=14165&action=edit
tracer.c
I am seeing an assert when a program that is set up to ptrace a child uses
ptrace(PTRACE_POKEDATA) to modify the contents of the child process' malloc
allocated buffer.
> tracee: malloc.c:2617: sysmalloc: Assertion `(old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)' failed.
This only seems to occur if the buffer size that the tracee program requests
from malloc matches the usable size reported by malloc_usable_size.
Reproducer (x86-64 specific):
```
$ gcc -o tracee tracee.c
$ gcc -o tracer tracer.c
```
Locate the starting heap address for programs when address randomization is
disabled and provide that as an argument to the tracer program.
When requested size == malloc usable size, an assert:
```
$ BUFSIZ=72 ./tracer 0x5555555592a0 ./tracee
tracee: malloc.c:2617: sysmalloc: Assertion `(old_top == initial_top (av) &&
old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse
(old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)' failed.
$ BUFSIZ=80 ./tracer 0x5555555592a0 ./tracee
buf: 0x5555555592a0
tracee: malloc.c:2617: sysmalloc: Assertion `(old_top == initial_top (av) &&
old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse
(old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)' failed.
```
When requested size != malloc usable size (ie. we have padding at the end), all
is well:
```
$ BUFSIZ=71 ./tracer 0x5555555592a0 ./tracee
buf: 0x5555555592a0
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA000000
$ BUFSIZ=73 ./tracer 0x5555555592a0 ./tracee
buf: 0x5555555592a0
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA00
```
This does not appear to be an issue with jemalloc (used as a sanity test):
```
$ BUFSIZ=72 LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so ./tracer
0x7ffff721e000 ./tracee
buf: 0x7ffff721e000
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
```
Any insight appreciated, thx.
--
You are receiving this mail because:
You are on the CC list for the bug.
next reply other threads:[~2022-06-24 1:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-24 1:26 russkubik at gmail dot com [this message]
2022-06-24 1:26 ` [Bug malloc/29283] " russkubik at gmail dot com
2022-06-24 7:22 ` fweimer at redhat dot com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-29283-131@http.sourceware.org/bugzilla/ \
--to=sourceware-bugzilla@sourceware.org \
--cc=glibc-bugs@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).