From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/6888 Path: news.gmane.org!not-for-mail From: =?UTF-8?Q?Daniel_Cegie=C5=82ka?= Newsgroups: gmane.linux.lib.musl.general Subject: Re: getrandom syscall Date: Wed, 28 Jan 2015 13:42:23 +0100 Message-ID: References: <20150128090212.GE32318@port70.net> <20150128122640.GF32318@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1422448978 26703 80.91.229.3 (28 Jan 2015 12:42:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 28 Jan 2015 12:42:58 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-6901-gllmg-musl=m.gmane.org@lists.openwall.com Wed Jan 28 13:42:58 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1YGRxR-0002sy-AA for gllmg-musl@m.gmane.org; Wed, 28 Jan 2015 13:42:57 +0100 Original-Received: (qmail 15972 invoked by uid 550); 28 Jan 2015 12:42:55 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 15958 invoked from network); 28 Jan 2015 12:42:55 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=IQp9j5/cdXr7B9oezPrX9pxfZMPIXA2K8IiCjoTDdyQ=; b=UMlaezhtfvcJz8CPMxu6Cq688mWU0qsKlv2515dSPyAleqScC8XUOrG0SlclTVJGv6 uJ/E12DPG6mT1Do9Vhsq2np1h0O6ZnbJGwWuHNLKfKFrfNscUOi8/ute/JFd32WWtpEd OK+AROSVfwNg3x/iAUp2+36kqgKZNA8wYtt81NsLh0eD3DHdinYnlgGc93/bqHX4XT6j TQMncJspoPaLyhCbFrUvvL7ROTZLXL2uDvcpWo/H07WGq5hYq4DEYUQ4E6fgQn4Xnvkd UYuWGPM3zeYucPbRWir3yN9xRK+yZks03i2dBxH/UAEiiGCUBWLKWR0bOWdsNRMfP5yg DRAA== X-Received: by 10.60.119.33 with SMTP id kr1mr1932676oeb.45.1422448963740; Wed, 28 Jan 2015 04:42:43 -0800 (PST) In-Reply-To: <20150128122640.GF32318@port70.net> Xref: news.gmane.org gmane.linux.lib.musl.general:6888 Archived-At: 2015-01-28 13:26 GMT+01:00 Szabolcs Nagy : > * Daniel Cegie??ka [2015-01-28 10:10:53 +0100]: >> 2015-01-28 10:02 GMT+01:00 Szabolcs Nagy : >> > >> > #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? Daniel