public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] stdlib: Fix BZ #26241 testcase on GNU/Hurd
@ 2021-03-24  0:38 Samuel Thibault
  2021-03-24 13:04 ` Adhemerval Zanella
  0 siblings, 1 reply; 3+ messages in thread
From: Samuel Thibault @ 2021-03-24  0:38 UTC (permalink / raw)
  To: libc-alpha, Adhemerval Zanella; +Cc: Samuel Thibault, commit-hurd

GNU/Hurd's readlink system call is partly implemented in userspace, which
also allocates a buffer on the stack for the result, and thus needs one
more path.
---
 stdlib/tst-canon-bz26341.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/stdlib/tst-canon-bz26341.c b/stdlib/tst-canon-bz26341.c
index 6d054596b5..0ddd9aed15 100644
--- a/stdlib/tst-canon-bz26341.c
+++ b/stdlib/tst-canon-bz26341.c
@@ -72,10 +72,11 @@ do_realpath (void *arg)
      If realpath uses more than 2 * PATH_MAX plus some slack it will trigger
      a stackoverflow.  */
 
+  const size_t syscall_usage = 1 * PATH_MAX + 1024;
   const size_t realpath_usage = 2 * PATH_MAX + 1024;
   const size_t thread_usage = 1 * PATH_MAX + 1024;
   size_t stack_size = support_small_thread_stack_size ()
-		      - realpath_usage - thread_usage;
+		      - syscall_usage - realpath_usage - thread_usage;
   char stack[stack_size];
   char *resolved = stack + stack_size - thread_usage + 1024;
 
-- 
2.30.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] stdlib: Fix BZ #26241 testcase on GNU/Hurd
  2021-03-24  0:38 [PATCH] stdlib: Fix BZ #26241 testcase on GNU/Hurd Samuel Thibault
@ 2021-03-24 13:04 ` Adhemerval Zanella
  2021-03-24 20:59   ` Samuel Thibault
  0 siblings, 1 reply; 3+ messages in thread
From: Adhemerval Zanella @ 2021-03-24 13:04 UTC (permalink / raw)
  To: Samuel Thibault, libc-alpha; +Cc: commit-hurd



On 23/03/2021 21:38, Samuel Thibault wrote:
> GNU/Hurd's readlink system call is partly implemented in userspace, which
> also allocates a buffer on the stack for the result, and thus needs one
> more path.

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> ---
>   stdlib/tst-canon-bz26341.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/stdlib/tst-canon-bz26341.c b/stdlib/tst-canon-bz26341.c
> index 6d054596b5..0ddd9aed15 100644
> --- a/stdlib/tst-canon-bz26341.c
> +++ b/stdlib/tst-canon-bz26341.c
> @@ -72,10 +72,11 @@ do_realpath (void *arg)
>        If realpath uses more than 2 * PATH_MAX plus some slack it will trigger
>        a stackoverflow.  */
>   
> +  const size_t syscall_usage = 1 * PATH_MAX + 1024;

Could you also add a comment from where this come from on the description
above?

>     const size_t realpath_usage = 2 * PATH_MAX + 1024;
>     const size_t thread_usage = 1 * PATH_MAX + 1024;
>     size_t stack_size = support_small_thread_stack_size ()
> -		      - realpath_usage - thread_usage;
> +		      - syscall_usage - realpath_usage - thread_usage;
>     char stack[stack_size];
>     char *resolved = stack + stack_size - thread_usage + 1024;
>   
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] stdlib: Fix BZ #26241 testcase on GNU/Hurd
  2021-03-24 13:04 ` Adhemerval Zanella
@ 2021-03-24 20:59   ` Samuel Thibault
  0 siblings, 0 replies; 3+ messages in thread
From: Samuel Thibault @ 2021-03-24 20:59 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha, commit-hurd

Adhemerval Zanella, le mer. 24 mars 2021 10:04:51 -0300, a ecrit:
> 
> 
> On 23/03/2021 21:38, Samuel Thibault wrote:
> > GNU/Hurd's readlink system call is partly implemented in userspace, which
> > also allocates a buffer on the stack for the result, and thus needs one
> > more path.
> 
> LGTM, thanks.
> 
> Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
> 
> > ---
> >   stdlib/tst-canon-bz26341.c | 3 ++-
> >   1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/stdlib/tst-canon-bz26341.c b/stdlib/tst-canon-bz26341.c
> > index 6d054596b5..0ddd9aed15 100644
> > --- a/stdlib/tst-canon-bz26341.c
> > +++ b/stdlib/tst-canon-bz26341.c
> > @@ -72,10 +72,11 @@ do_realpath (void *arg)
> >        If realpath uses more than 2 * PATH_MAX plus some slack it will trigger
> >        a stackoverflow.  */
> > +  const size_t syscall_usage = 1 * PATH_MAX + 1024;
> 
> Could you also add a comment from where this come from on the description
> above?

Ok, and commited.

Thanks,
Samuel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-24 20:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-24  0:38 [PATCH] stdlib: Fix BZ #26241 testcase on GNU/Hurd Samuel Thibault
2021-03-24 13:04 ` Adhemerval Zanella
2021-03-24 20:59   ` Samuel Thibault

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).