Bug 641124 - memmem, strstr, and strcasestr are broken
Summary: memmem, strstr, and strcasestr are broken
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: glibc
Version: 13
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Andreas Schwab
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 641128
TreeView+ depends on / blocked
 
Reported: 2010-10-07 19:26 UTC by Eric Blake
Modified: 2016-11-24 15:51 UTC (History)
4 users (show)

Fixed In Version: glibc-2.12.1-3
Clone Of:
: 641128 (view as bug list)
Environment:
Last Closed: 2010-10-19 22:22:47 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Eric Blake 2010-10-07 19:26:29 UTC
Description of problem:
glibc 2.9 through 2.12 have a bug in string searching algorithms which was just recently fixed upstream (note that glibc 2.11 introduced a replacement strstr for SSE4.2 platforms that avoids the bug on strstr and strcasestr, but at the expense of using a quadratic implementation instead of a linear version).  Since this bug can be triggered in any number of other packages, the upstream patch should be backported into the Fedora version of glibc.  http://sourceware.org/bugzilla/show_bug.cgi?id=12092

Version-Release number of selected component (if applicable):
glibc-2.12.1-2.x86_64
glibc-2.12.1-2.i686

How reproducible:
100% reproducible on problematic search patterns.  However, a machine with SSE4.2 hides the problem unless you use memmem.  Also, the problematic search patterns are not necessarily typical searches: the needle has to be periodic and at least 32 bytes, and the haystack has to match in most but not all of the periods of the needle to trigger the false positive match; so packages that use strstr() on hard-coded needles rather than on arbitrary user input are most likely immune.

Steps to Reproduce:
1. This demonstrates an example of existing packages that use strstr() on arbitrary input, and uses a shorter input string than the one listed in the glibc bug report.  First, validate that this machine is not using SSE4.2:
grep sse4_2 /proc/cpuinfo | wc -l
2. echo 'index(
;:11-:12-:12-:12-:12-:12-:12-:12-:12.:12.:12.:12.:12.:12.:12.:12.:12-,
:12-:12-:12-:12-:12-:12-:12-:12-)' | m4
  
Actual results:
1. 0
2. 37

Expected results:
1. 0
2.-1

Additional info:

Comment 1 Fedora Update System 2010-10-14 12:03:55 UTC
glibc-2.12.90-16 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/glibc-2.12.90-16

Comment 2 Fedora Update System 2010-10-14 13:51:43 UTC
glibc-2.12.90-16 has been pushed to the Fedora 14 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update glibc'.  You can provide feedback for this update here: https://admin.fedoraproject.org/updates/glibc-2.12.90-16

Comment 3 Fedora Update System 2010-10-19 14:44:30 UTC
glibc-2.12.1-3 has been submitted as an update for Fedora 13.
https://admin.fedoraproject.org/updates/glibc-2.12.1-3

Comment 4 Kamil Páral 2010-10-19 17:33:09 UTC
Verified with https://admin.fedoraproject.org/updates/glibc-2.12.90-17

Comment 5 Fedora Update System 2010-10-19 22:22:25 UTC
glibc-2.12.90-17 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 6 Fedora Update System 2010-10-22 18:07:35 UTC
glibc-2.12.1-3 has been pushed to the Fedora 13 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.