From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by sourceware.org (Postfix) with ESMTPS id F144B3858C33 for ; Fri, 17 Mar 2023 21:44:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F144B3858C33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-x32f.google.com with SMTP id k25-20020a7bc419000000b003ed23114fa7so5894846wmi.4 for ; Fri, 17 Mar 2023 14:44:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679089489; h=in-reply-to:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=YGV54XeL2eC9yLInsJA7ltbtprPyxSj8wyVds43FHWw=; b=Ld4w1US8BCHNCUAG6wC14QnO9E7C3v/KpQlANGNGANSmBT0pGNLXcSuilb8OETAGFx l0dSwx5moVkwLOl8Czf+mPdbanRUqdfRq3yYqioH/pisl43kQ3T10c1hVI92ZpIWuZzV r6Z39Tki/F+/44e+2q+8mWdUExVfCOo7jbG3NnkBuWIind9aZ0ciGXuQ9OXslDSMy+of iI7oEYtioJaK0gyqH7dMDchthn1oocSpH4zfu9zFGf+ysxkJ11sRbd2/ertF2D61FGMl sLEi3OlNCAIlfpGGWouZwn2z4mBoKBkZvNyHm1WRJuFhcC2uF2BW3FBj+vAsO5Cr9HOl ptuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679089489; h=in-reply-to:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=YGV54XeL2eC9yLInsJA7ltbtprPyxSj8wyVds43FHWw=; b=BIB+HbRwbdO2neIGQJRbRY1LW3Mv/kWRBvU1mc84Z7RS59JZ9nMQSjky9Cv+MKqtRH rDlNmYYUCgrM0cKWSC75FmzNLbu3FBxvUES/EBGccr/VqwmMRKYw9tX1/Qucir5Bfq1q 603bFs4dl4Fig8yMaysMRpB28wi+t64y9p8u/S2WM98+V7JYDddcBowYhDwgurN/RLhy k8PJm7zFqL07g2SZqeiMSVzl/jutpN6m7UaflZcv0m+pgnf8flpeq/n88l+E9inyqtMe 87BjlyfotkkFgaH0XkP0cVpZaUxZww39ZeIcyWX7teM776q80Z4l2xv2qhS1+EKki7nJ MF9Q== X-Gm-Message-State: AO0yUKUv30/w24Mz6vRYGOswK/CgYhXm+dpwa/iImOp6bXmqZHnZfRnj Qm+Wru5b3wmBZTH/D22T7RE= X-Google-Smtp-Source: AK7set9BMeMkDuua4ejwrw8gzeUc1as8fPWqjgz7z8GgL2Z86ydzRP29kK0ZO/Gxf0SKhZR2a3efJg== X-Received: by 2002:a05:600c:a0a:b0:3eb:2e1e:beae with SMTP id z10-20020a05600c0a0a00b003eb2e1ebeaemr27049673wmp.25.1679089488670; Fri, 17 Mar 2023 14:44:48 -0700 (PDT) Received: from [192.168.0.160] ([170.253.51.134]) by smtp.gmail.com with ESMTPSA id o4-20020a05600c378400b003ed4e078c92sm3053493wmr.11.2023.03.17.14.44.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 17 Mar 2023 14:44:48 -0700 (PDT) Message-ID: Date: Fri, 17 Mar 2023 22:44:40 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH] arc4random.3: New page documenting the arc4random(3) family of functions Content-Language: en-US To: Jakub Wilk Cc: linux-man@vger.kernel.org, Alejandro Colomar , libc-alpha@sourceware.org, "Jason A. Donenfeld" , Ingo Schwarze References: <20230101162627.28031-1-alx@kernel.org> <20230317213149.cp6nx6fhrmq56msv@jwilk.net> From: Alejandro Colomar In-Reply-To: <20230317213149.cp6nx6fhrmq56msv@jwilk.net> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------MXt29AbkL3AHJm0d6edUDH3P" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,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: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --------------MXt29AbkL3AHJm0d6edUDH3P Content-Type: multipart/mixed; boundary="------------pTCoLb0IZPpcD6omaQOgyhnT"; protected-headers="v1" From: Alejandro Colomar To: Jakub Wilk Cc: linux-man@vger.kernel.org, Alejandro Colomar , libc-alpha@sourceware.org, "Jason A. Donenfeld" , Ingo Schwarze Message-ID: Subject: Re: [PATCH] arc4random.3: New page documenting the arc4random(3) family of functions References: <20230101162627.28031-1-alx@kernel.org> <20230317213149.cp6nx6fhrmq56msv@jwilk.net> In-Reply-To: <20230317213149.cp6nx6fhrmq56msv@jwilk.net> --------------pTCoLb0IZPpcD6omaQOgyhnT Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Jakub, On 3/17/23 22:31, Jakub Wilk wrote: > * Alejandro Colomar , 2023-01-01 17:27: >> arc4random_uniform() returns a random number less than upper_bound for= =20 >> valid input, or 0 when upper_bound is invalid. >=20 > Is the "or 0 ..." thing part of the API? Yes, it is part of the (undocumented) API. At least, their authors claim to have thought about it when designing it, and purposefully took the decision of returning 0. They fail to acknowledge that it's a bug, also fail to acknowledge that their documentation doesn't document this behavior, and don't have any intention of changing the API because "we don't know what can possibly fail; you'd have to audit all software in the world to confirm that none depends on that detail". I have serious doubts that any software can depend on that, because mathematically it doesn't make any sense, so algorithms will likely have to purposefully special-case arc4random_uniform(0), but can't know for sure, because well, I haven't audited all software in the world. I didn't find any case in OpenBSD's source code that depends on that, however. > I could find anything like that=20 > in glibc docs or BSD man pages. Their manual page is bogus, and the funny thing is that one of Theo's arguments to reject a proposal to fix the bug in the API was that I wouldn't be able to document it reasonably. Well, as you saw, it's the current behavior that isn't well documented, and I had to special-case it in BUGS. >=20 >> STANDARDS >> These nonstandard functions are present in several Unix systems.= >=20 > That's not really helpful. Also, the VERSIONS section is missing ("ever= y=20 > new interface should include a VERSIONS section"). I thought of that this morning, while doing some reorganization of that section globally. I'll add the version. >=20 > In contrast, the libbsd man page is much more informative: >=20 >> These functions first appeared in OpenBSD 2.1, FreeBSD 3.0, NetBSD=20 >> 1.6, and DragonFly 1.0. The functions arc4random(), arc4random_buf() = >> and arc4random_uniform() appeared in glibc 2.36. Yup. :) Thanks a lot for this thorough review! Alex >> >> The original version of this random number generator used the RC4 (als= o=20 >> known as ARC4) algorithm. In OpenBSD 5.5 it was replaced with the=20 >> ChaCha20 cipher, and it may be replaced again in the future as=20 >> cryptographic techniques advance. A good mnemonic is =E2=80=9CA Repla= cement=20 >> Call for Random=E2=80=9D. >=20 --=20 GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5 --------------pTCoLb0IZPpcD6omaQOgyhnT-- --------------MXt29AbkL3AHJm0d6edUDH3P Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE6jqH8KTroDDkXfJAnowa+77/2zIFAmQU30gACgkQnowa+77/ 2zLhIA//fwZpnCbkk2AR5SEnLZZxnYqZe4gX/lfwYeIldl5I78m3BuhgQiqsSEVL 0jyGno7pLT2XQ5aVH8ek/DYUd1qgAeLWP0F3XFe3cx7M65AwBbvqjblkh2+H7EOV HnumB0JtF1yMZ/LOLQv5SX0i4a0ET292+M5iEMn+GADwGtG1gBYLNucLlmAeW6zS MpAoaWEJL9LZk83TcYlyeGi3MP2K/7vtKhTs+d54oHFdmO1F6lWwZ09nJFBHXNTE Ab5cPHokF/CMKms/DdXmASlKrxbB4R02LyG7RsjANhcsjzEbI2f8Nl59U35Y4XGN mDLpru6cwDTVjZ0RB3mAA4vRG6YxjieMcpFHToT1PNpYyyLb2t40lnTv+9MYjrl4 L0sLqdiko4fhoOSKb1dgm5rRVWyDvXYdGklb2jsd3QKwlKds+pKuYBaHTfzMbw0T NcXR224ER0wk13kAXHqXVWT/QSfRqeVg27U2V9sBx5xUGdbMbVVqkQy0trzdwLVd GcaK/kgie1o2KDiow9SMQ8WjjKOO1vOGw4mSxtOPlndkpZGmnffjHfM6qGjmSuAq 9jXNxFEXB8SAvYJiqCbQd63syyCdbsnuWfFuP/lmVrdMO6VwLmFDIrI90UpmyiYP KcmY2XsSSgvQLqbzZuexZksoVP2ZpxpBxAoN2Btknv8trSwxF9c= =sNRo -----END PGP SIGNATURE----- --------------MXt29AbkL3AHJm0d6edUDH3P--