Bug 641124

Summary: memmem, strstr, and strcasestr are broken
Product: [Fedora] Fedora Reporter: Eric Blake <eblake>
Component: glibcAssignee: Andreas Schwab <schwab>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 13CC: fweimer, jakub, kparal, schwab
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: glibc-2.12.1-3 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 641128 (view as bug list) Environment:
Last Closed: 2010-10-19 22:22:47 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 641128    

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.