From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 5ED9E3858402; Mon, 29 Jan 2024 12:44:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5ED9E3858402 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1706532251; bh=l4tVVCUcY1oqlM8p88GyAD3vMgpV1tvaDAv14vsnLfQ=; h=From:To:Subject:Date:From; b=QIaQa/mTTh44YEvJqDmleI1/SKWDZB0wQPrnVZQ5NfrKgM/PsKc5SQcfpe441nVDF Ub1obOp7tEQb4AhRYVIwC+Sf87OFvJextnS94LfLuOGtU3SrsDgISKdOb1LOsvJhGo PhsBQTpYJq9beY+ngOKiaB4A+vLrZM5seJbaadkA= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/main] Cygwin: fix arc4random after fork(2) X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/main X-Git-Oldrev: 1f68e88f0dfdac54d71ed0fd2c3f9a9f65636e06 X-Git-Newrev: 030a762535c1e18bf5a7ecc73b0f49898a30b157 Message-Id: <20240129124411.5ED9E3858402@sourceware.org> Date: Mon, 29 Jan 2024 12:44:11 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D030a762535c= 1e18bf5a7ecc73b0f49898a30b157 commit 030a762535c1e18bf5a7ecc73b0f49898a30b157 Author: Corinna Vinschen AuthorDate: Mon Jan 29 13:38:14 2024 +0100 Commit: Corinna Vinschen CommitDate: Mon Jan 29 13:43:36 2024 +0100 Cygwin: fix arc4random after fork(2) =20 After using fork(), arc4random does not reseed itself, which causes the results to become predictable. Activate droppingfork-recogn= ition =20 Fixes: e0fc33322d50 ("Delete Cygwin's arc4random in favor of new Newlib= implementation") Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/include/machine/_arc4random.h | 11 +++++++++++ winsup/cygwin/release/3.5.0 | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/winsup/cygwin/include/machine/_arc4random.h b/winsup/cygwin/in= clude/machine/_arc4random.h index 2078c35972bb..fd3970f64ab2 100644 --- a/winsup/cygwin/include/machine/_arc4random.h +++ b/winsup/cygwin/include/machine/_arc4random.h @@ -25,4 +25,15 @@ extern int __isthreaded; __lock_release (_arc4random_mutex); \ } while (0) =20 +static inline void +_arc4random_forkdetect(void) +{ + extern int __in_forkee; + + if (__in_forkee) + rs =3D NULL; +} +#define _ARC4RANDOM_FORKDETECT() _arc4random_forkdetect () + +__END_DECLS #endif /* _MACHINE_ARC4RANDOM_H */ diff --git a/winsup/cygwin/release/3.5.0 b/winsup/cygwin/release/3.5.0 index 611636b9029d..d756c07853f6 100644 --- a/winsup/cygwin/release/3.5.0 +++ b/winsup/cygwin/release/3.5.0 @@ -67,3 +67,9 @@ What changed: =20 - The default RLIMIT_CORE is now 0, disabling the generation of core dump = or stackdump files. + +Fixes: +------ + +- Fix arc4random reseeding after fork(2). + Addresses: https://cygwin.com/pipermail/cygwin/2024-January/255245.html