public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug testsuite/26016] New: Bad mmap error check in coredump-filter.c / testsuite
@ 2020-05-20 13:10 hanno at hboeck dot de
2020-05-20 14:41 ` [Bug testsuite/26016] " simark at simark dot ca
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: hanno at hboeck dot de @ 2020-05-20 13:10 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=26016
Bug ID: 26016
Summary: Bad mmap error check in coredump-filter.c / testsuite
Product: gdb
Version: HEAD
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: testsuite
Assignee: unassigned at sourceware dot org
Reporter: hanno at hboeck dot de
Target Milestone: ---
In coredump-filter.c [1] there is this code:
void *ret = mmap (addr, size, prot, flags, fd, offset);
assert (ret != NULL);
The mmap function never returns NULL, on errors it returns MAP_FAILED (or -1).
Thus this check is wrong and should probably be "ret != MAP_FAILED".
(Sidenote: asserts usually shouldn't be used for error checking, but this may
be a design decision due to this being a test suite.)
[1]
https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdb/testsuite/gdb.base/coredump-filter.c;h=f53a933a72545741094fc9549ff4411e3741adbe;hb=HEAD
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug testsuite/26016] Bad mmap error check in coredump-filter.c / testsuite
2020-05-20 13:10 [Bug testsuite/26016] New: Bad mmap error check in coredump-filter.c / testsuite hanno at hboeck dot de
@ 2020-05-20 14:41 ` simark at simark dot ca
2020-05-20 14:42 ` simark at simark dot ca
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: simark at simark dot ca @ 2020-05-20 14:41 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=26016
Simon Marchi <simark at simark dot ca> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2020-05-20
CC| |simark at simark dot ca
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
--- Comment #1 from Simon Marchi <simark at simark dot ca> ---
Thanks for the report. Was this found using some static analysis tool, or you
just stumbled on it?
I'll also fix the spots that check against -1 to use MAP_FAILED.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug testsuite/26016] Bad mmap error check in coredump-filter.c / testsuite
2020-05-20 13:10 [Bug testsuite/26016] New: Bad mmap error check in coredump-filter.c / testsuite hanno at hboeck dot de
2020-05-20 14:41 ` [Bug testsuite/26016] " simark at simark dot ca
@ 2020-05-20 14:42 ` simark at simark dot ca
2020-05-20 14:51 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: simark at simark dot ca @ 2020-05-20 14:42 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=26016
--- Comment #2 from Simon Marchi <simark at simark dot ca> ---
(In reply to Hanno Boeck from comment #0)
> (Sidenote: asserts usually shouldn't be used for error checking, but this
> may be a design decision due to this being a test suite.)
For test programs I think it's fine.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug testsuite/26016] Bad mmap error check in coredump-filter.c / testsuite
2020-05-20 13:10 [Bug testsuite/26016] New: Bad mmap error check in coredump-filter.c / testsuite hanno at hboeck dot de
2020-05-20 14:41 ` [Bug testsuite/26016] " simark at simark dot ca
2020-05-20 14:42 ` simark at simark dot ca
@ 2020-05-20 14:51 ` cvs-commit at gcc dot gnu.org
2020-05-20 14:54 ` hanno at hboeck dot de
2020-05-20 14:55 ` simark at simark dot ca
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-05-20 14:51 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=26016
--- Comment #3 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Simon Marchi <simark@sourceware.org>:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=41977d16e4ee5b9ad01abf2cfce6edbfb6d79541
commit 41977d16e4ee5b9ad01abf2cfce6edbfb6d79541
Author: Simon Marchi <simon.marchi@efficios.com>
Date: Wed May 20 10:50:39 2020 -0400
gdb/testsuite: check mmap ret val against MAP_FAILED
Fixup a few spots in the testsuite that use mmap to consistently check
the return value against MAP_FAILED.
One spot in gdb.base/coredump-filter.c checked against NULL, that is
wrong. The other spots either didn't check, or checked against -1.
MAP_FAILED has the value -1, at least on Linux, but it's better to check
against the documented define.
gdb/testsuite/ChangeLog:
PR gdb/26016
* gdb.base/coredump-filter.c (do_mmap): Check mmap ret val
against MAP_FAILED.
* gdb.base/coremaker.c (mmapdata): Likewise.
* gdb.base/jit-reader-host.c (main): Likewise.
* gdb.base/sym-file-loader.c (load): Likewise.
(load_shlib): Likewise.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug testsuite/26016] Bad mmap error check in coredump-filter.c / testsuite
2020-05-20 13:10 [Bug testsuite/26016] New: Bad mmap error check in coredump-filter.c / testsuite hanno at hboeck dot de
` (2 preceding siblings ...)
2020-05-20 14:51 ` cvs-commit at gcc dot gnu.org
@ 2020-05-20 14:54 ` hanno at hboeck dot de
2020-05-20 14:55 ` simark at simark dot ca
4 siblings, 0 replies; 6+ messages in thread
From: hanno at hboeck dot de @ 2020-05-20 14:54 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=26016
--- Comment #4 from Hanno Boeck <hanno at hboeck dot de> ---
(In reply to Simon Marchi from comment #1)
> Thanks for the report. Was this found using some static analysis tool, or
> you just stumbled on it?
So this is a very good question and the answer may surprise you :-)
I learned about this type of bug and I thought "I can write a trivial
shellscript to find these kinds of bugs". So if my 6 lines of bash count as a
static analysis tool then yes.
I plan to release it soon, I'll post a link.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug testsuite/26016] Bad mmap error check in coredump-filter.c / testsuite
2020-05-20 13:10 [Bug testsuite/26016] New: Bad mmap error check in coredump-filter.c / testsuite hanno at hboeck dot de
` (3 preceding siblings ...)
2020-05-20 14:54 ` hanno at hboeck dot de
@ 2020-05-20 14:55 ` simark at simark dot ca
4 siblings, 0 replies; 6+ messages in thread
From: simark at simark dot ca @ 2020-05-20 14:55 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=26016
Simon Marchi <simark at simark dot ca> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #5 from Simon Marchi <simark at simark dot ca> ---
Well, it worked well enough to find one bug, thanks!
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-05-20 14:55 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-20 13:10 [Bug testsuite/26016] New: Bad mmap error check in coredump-filter.c / testsuite hanno at hboeck dot de
2020-05-20 14:41 ` [Bug testsuite/26016] " simark at simark dot ca
2020-05-20 14:42 ` simark at simark dot ca
2020-05-20 14:51 ` cvs-commit at gcc dot gnu.org
2020-05-20 14:54 ` hanno at hboeck dot de
2020-05-20 14:55 ` simark at simark dot ca
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).