From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ouvsmtp1.octopuce.fr (ouvsmtp1.octopuce.fr [194.36.166.50]) by sourceware.org (Postfix) with ESMTPS id ED1E23857351 for ; Thu, 29 Sep 2022 17:46:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org ED1E23857351 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=opteya.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=opteya.com Received: from panel.vitry.ouvaton.coop (unknown [194.36.166.20]) by ouvsmtp1.octopuce.fr (Postfix) with ESMTPS id 35AA1EE; Thu, 29 Sep 2022 19:46:40 +0200 (CEST) Received: from sm.ouvaton.coop (ouvadm.octopuce.fr [194.36.166.2]) by panel.vitry.ouvaton.coop (Postfix) with ESMTPSA id 01E4C5E2231; Thu, 29 Sep 2022 19:46:40 +0200 (CEST) MIME-Version: 1.0 Date: Thu, 29 Sep 2022 17:46:39 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: "Yann Droneaud" Message-ID: Subject: Re: [PATCH] malloc: Do not clobber errno on __getrandom_nocancel (BZ#29624) To: "Adhemerval Zanella" , libc-alpha@sourceware.org In-Reply-To: <20220929164510.3454281-1-adhemerval.zanella@linaro.org> References: <20220929164510.3454281-1-adhemerval.zanella@linaro.org> X-Originating-IP: 10.0.20.16 X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_STATUS,RCVD_IN_SBL_CSS,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi, 29 septembre 2022 =C3=A0 18:45 "Adhemerval Zanella via Libc-alpha" a =C3= =A9crit: > Use INTERNAL_SYSCALL_CALL instead of INLINE_SYSCALL_CALL. This > requires emulate the semantic for hurd call (so __arc4random_buf > uses the fallback). >=20 >=20Checked 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(-) [...]=20 >=20diff --git a/sysdeps/mach/hurd/not-cancel.h b/sysdeps/mach/hurd/not-c= ancel.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__) >=20=20 >=20-#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 =3D errno; > + int r =3D __getrandom (buf, buflen, flags); > + __set_errno (save_errno); > + return r =3D=3D -1 ? -save_errno : r; > +} >=20=20 I=20don't get why the saved errno value is returned. Regards. --=20 Yann=20Droneaud OPTEYA