public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "slyfox at inbox dot ru" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug libc/16004] New: memcpy/strcpy: detect memory overlap and crash when error is detected
Date: Sat, 05 Oct 2013 11:29:00 -0000	[thread overview]
Message-ID: <bug-16004-131@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=16004

            Bug ID: 16004
           Summary: memcpy/strcpy: detect memory overlap and crash when
                    error is detected
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: slyfox at inbox dot ru
                CC: drepper.fsp at gmail dot com

Recently amount of bugs regarding to memcpy() copy ordering grown.
I guess it's due to new memcpy@GLIBC_2.14 on new CPUs.

What scary is bugs are always data corruptions and almost never
immediate application crashes (usually seen way later, that in
actual memcpy call). Thus they live very long time unnoticed.

Sometimes bug exhibits only on a subset of hardware (on core i7,
but not core2, same libc) or even oncertain heap. I guess it's
due to different semantics of memcpy IFUNC implelentations
on different host CPUs (depend on linear address alignment).

I'd like to ask to put memory overlap checking right into:
- memcpy implementations themselves before calling assembly implementation
- if above is too heavyweight, then do it only in _FORTIFY_SOURCE mode
- if above is too heavyweight, then add some variable/knob to allow
  putting slow checky memcpy at IFUNC startup time.

Same goes for strcpy. Sometimes people do silly things, like
    strcpy (some_str, some_str + strlen ("pref"));
and get data corruption.

Thank you!

Some data corruptions I've found myself:
  https://bugs.gentoo.org/show_bug.cgi?id=486984 - aircrack-ng's packet parsers
bug with memcpy to move packes for some bytes.
 
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=3387206f26e1b48703e810175b98611a4fd8e8ea
- filesystem corruption bug. It's a kernel patch, but usermode linux can be
forced to use libc's memcpy to find such bugs easier.
 
https://github.com/MidnightCommander/mc/commit/e48cb7c89ff3e54de70130a3de2136a9902a023d
- occasional data corruption of final filepaths

-- 
You are receiving this mail because:
You are on the CC list for the bug.


             reply	other threads:[~2013-10-05 11:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-05 11:29 slyfox at inbox dot ru [this message]
2013-10-09  7:52 ` [Bug libc/16004] " neleai at seznam dot cz
2014-06-13 12:41 ` fweimer at redhat dot com
2014-06-23  3:11 ` allachan at au1 dot ibm.com
2014-06-23  7:19 ` slyfox at inbox dot ru
2014-06-24  8:30 ` fweimer at redhat dot com
2015-08-27 22:17 ` [Bug string/16004] " jsm28 at gcc dot gnu.org
2024-03-01  7:43 ` sam at gentoo dot org

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-16004-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).