From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: Yann Droneaud <ydroneaud@opteya.com>, libc-alpha@sourceware.org
Subject: Re: [PATCH] malloc: Do not clobber errno on __getrandom_nocancel (BZ#29624)
Date: Thu, 29 Sep 2022 14:49:20 -0300 [thread overview]
Message-ID: <24841f93-2247-e46d-82a1-e0c35c1d3958@linaro.org> (raw)
In-Reply-To: <eb0bc7d58352ae813ad2c41d6270e303258f54e4@opteya.com>
On 29/09/22 14:46, Yann Droneaud wrote:
> Hi,
>
> 29 septembre 2022 à 18:45 "Adhemerval Zanella via Libc-alpha" a écrit:
>
>> 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.
>> ---
>> stdlib/arc4random.c | 4 ++--
>> sysdeps/mach/hurd/not-cancel.h | 11 +++++++++--
>> sysdeps/unix/sysv/linux/not-cancel.h | 2 +-
>> 3 files changed, 12 insertions(+), 5 deletions(-)
>
> [...]
>
>> diff --git a/sysdeps/mach/hurd/not-cancel.h b/sysdeps/mach/hurd/not-cancel.h
>> index ae58b734e3..f2cb9b60ba 100644
>> --- a/sysdeps/mach/hurd/not-cancel.h
>> +++ b/sysdeps/mach/hurd/not-cancel.h
>> @@ -75,8 +76,14 @@ __typeof (__fcntl) __fcntl_nocancel;
>> #define __fcntl64_nocancel(...) \
>> __fcntl_nocancel (__VA_ARGS__)
>>
>> -#define __getrandom_nocancel(buf, size, flags) \
>> - __getrandom (buf, size, flags)
>> +static inline int
>> +__getrandom_nocancel (void *buf, size_t buflen, unsigned int flags)
>> +{
>> + int save_errno = errno;
>> + int r = __getrandom (buf, buflen, flags);
>> + __set_errno (save_errno);
>> + return r == -1 ? -save_errno : r;
>> +}
>>
>
> I don't get why the saved errno value is returned.
Oops, because it is wrong.
>
>
> Regards.
>
next prev parent reply other threads:[~2022-09-29 17:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-29 16:45 Adhemerval Zanella
2022-09-29 17:31 ` Andreas Schwab
2022-09-29 17:46 ` Yann Droneaud
2022-09-29 17:49 ` Adhemerval Zanella Netto [this message]
2022-09-29 17:52 ` Wilco Dijkstra
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=24841f93-2247-e46d-82a1-e0c35c1d3958@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=libc-alpha@sourceware.org \
--cc=ydroneaud@opteya.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).