Bug 23631 - strstr testing is inadequate
Summary: strstr testing is inadequate
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: string (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-09-11 15:19 UTC by Paul Pluzhnikov
Modified: 2023-11-02 18:05 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Pluzhnikov 2018-09-11 15:19:59 UTC
strstr function regularly gets broken:

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

https://sourceware.org/ml/libc-help/2018-09/msg00000.html

AFAICT, we only test it using the current IFUNC-selected version, and only on a very small set of inputs.

I think we need a stress-test for it.
I'll take a stab at writing one.
Comment 1 Paul Pluzhnikov 2018-09-11 20:43:31 UTC
Likewise for memmem.
Comment 2 Carlos O'Donell 2023-11-02 18:05:34 UTC
We test all the possible IFUNC implementations with FOR_EACH_IMPL.

Improved significantly with:

commit bfdb731438206b0f70fe7afa890681155c30b419
Author: Stefan Liebler <stli@linux.ibm.com>
Date:   Wed Nov 27 12:35:40 2019 +0100

    S390: Fix handling of needles crossing a page in strstr z15 ifunc-variant. [BZ #25226]
    
    If the specified needle crosses a page-boundary, the s390-z15 ifunc variant of
    strstr truncates the needle which results in invalid results.
    
    This is fixed by loading the needle beyond the page boundary to v18 instead of v16.
    The bug is sometimes observable in test-strstr.c in check1 and check2 as the
    haystack and needle is stored on stack. Thus the needle can be on a page boundary.
    
    check2 is now extended to test haystack / needles located on stack, at end of page
    and on two pages.
    
    This bug was introduced with commit 6f47401bd5fc71209219779a0426170a9a7395b0
    ("S390: Add arch13 strstr ifunc variant.") and is already released in glibc 2.30.