[PATCH v3 2/2] malloc: Do not clobber errno on __getrandom_nocancel (BZ #29624)
Yann Droneaud
ydroneaud@opteya.com
Fri Sep 30 16:29:26 GMT 2022
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
More information about the Libc-alpha
mailing list