From 5a85786a9005722be7cb9e70f8874a5f1130daea Mon Sep 17 00:00:00 2001 From: Xi Ruoyao Date: Thu, 4 Jan 2024 21:41:20 +0800 Subject: Make __getrandom_nocancel set errno and add a _nostatus version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The __getrandom_nocancel function returns errors as negative values instead of errno. This is inconsistent with other _nocancel functions and it breaks "TEMP_FAILURE_RETRY (__getrandom_nocancel (p, n, 0))" in __arc4random_buf. Use INLINE_SYSCALL_CALL instead of INTERNAL_SYSCALL_CALL to fix this issue. But __getrandom_nocancel has been avoiding from touching errno for a reason, see BZ 29624. So add a __getrandom_nocancel_nostatus function and use it in tcache_key_initialize. Signed-off-by: Xi Ruoyao Reviewed-by: Adhemerval Zanella Signed-off-by: Andreas K. Hüttel --- sysdeps/unix/sysv/linux/not-cancel.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'sysdeps/unix/sysv') diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h index 50483d9e74..2a7585b73f 100644 --- a/sysdeps/unix/sysv/linux/not-cancel.h +++ b/sysdeps/unix/sysv/linux/not-cancel.h @@ -85,6 +85,14 @@ __writev_nocancel_nostatus (int fd, const struct iovec *iov, int iovcnt) static inline ssize_t __getrandom_nocancel (void *buf, size_t buflen, unsigned int flags) +{ + return INLINE_SYSCALL_CALL (getrandom, buf, buflen, flags); +} + +/* Non cancellable getrandom syscall that does not also set errno in case of + failure. */ +static inline ssize_t +__getrandom_nocancel_nostatus (void *buf, size_t buflen, unsigned int flags) { return INTERNAL_SYSCALL_CALL (getrandom, buf, buflen, flags); } -- cgit 1.4.1