* [PATCH v1 1/2] String: Add three more overflow tests cases to test-strnlen.c
@ 2021-06-23 23:59 Noah Goldstein
2021-06-23 23:59 ` [PATCH v1 2/2] x86: Remove unnecessary overflow check from wcsnlen-sse4_1.S Noah Goldstein
2021-06-24 0:41 ` [PATCH v1 1/2] String: Add three more overflow tests cases to test-strnlen.c H.J. Lu
0 siblings, 2 replies; 5+ messages in thread
From: Noah Goldstein @ 2021-06-23 23:59 UTC (permalink / raw)
To: libc-alpha
No bug. Just seem like relevant cases given that strnlen will
use s + maxlen in many implementations.
Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
---
string/test-strnlen.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/string/test-strnlen.c b/string/test-strnlen.c
index f53e09263f..bb5d9b5f04 100644
--- a/string/test-strnlen.c
+++ b/string/test-strnlen.c
@@ -117,6 +117,10 @@ do_overflow_tests (void)
do_test (0, i, ~len + i, BIG_CHAR);
do_test (0, i, ~len - buf_addr - i, BIG_CHAR);
do_test (0, i, ~len - buf_addr + i, BIG_CHAR);
+
+ do_test (0, i, -buf_addr, BIG_CHAR);
+ do_test (0, i, j - buf_addr, BIG_CHAR);
+ do_test (0, i, -buf_addr - j, BIG_CHAR);
}
}
}
--
2.25.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v1 2/2] x86: Remove unnecessary overflow check from wcsnlen-sse4_1.S
2021-06-23 23:59 [PATCH v1 1/2] String: Add three more overflow tests cases to test-strnlen.c Noah Goldstein
@ 2021-06-23 23:59 ` Noah Goldstein
2021-06-24 0:41 ` H.J. Lu
2021-06-24 0:41 ` [PATCH v1 1/2] String: Add three more overflow tests cases to test-strnlen.c H.J. Lu
1 sibling, 1 reply; 5+ messages in thread
From: Noah Goldstein @ 2021-06-23 23:59 UTC (permalink / raw)
To: libc-alpha
No bug. The way wcsnlen will check if near the end of maxlen
is the following macro:
mov %r11, %rsi; \
subq %rax, %rsi; \
andq $-64, %rax; \
testq $-64, %rsi; \
je L(strnlen_ret)
Which words independently of s + maxlen overflowing. So the
second overflow check is unnecissary for correctness and
just extra overhead in the common no overflow case.
test-strlen.c, test-wcslen.c, test-strnlen.c and test-wcsnlen.c are
all passing
Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
---
Sorry I didn't notice this earlier before my last commit. As
of submitting this patch
a775a7a3eb1e85b54af0b4ee5ff4dcf66772a1fb
Is HEAD of master to maybe rebase so commit history isnt messy?
sysdeps/x86_64/multiarch/strlen-vec.S | 7 -------
1 file changed, 7 deletions(-)
diff --git a/sysdeps/x86_64/multiarch/strlen-vec.S b/sysdeps/x86_64/multiarch/strlen-vec.S
index 439e486a43..b7657282bd 100644
--- a/sysdeps/x86_64/multiarch/strlen-vec.S
+++ b/sysdeps/x86_64/multiarch/strlen-vec.S
@@ -71,19 +71,12 @@ L(n_nonzero):
suffice. */
mov %RSI_LP, %R10_LP
sar $62, %R10_LP
- test %R10_LP, %R10_LP
jnz __wcslen_sse4_1
sal $2, %RSI_LP
# endif
-
/* Initialize long lived registers. */
-
add %RDI_LP, %RSI_LP
-# ifdef AS_WCSLEN
-/* Check for overflow again from s + maxlen * sizeof(wchar_t). */
- jbe __wcslen_sse4_1
-# endif
mov %RSI_LP, %R10_LP
and $-64, %R10_LP
mov %RSI_LP, %R11_LP
--
2.25.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1 1/2] String: Add three more overflow tests cases to test-strnlen.c
2021-06-23 23:59 [PATCH v1 1/2] String: Add three more overflow tests cases to test-strnlen.c Noah Goldstein
2021-06-23 23:59 ` [PATCH v1 2/2] x86: Remove unnecessary overflow check from wcsnlen-sse4_1.S Noah Goldstein
@ 2021-06-24 0:41 ` H.J. Lu
1 sibling, 0 replies; 5+ messages in thread
From: H.J. Lu @ 2021-06-24 0:41 UTC (permalink / raw)
To: Noah Goldstein; +Cc: GNU C Library, Carlos O'Donell
On Wed, Jun 23, 2021 at 4:59 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
>
> No bug. Just seem like relevant cases given that strnlen will
> use s + maxlen in many implementations.
>
> Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
> ---
> string/test-strnlen.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/string/test-strnlen.c b/string/test-strnlen.c
> index f53e09263f..bb5d9b5f04 100644
> --- a/string/test-strnlen.c
> +++ b/string/test-strnlen.c
> @@ -117,6 +117,10 @@ do_overflow_tests (void)
> do_test (0, i, ~len + i, BIG_CHAR);
> do_test (0, i, ~len - buf_addr - i, BIG_CHAR);
> do_test (0, i, ~len - buf_addr + i, BIG_CHAR);
> +
> + do_test (0, i, -buf_addr, BIG_CHAR);
> + do_test (0, i, j - buf_addr, BIG_CHAR);
> + do_test (0, i, -buf_addr - j, BIG_CHAR);
> }
> }
> }
> --
> 2.25.1
>
LGTM.
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
Thanks.
--
H.J.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1 2/2] x86: Remove unnecessary overflow check from wcsnlen-sse4_1.S
2021-06-23 23:59 ` [PATCH v1 2/2] x86: Remove unnecessary overflow check from wcsnlen-sse4_1.S Noah Goldstein
@ 2021-06-24 0:41 ` H.J. Lu
2022-04-28 0:08 ` Sunil Pandey
0 siblings, 1 reply; 5+ messages in thread
From: H.J. Lu @ 2021-06-24 0:41 UTC (permalink / raw)
To: Noah Goldstein; +Cc: GNU C Library, Carlos O'Donell
On Wed, Jun 23, 2021 at 5:00 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
>
> No bug. The way wcsnlen will check if near the end of maxlen
> is the following macro:
>
> mov %r11, %rsi; \
> subq %rax, %rsi; \
> andq $-64, %rax; \
> testq $-64, %rsi; \
> je L(strnlen_ret)
>
> Which words independently of s + maxlen overflowing. So the
> second overflow check is unnecissary for correctness and
> just extra overhead in the common no overflow case.
>
> test-strlen.c, test-wcslen.c, test-strnlen.c and test-wcsnlen.c are
> all passing
>
> Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
> ---
> Sorry I didn't notice this earlier before my last commit. As
> of submitting this patch
>
> a775a7a3eb1e85b54af0b4ee5ff4dcf66772a1fb
>
> Is HEAD of master to maybe rebase so commit history isnt messy?
>
>
> sysdeps/x86_64/multiarch/strlen-vec.S | 7 -------
> 1 file changed, 7 deletions(-)
>
> diff --git a/sysdeps/x86_64/multiarch/strlen-vec.S b/sysdeps/x86_64/multiarch/strlen-vec.S
> index 439e486a43..b7657282bd 100644
> --- a/sysdeps/x86_64/multiarch/strlen-vec.S
> +++ b/sysdeps/x86_64/multiarch/strlen-vec.S
> @@ -71,19 +71,12 @@ L(n_nonzero):
> suffice. */
> mov %RSI_LP, %R10_LP
> sar $62, %R10_LP
> - test %R10_LP, %R10_LP
> jnz __wcslen_sse4_1
> sal $2, %RSI_LP
> # endif
>
> -
> /* Initialize long lived registers. */
> -
> add %RDI_LP, %RSI_LP
> -# ifdef AS_WCSLEN
> -/* Check for overflow again from s + maxlen * sizeof(wchar_t). */
> - jbe __wcslen_sse4_1
> -# endif
> mov %RSI_LP, %R10_LP
> and $-64, %R10_LP
> mov %RSI_LP, %R11_LP
> --
> 2.25.1
>
LGTM.
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
Thanks.
--
H.J.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1 2/2] x86: Remove unnecessary overflow check from wcsnlen-sse4_1.S
2021-06-24 0:41 ` H.J. Lu
@ 2022-04-28 0:08 ` Sunil Pandey
0 siblings, 0 replies; 5+ messages in thread
From: Sunil Pandey @ 2022-04-28 0:08 UTC (permalink / raw)
To: H.J. Lu, libc-stable; +Cc: Noah Goldstein, GNU C Library
On Wed, Jun 23, 2021 at 5:42 PM H.J. Lu via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
> On Wed, Jun 23, 2021 at 5:00 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
> >
> > No bug. The way wcsnlen will check if near the end of maxlen
> > is the following macro:
> >
> > mov %r11, %rsi; \
> > subq %rax, %rsi; \
> > andq $-64, %rax; \
> > testq $-64, %rsi; \
> > je L(strnlen_ret)
> >
> > Which words independently of s + maxlen overflowing. So the
> > second overflow check is unnecissary for correctness and
> > just extra overhead in the common no overflow case.
> >
> > test-strlen.c, test-wcslen.c, test-strnlen.c and test-wcsnlen.c are
> > all passing
> >
> > Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
> > ---
> > Sorry I didn't notice this earlier before my last commit. As
> > of submitting this patch
> >
> > a775a7a3eb1e85b54af0b4ee5ff4dcf66772a1fb
> >
> > Is HEAD of master to maybe rebase so commit history isnt messy?
> >
> >
> > sysdeps/x86_64/multiarch/strlen-vec.S | 7 -------
> > 1 file changed, 7 deletions(-)
> >
> > diff --git a/sysdeps/x86_64/multiarch/strlen-vec.S b/sysdeps/x86_64/multiarch/strlen-vec.S
> > index 439e486a43..b7657282bd 100644
> > --- a/sysdeps/x86_64/multiarch/strlen-vec.S
> > +++ b/sysdeps/x86_64/multiarch/strlen-vec.S
> > @@ -71,19 +71,12 @@ L(n_nonzero):
> > suffice. */
> > mov %RSI_LP, %R10_LP
> > sar $62, %R10_LP
> > - test %R10_LP, %R10_LP
> > jnz __wcslen_sse4_1
> > sal $2, %RSI_LP
> > # endif
> >
> > -
> > /* Initialize long lived registers. */
> > -
> > add %RDI_LP, %RSI_LP
> > -# ifdef AS_WCSLEN
> > -/* Check for overflow again from s + maxlen * sizeof(wchar_t). */
> > - jbe __wcslen_sse4_1
> > -# endif
> > mov %RSI_LP, %R10_LP
> > and $-64, %R10_LP
> > mov %RSI_LP, %R11_LP
> > --
> > 2.25.1
> >
>
> LGTM.
>
> Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
>
> Thanks.
>
> --
> H.J.
I would like to backport this patch to release branches.
Any comments or objections?
--Sunil
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-04-28 0:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-23 23:59 [PATCH v1 1/2] String: Add three more overflow tests cases to test-strnlen.c Noah Goldstein
2021-06-23 23:59 ` [PATCH v1 2/2] x86: Remove unnecessary overflow check from wcsnlen-sse4_1.S Noah Goldstein
2021-06-24 0:41 ` H.J. Lu
2022-04-28 0:08 ` Sunil Pandey
2021-06-24 0:41 ` [PATCH v1 1/2] String: Add three more overflow tests cases to test-strnlen.c H.J. Lu
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).