GNU bug report logs - #21694
'clone' syscall binding unreliable

Previous Next

Package: guix;

Reported by: ludo <at> gnu.org (Ludovic Courtès)

Date: Fri, 16 Oct 2015 20:41:02 UTC

Severity: normal

Done: ludo <at> gnu.org (Ludovic Courtès)

Bug is archived. No further changes may be made.

Full log


Message #20 received at 21694 <at> debbugs.gnu.org (full text, mbox):

From: Mark H Weaver <mhw <at> netris.org>
To: ludo <at> gnu.org (Ludovic Courtès)
Cc: 21694 <at> debbugs.gnu.org, David Thompson <davet <at> gnu.org>
Subject: Re: bug#21694: 'clone' syscall binding unreliable
Date: Wed, 28 Oct 2015 00:53:28 -0400
ludo <at> gnu.org (Ludovic Courtès) writes:

> Mark H Weaver <mhw <at> netris.org> skribis:
>
>> ludo <at> gnu.org (Ludovic Courtès) writes:
>
> [...]
>
>>>  ;; The libc interface to sys_clone is not useful for Scheme programs, so the
>>> -;; low-level system call is wrapped instead.
>>> +;; low-level system call is wrapped instead.  The 'syscall' function is
>>> +;; declared in <unistd.h> as a variadic function; in practice, it expects 6
>>> +;; pointer-sized arguments, as shown in, e.g., x86_64/syscall.S.
>>>  (define clone
>>>    (let* ((ptr        (dynamic-func "syscall" (dynamic-link)))
>>> -         (proc       (pointer->procedure int ptr (list int int '*)))
>>> +         (proc       (pointer->procedure long ptr
>>> +                                         (list long                   ;sysno
>>> +                                               unsigned-long          ;flags
>>
>> 'long' and 'unsigned long' might not be the same size as a pointer.
>> Better to use 'size_t' for both of these.  While not strictly guaranteed
>> to be the same size as a pointer, in practice they should be the same
>> except on architectures with segmented memory models.
>>
>> What do you think?
>
> I had the same reaction, but posix/unistd.h in libc really uses these
> types for ‘syscall’ so I thought it’d be best to stick to them.

Okay, makes sense.

    Thanks,
      Mark




This bug report was last modified 9 years and 264 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.