From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: libc-alpha@sourceware.org,
Wilco Dijkstra <Wilco.Dijkstra@arm.com>,
Yu Chien Peter Lin <peterlin@andestech.com>
Subject: Re: [PATCH 1/2] stdlib: Fix __getrandom_nocancel type and arc4random usage (BZ #29638)
Date: Thu, 29 Sep 2022 16:54:45 -0300 [thread overview]
Message-ID: <dc91b8e7-8501-d19d-b531-d3018e7abb75@linaro.org> (raw)
In-Reply-To: <CAMe9rOp=1mpE2L11uxkNE1416pt=X12cOC2LAuw5iU1zPqxHnQ@mail.gmail.com>
On 29/09/22 16:39, H.J. Lu wrote:
> On Thu, Sep 29, 2022 at 12:28 PM Adhemerval Zanella via Libc-alpha
> <libc-alpha@sourceware.org> wrote:
>>
>> Using an unsigned type prevents the fallback to be used if kernel
>> does not support getrandom syscall.
>>
>> Checked on x86_64-linux-gnu.
>> ---
>> stdlib/arc4random.c | 2 +-
>> sysdeps/unix/sysv/linux/not-cancel.h | 2 +-
>> 2 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/stdlib/arc4random.c b/stdlib/arc4random.c
>> index e417ef624d..960a38f295 100644
>> --- a/stdlib/arc4random.c
>> +++ b/stdlib/arc4random.c
>> @@ -34,7 +34,7 @@ void
>> __arc4random_buf (void *p, size_t n)
>> {
>> static int seen_initialized;
>> - size_t l;
>> + ssize_t l;
>> int fd;
>>
>> if (n == 0)
>> diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h
>> index a263d294b1..cf35c8bfc9 100644
>> --- a/sysdeps/unix/sysv/linux/not-cancel.h
>> +++ b/sysdeps/unix/sysv/linux/not-cancel.h
>> @@ -68,7 +68,7 @@ __writev_nocancel_nostatus (int fd, const struct iovec *iov, int iovcnt)
>> INTERNAL_SYSCALL_CALL (writev, fd, iov, iovcnt);
>> }
>>
>> -static inline int
>> +static inline ssize_t
>
> Shouldn't it be __syscall_slong_t?
Would it make any difference? 'size_t' is still 32 bit on x32, so arc4random_buf
would not be able to handle buffer larger than 32 bits. Same for getrandom,
which return ssize_t.
>
>> __getrandom_nocancel (void *buf, size_t buflen, unsigned int flags)
>> {
>> return INLINE_SYSCALL_CALL (getrandom, buf, buflen, flags);
>> --
>> 2.34.1
>>
>
>
>
next prev parent reply other threads:[~2022-09-29 19:54 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-29 19:27 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
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 [this message]
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=dc91b8e7-8501-d19d-b531-d3018e7abb75@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=Wilco.Dijkstra@arm.com \
--cc=hjl.tools@gmail.com \
--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).