public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Noah Goldstein <goldstein.w.n@gmail.com>
To: Siddhesh Poyarekar <siddhesh@gotplt.org>
Cc: Paul Eggert <eggert@cs.ucla.edu>,
	GNU C Library <libc-alpha@sourceware.org>
Subject: Re: [PATCH v1] x86: memcmp-avx2-movbe.S and memcmp-evex-movbe.S fix overflow bug.
Date: Wed, 9 Jun 2021 02:54:26 -0400	[thread overview]
Message-ID: <CAFUsyfLMsUSjyCC0gAWs=hnH94b4YOxQjZm3GVtT2Gdp-gAsbw@mail.gmail.com> (raw)
In-Reply-To: <00e3f10b-9769-306e-7391-b57bd48a1476@gotplt.org>

On Wed, Jun 9, 2021 at 2:48 AM Siddhesh Poyarekar <siddhesh@gotplt.org>
wrote:

> On 6/9/21 12:02 PM, Noah Goldstein wrote:
> > Wait are you saying that the return value overflowing causes UB or
> > that the act of passing a maxlen where s + maxlen * sizeof(wchar_t) is
> > outside range object is UB?
>
> Not specifically the return value, but more broadly, causing wcsnlen to
> invoke undefined behaviour, which could include the former.
>
> > If the former then why is the follow okay:
> >
> > Previous example with a string whose length is 1000
> > but because wcslen is passed maxlen where maxlen * sizeof(wchar_t)
> > overflows and leads to a result less than 1000 the implementation of
> > wcslen in wcsnlen-avx2.S will return a length less than 1000.
> >
> >
> > If the latter then:
> >
> > For test-wcsnlen which redirects to test-strnlen
> > If the UB is when is s+maxlen*sizeof(wchar_t) is outside object bound
> > then s + SIZE_MAX + sizeof(wchar_t) surely is.
> >
> > Although even then test-strnlen s + SIZE_MAX will also overflow if s non
> > null.
>
> That is a good catch; I did not notice that.  That should be SIZE_MAX /
> sizeof (CHAR).
>

Do we want to support s + maxlen + sizeof(CHAR) overflowing? If not we can
speed up the AVX2/EVEX implementation of strnlen/wcsnlen/memchr/wmemchr.

(Assuming memchr is of same standard where s + n + sizeof(CHAR)
can't overflow. If not it has this bug).


> Thanks,
> Siddhesh
>

  reply	other threads:[~2021-06-09  6:54 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-07  8:30 Noah Goldstein
2021-06-07 13:45 ` H.J. Lu
2021-06-07 17:24   ` Noah Goldstein
2021-06-07 14:21 ` Siddhesh Poyarekar
2021-06-07 17:28   ` Noah Goldstein
2021-06-07 17:45     ` Paul Eggert
2021-06-07 18:07       ` Noah Goldstein
2021-06-07 19:51         ` Paul Eggert
2021-06-07 20:12           ` Noah Goldstein
2021-06-09  5:15       ` Noah Goldstein
2021-06-09  5:25         ` Siddhesh Poyarekar
2021-06-09  5:43           ` Noah Goldstein
2021-06-09  6:01             ` Siddhesh Poyarekar
2021-06-09  6:32               ` Noah Goldstein
2021-06-09  6:47                 ` Siddhesh Poyarekar
2021-06-09  6:54                   ` Noah Goldstein [this message]
2021-06-09  7:01                     ` Siddhesh Poyarekar
2021-06-09  7:07                       ` Siddhesh Poyarekar
2021-06-09  7:39                   ` Andreas Schwab
2021-06-09  7:58                     ` Siddhesh Poyarekar
2021-06-09  9:14                       ` Andreas Schwab
2021-06-09  9:20                         ` Florian Weimer
2021-06-09  9:34                           ` Siddhesh Poyarekar
2021-06-09  9:37                             ` Florian Weimer
2021-06-09  9:41                               ` Siddhesh Poyarekar
2021-06-09  9:26                         ` Siddhesh Poyarekar
2021-06-09  9:35                           ` Andreas Schwab
2021-06-09  9:43                             ` Siddhesh Poyarekar
2021-06-09 20:33                             ` Noah Goldstein
2021-06-09 20:37                               ` H.J. Lu
2021-06-10  3:35                               ` Siddhesh Poyarekar
2021-06-10  3:46                               ` Siddhesh Poyarekar

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='CAFUsyfLMsUSjyCC0gAWs=hnH94b4YOxQjZm3GVtT2Gdp-gAsbw@mail.gmail.com' \
    --to=goldstein.w.n@gmail.com \
    --cc=eggert@cs.ucla.edu \
    --cc=libc-alpha@sourceware.org \
    --cc=siddhesh@gotplt.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).