[PATCH v5 0/8] Always use 32-bit time_t for certain syscalls

classic Classic list List threaded Threaded
42 messages Options
123
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v5 0/8] Always use 32-bit time_t for certain syscalls

Sourceware - libc-alpha mailing list
On Mon, Apr 6, 2020 at 10:45 AM Alistair Francis <[hidden email]> wrote:

>
> On Mon, Apr 6, 2020 at 10:48 AM Andreas Schwab <[hidden email]> wrote:
> >
> > On Apr 06 2020, Adhemerval Zanella wrote:
> >
> > > On 06/04/2020 14:07, Andreas Schwab wrote:
> > >> On Apr 06 2020, Adhemerval Zanella wrote:
> > >>
> > >>> I am not familiar with build-vm command, which would be a easy
> > >>> way to try reproduce it?
> > >>
> > >> Just run any shell script.
> > >>
> > >> See <[hidden email]>.
> > >>
> > >> Andreas.
> > >>
> > >
> > > I built a bash 5.0 for i686 and I am trying to reproduce it
> > > with master (4531ba8ebfedf):
> > >
> > > i686-linux-gnu$ file /tmp/bash-5.0/install/bin/bash
> > > /tmp/bash-5.0/install/bin/bash: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-, BuildID[sha1]=7468b3013138231097ec41a9b35826febc576939, for GNU/Linux 3.2.0, with debug_info, not stripped
> > > i686-linux-gnu$ cat test.sh
> > > echo $@
> > > i686-linux-gnu$ ./testrun.sh /tmp/bash-5.0/install/bin/bash ./test.sh ... +++ ===
> > > ... +++ ===
> > >
> > > What am I missing here?
> >
> > Probably a modern kernel.
>
> I'm building a ARMv7 rootFS and 5.4 kernel now. I'll try to reproduce
> the problem.

I have what I think is a fix based on some other comments on the list.
Testing now then I'll send the patch.

This is the diff:
diff --git a/sysdeps/unix/sysv/linux/wait4.c b/sysdeps/unix/sysv/linux/wait4.c
index d14bd4da27..796691eb2b 100644
--- a/sysdeps/unix/sysv/linux/wait4.c
+++ b/sysdeps/unix/sysv/linux/wait4.c
@@ -32,10 +32,7 @@ __wait4_time64 (pid_t pid, int *stat_loc, int
options, struct __rusage64 *usage)
   struct __rusage32 usage32;
   pid_t ret = SYSCALL_CANCEL (wait4, pid, stat_loc, options, &usage32);

-  if (ret != 0)
-    return ret;
-
-  if (usage != NULL)
+  if (ret > 0 && usage != NULL)
     rusage32_to_rusage64 (&usage32, usage);

   return ret;
@@ -119,10 +116,8 @@ __wait4 (pid_t pid, int *stat_loc, int options,
struct rusage *usage)

   ret = __wait4_time64 (pid, stat_loc, options, &usage64);

-  if (ret != 0)
-    return ret;
-
-  rusage64_to_rusage (&usage64, usage);
+  if (ret > 0 && usage != NULL)
+    rusage64_to_rusage (&usage64, usage);

   return ret;
 }


Alistair

>
> Alistair
>
> >
> > Andreas.
> >
> > --
> > Andreas Schwab, [hidden email]
> > GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
> > "And now for something completely different."
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH v5 0/8] Always use 32-bit time_t for certain syscalls

Sourceware - libc-alpha mailing list


On 06/04/2020 15:02, Alistair Francis wrote:

> On Mon, Apr 6, 2020 at 10:45 AM Alistair Francis <[hidden email]> wrote:
>>
>> On Mon, Apr 6, 2020 at 10:48 AM Andreas Schwab <[hidden email]> wrote:
>>>
>>> On Apr 06 2020, Adhemerval Zanella wrote:
>>>
>>>> On 06/04/2020 14:07, Andreas Schwab wrote:
>>>>> On Apr 06 2020, Adhemerval Zanella wrote:
>>>>>
>>>>>> I am not familiar with build-vm command, which would be a easy
>>>>>> way to try reproduce it?
>>>>>
>>>>> Just run any shell script.
>>>>>
>>>>> See <[hidden email]>.
>>>>>
>>>>> Andreas.
>>>>>
>>>>
>>>> I built a bash 5.0 for i686 and I am trying to reproduce it
>>>> with master (4531ba8ebfedf):
>>>>
>>>> i686-linux-gnu$ file /tmp/bash-5.0/install/bin/bash
>>>> /tmp/bash-5.0/install/bin/bash: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-, BuildID[sha1]=7468b3013138231097ec41a9b35826febc576939, for GNU/Linux 3.2.0, with debug_info, not stripped
>>>> i686-linux-gnu$ cat test.sh
>>>> echo $@
>>>> i686-linux-gnu$ ./testrun.sh /tmp/bash-5.0/install/bin/bash ./test.sh ... +++ ===
>>>> ... +++ ===
>>>>
>>>> What am I missing here?
>>>
>>> Probably a modern kernel.
>>
>> I'm building a ARMv7 rootFS and 5.4 kernel now. I'll try to reproduce
>> the problem.
>
> I have what I think is a fix based on some other comments on the list.
> Testing now then I'll send the patch.
>
> This is the diff:
> diff --git a/sysdeps/unix/sysv/linux/wait4.c b/sysdeps/unix/sysv/linux/wait4.c
> index d14bd4da27..796691eb2b 100644
> --- a/sysdeps/unix/sysv/linux/wait4.c
> +++ b/sysdeps/unix/sysv/linux/wait4.c
> @@ -32,10 +32,7 @@ __wait4_time64 (pid_t pid, int *stat_loc, int
> options, struct __rusage64 *usage)
>    struct __rusage32 usage32;
>    pid_t ret = SYSCALL_CANCEL (wait4, pid, stat_loc, options, &usage32);
>
> -  if (ret != 0)
> -    return ret;
> -
> -  if (usage != NULL)
> +  if (ret > 0 && usage != NULL)
>      rusage32_to_rusage64 (&usage32, usage);
>
>    return ret;
> @@ -119,10 +116,8 @@ __wait4 (pid_t pid, int *stat_loc, int options,
> struct rusage *usage)
>
>    ret = __wait4_time64 (pid, stat_loc, options, &usage64);
>
> -  if (ret != 0)
> -    return ret;
> -
> -  rusage64_to_rusage (&usage64, usage);
> +  if (ret > 0 && usage != NULL)
> +    rusage64_to_rusage (&usage64, usage);
>
>    return ret;
>  }

It seems to be issue, this small testcase reproduces it:

--
#include <unistd.h>
#include <stdlib.h>
#include <sys/wait.h>

int main (int argc, char *argv[])
{
  pid_t child = fork ();
  if (child == 0)
    {
      pause ();
      exit (0);
    }


  wait4 (child, &(int){0}, WNOHANG, NULL);
  kill (child, SIGKILL);
  return 0;
}
--

Please post the fix upstream.
123