public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Yann Droneaud <ydroneaud@opteya.com>
To: Wilco Dijkstra <Wilco.Dijkstra@arm.com>,
	Adhemerval Zanella <adhemerval.zanella@linaro.org>,
	"libc-alpha@sourceware.org" <libc-alpha@sourceware.org>,
	Yu Chien Peter Lin <peterlin@andestech.com>
Subject: Re: [PATCH v3 2/2] malloc: Do not clobber errno on __getrandom_nocancel (BZ #29624)
Date: Fri, 30 Sep 2022 18:29:26 +0200	[thread overview]
Message-ID: <55da3486-8246-c18f-4676-569c385b968d@opteya.com> (raw)
In-Reply-To: <AS4PR08MB79013D4518694DDD446A768E83569@AS4PR08MB7901.eurprd08.prod.outlook.com>

[-- Attachment #1: Type: text/plain, Size: 1410 bytes --]

Hi,

Le 30/09/2022 à 17:09, Wilco Dijkstra via Libc-alpha a écrit :
> Hi Adhemerval,
>
> This looks good to me assuming Hurd is 32-bit only.
>
> Reviewed-by: Wilco Dijkstra<Wilco.Dijkstra@arm.com>
>
> Cheers,
> Wilco
>
>
> From: Adhemerval Zanella<adhemerval.zanella@linaro.org>
>   
> Use INTERNAL_SYSCALL_CALL instead of INLINE_SYSCALL_CALL.  This
> requires emulate the semantic for hurd call (so __arc4random_buf
> uses the fallback).
>
> Checked on x86_64-linux-gnu.
> ---
> diff --git a/sysdeps/mach/hurd/not-cancel.h b/sysdeps/mach/hurd/not-cancel.h
> index ae58b734e3..5d2d2b4b8a 100644
> --- a/sysdeps/mach/hurd/not-cancel.h
> +++ b/sysdeps/mach/hurd/not-cancel.h
> @@ -25,6 +25,7 @@
>   #include <sys/wait.h>
>   #include <time.h>
>   #include <sys/uio.h>
> +#include <sys/random.h>
>   #include <hurd.h>
>   #include <hurd/fd.h>
>   
> @@ -75,8 +76,15 @@ __typeof (__fcntl) __fcntl_nocancel;
>   #define __fcntl64_nocancel(...) \
>     __fcntl_nocancel (__VA_ARGS__)
>   
> -#define __getrandom_nocancel(buf, size, flags) \
> -  __getrandom (buf, size, flags)
> +static inline int


ssize_t


> +__getrandom_nocancel (void *buf, size_t buflen, unsigned int flags)
> +{
> +  int save_errno = errno;
> +  int r = __getrandom (buf, buflen, flags);

ssize_t r


> +  r = r == -1 ? -errno : r;
> +  __set_errno (save_errno);
> +  return r;
> +}
>   

Regards.

-- 
Yann Droneaud
OPTEYA

  reply	other threads:[~2022-09-30 16:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-29 19:27 [PATCH 1/2] stdlib: Fix __getrandom_nocancel type and arc4random usage (BZ #29638) Adhemerval Zanella
2022-09-29 19:27 ` [PATCH v3 2/2] malloc: Do not clobber errno on __getrandom_nocancel (BZ #29624) Adhemerval Zanella
2022-09-30 15:09   ` Wilco Dijkstra
2022-09-30 16:29     ` Yann Droneaud [this message]
2022-09-30 16:37       ` Adhemerval Zanella Netto
2022-10-01 12:21         ` Yu-Chien Peter Lin
2022-09-29 19:39 ` [PATCH 1/2] stdlib: Fix __getrandom_nocancel type and arc4random usage (BZ #29638) H.J. Lu
2022-09-29 19:54   ` Adhemerval Zanella Netto
2022-09-29 20:01   ` Andreas Schwab
2022-09-30 15:05 ` Wilco Dijkstra
2022-10-01 12:16   ` Yu-Chien Peter Lin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55da3486-8246-c18f-4676-569c385b968d@opteya.com \
    --to=ydroneaud@opteya.com \
    --cc=Wilco.Dijkstra@arm.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=libc-alpha@sourceware.org \
    --cc=peterlin@andestech.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).