Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 28 Jan 2015 09:49:07 -0500
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: getrandom syscall

On Wed, Jan 28, 2015 at 01:42:23PM +0100, Daniel Cegiełka wrote:
> 2015-01-28 13:26 GMT+01:00 Szabolcs Nagy <nsz@...t70.net>:
> > * Daniel Cegie??ka <daniel.cegielka@...il.com> [2015-01-28 10:10:53 +0100]:
> >> 2015-01-28 10:02 GMT+01:00 Szabolcs Nagy <nsz@...t70.net>:
> >> >
> >> > #ifdef SYS_getrandom
> > ...
> >> > #endif
> >> >
> >> > eg sh does not have the syscall (linux is not consistent with
> >> > syscalls for whatever reason)
> >>
> >> SYS_getrandom is defined on musl, so #ifdef SYS_getrandom is not a
> >> good solution:
> >>
> >> http://git.musl-libc.org/cgit/musl/tree/arch/x86_64/bits/syscall.h#n657
> >>
> >> It's better to return an error.
> >
> > no
> >
> > you should return runtime error if the syscall fails
> > (eg you are on old kernel that does not support the syscall)
> >
> > but you cannot use this code if SYS_getrandom is not
> > defined (eg. sh arch) because it will be a musl
> > compile time failure (sadly linux does not allocate
> > syscall numbers on all archs so musl cannot define
> > all SYS_ macros consistently on all archs either)
> 
> Indeed. I considered the kernel version check, but it is ugly
> approach. #ifdef SYS_getrandom we should add also add to the header
> file (stdlib.h?). Is this code will be approved for musl?

No, the header can't see the syscalls list. You can prototype the
function even if it's not defined; it won't hurt. But rather than
leaving it undefined, I think it should just return an error of ENOSYS
if the SYS_getrandom macro is not defined.

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.