Bug 28755 - overflow bug in wcsncmp_avx2 and wcsncmp_evex
Summary: overflow bug in wcsncmp_avx2 and wcsncmp_evex
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: string (show other bugs)
Version: 2.34
: P2 normal
Target Milestone: 2.35
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-09 10:30 UTC by Noah Goldstein
Modified: 2022-02-17 19:52 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Noah Goldstein 2022-01-09 10:30:11 UTC
Similiar to [BZ 27974](https://sourceware.org/bugzilla/show_bug.cgi?id=27974). The multiply of length by sizeof (wchar_t) can overflow if length is >= 2^62 which can lead to incorrect results.

For example:

#include <wchar.h>
int
main(int argc, char ** argv) {
    assert(__wcsncmp_evex(L"abc", L"abd", (1UL << 62)) != 0);
    assert(__wcsncmp_avx2(L"abc", L"abd", (1UL << 62)) != 0);
}

Will fail on either assert.
Comment 2 Noah Goldstein 2022-01-11 03:07:10 UTC
Fixed in

commit ddf0992cf57a93200e0c782e2a94d0733a5a0b87
Author: Noah Goldstein <goldstein.w.n@gmail.com>
Date:   Sun Jan 9 16:02:21 2022 -0600

    x86: Fix __wcsncmp_avx2 in strcmp-avx2.S [BZ# 28755]


and 


commit 7e08db3359c86c94918feb33a1182cd0ff3bb10b
Author: Noah Goldstein <goldstein.w.n@gmail.com>
Date:   Sun Jan 9 16:02:28 2022 -0600

    x86: Fix __wcsncmp_evex in strcmp-evex.S [BZ# 28755]
Comment 3 Sourceware Commits 2022-01-27 04:24:21 UTC
The release/2.34/master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=72123e1b56f53f9205bb105f8a62d0869b837b22

commit 72123e1b56f53f9205bb105f8a62d0869b837b22
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Jan 26 20:20:43 2022 -0800

    NEWS: Add a bug entry for BZ #28755
Comment 4 Sourceware Commits 2022-01-27 04:58:21 UTC
The release/2.33/master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=86c153d0922a6da3263f0ade42573bd405d8edee

commit 86c153d0922a6da3263f0ade42573bd405d8edee
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Jan 26 20:28:51 2022 -0800

    NEWS: Add a bug fix entry for BZ #28755
Comment 5 Sourceware Commits 2022-01-27 13:14:16 UTC
The release/2.32/master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=40eebb02ccbc2d621e796795d5994fe7483b679f

commit 40eebb02ccbc2d621e796795d5994fe7483b679f
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Jan 26 21:00:25 2022 -0800

    NEWS: Add a bug fix entry for BZ #28755
Comment 6 Sourceware Commits 2022-01-27 13:29:52 UTC
The release/2.31/master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=5b136510856f3742b58eb5e2de0cada7e9e95630

commit 5b136510856f3742b58eb5e2de0cada7e9e95630
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Jan 27 05:16:30 2022 -0800

    NEWS: Add a bug fix entry for BZ #28755
Comment 7 Sourceware Commits 2022-01-27 13:33:11 UTC
The release/2.30/master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=9d868841f870c22c05e5ce11900afc9abd8fda02

commit 9d868841f870c22c05e5ce11900afc9abd8fda02
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Jan 27 05:31:02 2022 -0800

    NEWS: Add a bug fix entry for BZ #28755
Comment 8 Sourceware Commits 2022-01-27 15:28:52 UTC
The release/2.29/master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=2f3fb944b311b67e609ed79478cc1737f6066af9

commit 2f3fb944b311b67e609ed79478cc1737f6066af9
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Jan 27 05:34:02 2022 -0800

    NEWS: Add a bug fix entry for BZ #28755
Comment 9 Sourceware Commits 2022-01-27 16:12:47 UTC
The release/2.28/master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=43c27a754bd417726032006d0a564d946994554e

commit 43c27a754bd417726032006d0a564d946994554e
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Jan 27 07:30:10 2022 -0800

    NEWS: Add a bug fix entry for BZ #28755
Comment 10 H.J. Lu 2022-01-27 16:14:25 UTC
Fixed for 2.35 and all release branches.
Comment 11 Sourceware Commits 2022-02-17 19:04:57 UTC
The master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=aa5a720056d37cf24924c138a3dbe6dace98e97c

commit aa5a720056d37cf24924c138a3dbe6dace98e97c
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Feb 17 08:10:35 2022 -0800

    string: Add a testcase for wcsncmp with SIZE_MAX [BZ #28755]
    
    Verify that wcsncmp (L("abc"), L("abd"), SIZE_MAX) == 0.  The new test
    fails without
    
    commit ddf0992cf57a93200e0c782e2a94d0733a5a0b87
    Author: Noah Goldstein <goldstein.w.n@gmail.com>
    Date:   Sun Jan 9 16:02:21 2022 -0600
    
        x86: Fix __wcsncmp_avx2 in strcmp-avx2.S [BZ# 28755]
    
    and
    
    commit 7e08db3359c86c94918feb33a1182cd0ff3bb10b
    Author: Noah Goldstein <goldstein.w.n@gmail.com>
    Date:   Sun Jan 9 16:02:28 2022 -0600
    
        x86: Fix __wcsncmp_evex in strcmp-evex.S [BZ# 28755]
    
    This is for BZ #28755.
    
    Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com>
Comment 12 Sourceware Commits 2022-02-17 19:14:13 UTC
The release/2.35/master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=a30807b7db924d31681e9c6e98e78f2f46a2640c

commit a30807b7db924d31681e9c6e98e78f2f46a2640c
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Feb 17 08:10:35 2022 -0800

    string: Add a testcase for wcsncmp with SIZE_MAX [BZ #28755]
    
    Verify that wcsncmp (L("abc"), L("abd"), SIZE_MAX) == 0.  The new test
    fails without
    
    commit ddf0992cf57a93200e0c782e2a94d0733a5a0b87
    Author: Noah Goldstein <goldstein.w.n@gmail.com>
    Date:   Sun Jan 9 16:02:21 2022 -0600
    
        x86: Fix __wcsncmp_avx2 in strcmp-avx2.S [BZ# 28755]
    
    and
    
    commit 7e08db3359c86c94918feb33a1182cd0ff3bb10b
    Author: Noah Goldstein <goldstein.w.n@gmail.com>
    Date:   Sun Jan 9 16:02:28 2022 -0600
    
        x86: Fix __wcsncmp_evex in strcmp-evex.S [BZ# 28755]
    
    This is for BZ #28755.
    
    Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com>
    
    (cherry picked from commit aa5a720056d37cf24924c138a3dbe6dace98e97c)
Comment 13 Sourceware Commits 2022-02-17 19:22:33 UTC
The release/2.34/master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=04d60ce0f21ffe2a4add148cb37a1942dbad64e2

commit 04d60ce0f21ffe2a4add148cb37a1942dbad64e2
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Feb 17 08:10:35 2022 -0800

    string: Add a testcase for wcsncmp with SIZE_MAX [BZ #28755]
    
    Verify that wcsncmp (L("abc"), L("abd"), SIZE_MAX) == 0.  The new test
    fails without
    
    commit ddf0992cf57a93200e0c782e2a94d0733a5a0b87
    Author: Noah Goldstein <goldstein.w.n@gmail.com>
    Date:   Sun Jan 9 16:02:21 2022 -0600
    
        x86: Fix __wcsncmp_avx2 in strcmp-avx2.S [BZ# 28755]
    
    and
    
    commit 7e08db3359c86c94918feb33a1182cd0ff3bb10b
    Author: Noah Goldstein <goldstein.w.n@gmail.com>
    Date:   Sun Jan 9 16:02:28 2022 -0600
    
        x86: Fix __wcsncmp_evex in strcmp-evex.S [BZ# 28755]
    
    This is for BZ #28755.
    
    Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com>
    
    (cherry picked from commit aa5a720056d37cf24924c138a3dbe6dace98e97c)
Comment 14 Sourceware Commits 2022-02-17 19:27:21 UTC
The release/2.33/master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=cb922428dc7c5260ea84de482ffe05d2ea766199

commit cb922428dc7c5260ea84de482ffe05d2ea766199
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Feb 17 08:10:35 2022 -0800

    string: Add a testcase for wcsncmp with SIZE_MAX [BZ #28755]
    
    Verify that wcsncmp (L("abc"), L("abd"), SIZE_MAX) == 0.  The new test
    fails without
    
    commit ddf0992cf57a93200e0c782e2a94d0733a5a0b87
    Author: Noah Goldstein <goldstein.w.n@gmail.com>
    Date:   Sun Jan 9 16:02:21 2022 -0600
    
        x86: Fix __wcsncmp_avx2 in strcmp-avx2.S [BZ# 28755]
    
    and
    
    commit 7e08db3359c86c94918feb33a1182cd0ff3bb10b
    Author: Noah Goldstein <goldstein.w.n@gmail.com>
    Date:   Sun Jan 9 16:02:28 2022 -0600
    
        x86: Fix __wcsncmp_evex in strcmp-evex.S [BZ# 28755]
    
    This is for BZ #28755.
    
    Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com>
    
    (cherry picked from commit aa5a720056d37cf24924c138a3dbe6dace98e97c)
Comment 15 Sourceware Commits 2022-02-17 19:32:31 UTC
The release/2.32/master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=0f8a2390000c4e9a152b5f6cf8220f2560c01e74

commit 0f8a2390000c4e9a152b5f6cf8220f2560c01e74
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Feb 17 08:10:35 2022 -0800

    string: Add a testcase for wcsncmp with SIZE_MAX [BZ #28755]
    
    Verify that wcsncmp (L("abc"), L("abd"), SIZE_MAX) == 0.  The new test
    fails without
    
    commit ddf0992cf57a93200e0c782e2a94d0733a5a0b87
    Author: Noah Goldstein <goldstein.w.n@gmail.com>
    Date:   Sun Jan 9 16:02:21 2022 -0600
    
        x86: Fix __wcsncmp_avx2 in strcmp-avx2.S [BZ# 28755]
    
    and
    
    commit 7e08db3359c86c94918feb33a1182cd0ff3bb10b
    Author: Noah Goldstein <goldstein.w.n@gmail.com>
    Date:   Sun Jan 9 16:02:28 2022 -0600
    
        x86: Fix __wcsncmp_evex in strcmp-evex.S [BZ# 28755]
    
    This is for BZ #28755.
    
    Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com>
    
    (cherry picked from commit aa5a720056d37cf24924c138a3dbe6dace98e97c)
Comment 16 Sourceware Commits 2022-02-17 19:40:20 UTC
The release/2.31/master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=775c05b28c1883c5860f582cca68abf9036d9ace

commit 775c05b28c1883c5860f582cca68abf9036d9ace
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Feb 17 08:10:35 2022 -0800

    string: Add a testcase for wcsncmp with SIZE_MAX [BZ #28755]
    
    Verify that wcsncmp (L("abc"), L("abd"), SIZE_MAX) == 0.  The new test
    fails without
    
    commit ddf0992cf57a93200e0c782e2a94d0733a5a0b87
    Author: Noah Goldstein <goldstein.w.n@gmail.com>
    Date:   Sun Jan 9 16:02:21 2022 -0600
    
        x86: Fix __wcsncmp_avx2 in strcmp-avx2.S [BZ# 28755]
    
    and
    
    commit 7e08db3359c86c94918feb33a1182cd0ff3bb10b
    Author: Noah Goldstein <goldstein.w.n@gmail.com>
    Date:   Sun Jan 9 16:02:28 2022 -0600
    
        x86: Fix __wcsncmp_evex in strcmp-evex.S [BZ# 28755]
    
    This is for BZ #28755.
    
    Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com>
    
    (cherry picked from commit aa5a720056d37cf24924c138a3dbe6dace98e97c)
Comment 17 Sourceware Commits 2022-02-17 19:43:06 UTC
The release/2.30/master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=70522b1c1d1ffa5e3bd55aa3c064ea93a330bde9

commit 70522b1c1d1ffa5e3bd55aa3c064ea93a330bde9
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Feb 17 08:10:35 2022 -0800

    string: Add a testcase for wcsncmp with SIZE_MAX [BZ #28755]
    
    Verify that wcsncmp (L("abc"), L("abd"), SIZE_MAX) == 0.  The new test
    fails without
    
    commit ddf0992cf57a93200e0c782e2a94d0733a5a0b87
    Author: Noah Goldstein <goldstein.w.n@gmail.com>
    Date:   Sun Jan 9 16:02:21 2022 -0600
    
        x86: Fix __wcsncmp_avx2 in strcmp-avx2.S [BZ# 28755]
    
    and
    
    commit 7e08db3359c86c94918feb33a1182cd0ff3bb10b
    Author: Noah Goldstein <goldstein.w.n@gmail.com>
    Date:   Sun Jan 9 16:02:28 2022 -0600
    
        x86: Fix __wcsncmp_evex in strcmp-evex.S [BZ# 28755]
    
    This is for BZ #28755.
    
    Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com>
    
    (cherry picked from commit aa5a720056d37cf24924c138a3dbe6dace98e97c)
Comment 18 Sourceware Commits 2022-02-17 19:48:02 UTC
The release/2.29/master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=a486152569be7ccdd748f669631285e1a16f2e73

commit a486152569be7ccdd748f669631285e1a16f2e73
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Feb 17 08:10:35 2022 -0800

    string: Add a testcase for wcsncmp with SIZE_MAX [BZ #28755]
    
    Verify that wcsncmp (L("abc"), L("abd"), SIZE_MAX) == 0.  The new test
    fails without
    
    commit ddf0992cf57a93200e0c782e2a94d0733a5a0b87
    Author: Noah Goldstein <goldstein.w.n@gmail.com>
    Date:   Sun Jan 9 16:02:21 2022 -0600
    
        x86: Fix __wcsncmp_avx2 in strcmp-avx2.S [BZ# 28755]
    
    and
    
    commit 7e08db3359c86c94918feb33a1182cd0ff3bb10b
    Author: Noah Goldstein <goldstein.w.n@gmail.com>
    Date:   Sun Jan 9 16:02:28 2022 -0600
    
        x86: Fix __wcsncmp_evex in strcmp-evex.S [BZ# 28755]
    
    This is for BZ #28755.
    
    Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com>
    
    (cherry picked from commit aa5a720056d37cf24924c138a3dbe6dace98e97c)
Comment 19 Sourceware Commits 2022-02-17 19:52:27 UTC
The release/2.28/master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=9e050d1370587e808bc7bc3d151c5beb417120cb

commit 9e050d1370587e808bc7bc3d151c5beb417120cb
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Feb 17 08:10:35 2022 -0800

    string: Add a testcase for wcsncmp with SIZE_MAX [BZ #28755]
    
    Verify that wcsncmp (L("abc"), L("abd"), SIZE_MAX) == 0.  The new test
    fails without
    
    commit ddf0992cf57a93200e0c782e2a94d0733a5a0b87
    Author: Noah Goldstein <goldstein.w.n@gmail.com>
    Date:   Sun Jan 9 16:02:21 2022 -0600
    
        x86: Fix __wcsncmp_avx2 in strcmp-avx2.S [BZ# 28755]
    
    and
    
    commit 7e08db3359c86c94918feb33a1182cd0ff3bb10b
    Author: Noah Goldstein <goldstein.w.n@gmail.com>
    Date:   Sun Jan 9 16:02:28 2022 -0600
    
        x86: Fix __wcsncmp_evex in strcmp-evex.S [BZ# 28755]
    
    This is for BZ #28755.
    
    Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com>
    
    (cherry picked from commit aa5a720056d37cf24924c138a3dbe6dace98e97c)