public inbox for libc-stable@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Noah Goldstein <goldstein.w.n@gmail.com>
Cc: GNU C Library <libc-alpha@sourceware.org>,
	 Libc-stable Mailing List <libc-stable@sourceware.org>
Subject: Re: [PATCH v3 1/7] x86: Fix __wcsncmp_avx2 in strcmp-avx2.S [BZ# 28755]
Date: Wed, 26 Jan 2022 14:05:20 -0800	[thread overview]
Message-ID: <CAMe9rOp4c0QdrUX_KXEwY531G=6yJmSowSWJr7boKLynwX5ZjQ@mail.gmail.com> (raw)
In-Reply-To: <CAMe9rOoSyQpp=u=B2+OXXfxqJvdCOyd0GKj-sx=tv4iQW_dNug@mail.gmail.com>

On Mon, Jan 10, 2022 at 6:15 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Mon, Jan 10, 2022 at 1:36 PM Noah Goldstein via Libc-alpha
> <libc-alpha@sourceware.org> wrote:
> >
> > Fixes [BZ# 28755] for wcsncmp by redirecting length >= 2^56 to
> > __wcscmp_avx2. For x86_64 this covers the entire address range so any
> > length larger could not possibly be used to bound `s1` or `s2`.
> >
> > test-strcmp, test-strncmp, test-wcscmp, and test-wcsncmp all pass.
> >
> > Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
> > ---
> >  sysdeps/x86_64/multiarch/strcmp-avx2.S | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> >
> > diff --git a/sysdeps/x86_64/multiarch/strcmp-avx2.S b/sysdeps/x86_64/multiarch/strcmp-avx2.S
> > index a45f9d2749..9c73b5899d 100644
> > --- a/sysdeps/x86_64/multiarch/strcmp-avx2.S
> > +++ b/sysdeps/x86_64/multiarch/strcmp-avx2.S
> > @@ -87,6 +87,16 @@ ENTRY (STRCMP)
> >         je      L(char0)
> >         jb      L(zero)
> >  #  ifdef USE_AS_WCSCMP
> > +#  ifndef __ILP32__
> > +       movq    %rdx, %rcx
> > +       /* Check if length could overflow when multiplied by
> > +          sizeof(wchar_t). Checking top 8 bits will cover all potential
> > +          overflow cases as well as redirect cases where its impossible to
> > +          length to bound a valid memory region. In these cases just use
> > +          'wcscmp'.  */
> > +       shrq    $56, %rcx
> > +       jnz     __wcscmp_avx2
> > +#  endif
> >         /* Convert units: from wide to byte char.  */
> >         shl     $2, %RDX_LP
> >  #  endif
> > --
> > 2.25.1
> >
>
> LGTM.
>
> Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
>
> Thanks.
>
> --
> H.J.

I am backporting this to 2.34 branch.


-- 
H.J.

  parent reply	other threads:[~2022-01-26 22:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20220109122946.2754917-1-goldstein.w.n@gmail.com>
     [not found] ` <20220110213540.1258344-1-goldstein.w.n@gmail.com>
     [not found]   ` <20220110213540.1258344-2-goldstein.w.n@gmail.com>
     [not found]     ` <CAMe9rOqXMUQj_EUcisf_xr+cN2VVUJEY2p1DibS9tjkDS5vmSA@mail.gmail.com>
2022-01-26 22:04       ` [PATCH v3 2/7] x86: Fix __wcsncmp_evex in strcmp-evex.S " H.J. Lu
2022-04-29 22:05         ` Sunil Pandey
     [not found]   ` <CAMe9rOoSyQpp=u=B2+OXXfxqJvdCOyd0GKj-sx=tv4iQW_dNug@mail.gmail.com>
2022-01-26 22:05     ` H.J. Lu [this message]
2022-01-27  4:29       ` [PATCH v3 1/7] x86: Fix __wcsncmp_avx2 in strcmp-avx2.S " H.J. Lu
2022-01-27  5:10         ` H.J. Lu
2022-01-27  5:52           ` Noah Goldstein

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='CAMe9rOp4c0QdrUX_KXEwY531G=6yJmSowSWJr7boKLynwX5ZjQ@mail.gmail.com' \
    --to=hjl.tools@gmail.com \
    --cc=goldstein.w.n@gmail.com \
    --cc=libc-alpha@sourceware.org \
    --cc=libc-stable@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).