From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from shymkent.ilbers.de ([unix socket]) by shymkent (Cyrus 2.5.10-Debian-2.5.10-3+deb9u2) with LMTPA; Wed, 22 Jul 2026 00:28:14 +0200 X-Sieve: CMU Sieve 2.4 Received: from mail-qv1-f61.google.com (mail-qv1-f61.google.com [209.85.219.61]) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8+deb9u1) with ESMTPS id 66LMSDKA031938 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 22 Jul 2026 00:28:14 +0200 Received: by mail-qv1-f61.google.com with SMTP id 6a1803df08f44-8ea75996387sf141859016d6.1 for ; Tue, 21 Jul 2026 15:28:13 -0700 (PDT) ARC-Seal: i=3; a=rsa-sha256; t=1784672888; cv=pass; d=google.com; s=arc-20260327; b=XNyo9Oh8Z9BTmIWmRB/JzsDIyOC9aGBvlQ7dBOF+MWnPwx5buls3ATRFS1dQhOwnWA qBJaZvv4Z+cO/qm2RJWzSNS0v3dxBVye63KNC/xvUyf6dVr240DlHAMhKmp+iKJjJB7q PfS2zwux2prUv0/u8ltUJMI/nrRYTl9d+vgIkHvKUspmc2nUixyRAH/eva4rgc88cpZT l4ahabO5L9Ei8NZKm5swR9X8J0+o8DSnsQ3YjJiodoHsq8swnLvz+puACYLRPr/bZEbL nyxYFhms2tOyoxrj47KZ2hPNOE+JYUgvco1QKetZSDU08a4P6YXiXtUlSswZOKulSdTY T8Qg== ARC-Message-Signature: i=3; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:to:subject:message-id:date:from :in-reply-to:references:mime-version:sender:dkim-signature :dkim-signature; bh=u2UmozUGyED5HhtojEsat58x+Wr6VkdKd/28PjWdzC0=; fh=M902NBFLdjjbotMmMacj4WO0+TqJBhN4htgZRwa9kfk=; b=CewHrV5fCXqYLdraZDx6CHL7EjTiy+v3CL7N4lxGzYM9RNtMpaqQSJhbHoTz74ig22 FmswnVweIQYRv0dRDmvrbnha0ymrseRbrRcHxje3Yjkjc4FRfWlWwbZT5GQW0NEeoFLj 8IRO8z1d5R3suyK7AIx87MfQQ6hEsCZe9qtcZvhW6xTrIDJZkn2jbiMqHHm9hOw1y/GZ sfbN0qGpPhQkTZIl6Z2rAlI0C71Lr9rjPKYcPT43umIYyiHFOZa3w/nybuavb4qxU3H1 4LFl1OkU4OG2C/R6aJmOXbwUM3pknN7ytrlEc/dfCYpKOiiSIQjotxvOmgZbu87nQZyE UfmQ==; darn=ilbers.de ARC-Authentication-Results: i=3; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20251104 header.b=N5qPz1KQ; arc=pass (i=1); spf=pass (google.com: domain of roberto.foglietta@gmail.com designates 2607:f8b0:4864:20::112a as permitted sender) smtp.mailfrom=roberto.foglietta@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com; dara=pass header.i=@googlegroups.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20251104; t=1784672888; x=1785277688; darn=ilbers.de; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:content-type:to:subject:message-id:date:from :in-reply-to:references:mime-version:sender:from:to:cc:subject:date :message-id:reply-to:content-type; bh=u2UmozUGyED5HhtojEsat58x+Wr6VkdKd/28PjWdzC0=; b=eXQFs+YEmYs2Yucyly9XsEUy03Qu80aRwePUbnjOjbdlZgg8RGAzj72pfMz/kr1GC1 gNjqGrufwRNGl+bcwM7eBjcOZN3xB9j2Mu2IQcfHTN/tFXVEX5yCTKgo2iEszmjj9a6r xZnibkA+WZ7MMYk7nKxc9B+TH40iZF8pQYKAjmNMKdLbzR6RsZMicIc3ywXh2PbTtjqw 3ooGSg3p6BIe6tNzuSCpZqAl6jlYWpI9l8A+6XOefEKPoJnAi25q8lBYIAw0wEYouM1H f5m9tKckfV+YhD2mHvoRZrdpjXkNvQqd98TCPprdBf2uj7D+aMpa0pFl+X+Y6P2bb5Kx 1XSg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784672888; x=1785277688; darn=ilbers.de; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:content-type:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to:content-type; bh=u2UmozUGyED5HhtojEsat58x+Wr6VkdKd/28PjWdzC0=; b=eMjR3Fcz/OATIFCdfBaOiAUwmRyiTAeLIO7yqfzXALZWEil6cOavubYcMuqt973ggE CPeNoQG04NVOo51XUd373/iJ5kNVHpil/fc47Qx9YKSDeguxS/7cwang0AXL7ZokSHgy o20ohOH6OmluWIQxEBqxgyeemlpRGTCw4rAZFW7Ns5wPyaSI6wyL8dnsTL1c40hwxeU6 ELi44IjRd699yiSYsK8FpIpIzapJUNC3zMgklRrf1X3ZdIoPf14yU48NYSSYPeXCCWi+ PMBuVrsz4xLo7yOzk6eiOpcNNDHnC85bmzx3tdBOqq63WqP0zAUbOURiB7IdtbDO0D+6 KY+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784672888; x=1785277688; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:content-type:to :subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-gg:x-beenthere:x-gm-message-state:sender:from:to:cc:subject :date:message-id:reply-to:content-type; bh=u2UmozUGyED5HhtojEsat58x+Wr6VkdKd/28PjWdzC0=; b=OMpad5Ilorfrsq+GHK+y6ZpYR5HYSkC/VB6MZo3d4lOLDTr8uPvu3uGXyiqWto9EVD I0VQ6wHkYWhi4515QxIAvikH2mC/Up6Q3P5Ok1rtlKe0cP1XPH8KvLyQQ5NEGm0Jjlfh G3eAniCHugKRGD19wjLQ+f+JlNTd8lPIcNNNJ3KeKqRng5K2IzuoR+H6Xo0yVINxFr/2 r93k6kZbk1xuqcz97UUn3R10bIW2nq1fjgg3lyyagNhM7TupfY2KMcIxDQwNmcjV2zVV yPusSQrqF0lCF1nbdJK3aeSypCxFs2UE5yKZZppjH4+/kypWW9ZB9lM71Xdlo6/eBZMF UIpA== Sender: isar-users@googlegroups.com X-Forwarded-Encrypted: i=3; AHgh+Ro5TP+Kye6VF1BIerS6UnEE0g5WzRxg3ZquhgeuriklmS9uuH5AFEuRraiIkvtV/Ywc2eZw@ilbers.de X-Gm-Message-State: AOJu0YzAmZPkxuTiuiBGSWjc0z5fZiQVyQ56fiSgNzp8rlyyj5ehlRwb mbsKBjen6Wdp7jXxlLJx1kHbYRqwxtanZNLHfverUbWz5n8c9/jArnyK X-Received: by 2002:a05:6214:5a05:b0:8ea:1b3:ff5f with SMTP id 6a1803df08f44-9077833306bmr252935846d6.21.1784672887919; Tue, 21 Jul 2026 15:28:07 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com; h="Aa7YSPRY2Fd/6fASB/+Fzwyj4Bl7ujlWeGX2EaRpK7U61f74+g==" Received: by 2002:a05:6214:5f83:b0:8e9:7648:a5c5 with SMTP id 6a1803df08f44-9076bea63d3ls6941096d6.2.-pod-prod-04-us; Tue, 21 Jul 2026 15:28:06 -0700 (PDT) X-Received: by 2002:a05:6122:caa:b0:5bd:b27c:bace with SMTP id 71dfb90a1353d-5c1bfa7ad4dmr6804592e0c.14.1784672886744; Tue, 21 Jul 2026 15:28:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1784672886; cv=pass; d=google.com; s=arc-20260327; b=gjQbNEPneTF3QsTCun5W7cWTDzHYQp7qVLzug2aY7DOOg/ZiuKtmqqth5cRQ8AyDD8 wjmogliUhit1Bvuu2wBtWCmR47g/NERSwsXUjx4rWnQR/iaX0JrAzhNl4qBomoE/17Kv nrvGnjATZhH3OoqJOQvfzKRCPZhIXm/T1WBr0oKa8y/8BlWZ+SSh7T1te3MCcAf5c33q QgW2PUqrxEPJuMwu32tHsi8mo3Io1AaWWE04I/QpqtfulvKKddLm144lRvkVe79q3Jem 01qinuXbPwVQxKPQahUajtSAqS3Z5tM3Pb2i7RlMwTPKecpeyJt0smtQ6u6JXDOyMmmV I5Xg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=/T3ZXCPr+0UolyxUOlG3LPPdqoG/YsqOMBLiEFr/Fos=; fh=hOBXq6nisExkIRIwN8IDOmOCLKwX8PM0ANlxQbNMEqA=; b=TPZ9SPwCcoyVv0vqigoRAYrecbsx+RIa2+FdUx14BYdbgKK+suedaaOaNng+spBA79 9S/EZDaIOOB1Bb3L44NmzjPNlyb7/ApSeXLagnRQH6NwqKhbrjhEo/9iP23a4tnd40jY ufWreBMrWDy8PM3AGBVX8ivYld6Zfmym+kVBvGQMOGO3WigervsCyq7wdNzjoyIQTsFn PoFc7Q63ypcHVQ4qDVaAF9/05CninsvwnHy9puzVnawJZlRMDVfJ7B5ioo/m9Es9/q2v fC+z+jYTnELl5rWS06a5PmMz5MO1BzbGsn0aOvchQUDVJj+hoZlun43OYnNNchTOuPl3 fHbQ==; dara=google.com ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20251104 header.b=N5qPz1KQ; arc=pass (i=1); spf=pass (google.com: domain of roberto.foglietta@gmail.com designates 2607:f8b0:4864:20::112a as permitted sender) smtp.mailfrom=roberto.foglietta@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com; dara=pass header.i=@googlegroups.com Received: from mail-yw1-x112a.google.com (mail-yw1-x112a.google.com. [2607:f8b0:4864:20::112a]) by gmr-mx.google.com with ESMTPS id 71dfb90a1353d-5c2c646150fsi21117e0c.3.2026.07.21.15.28.06 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Jul 2026 15:28:06 -0700 (PDT) Received-SPF: pass (google.com: domain of roberto.foglietta@gmail.com designates 2607:f8b0:4864:20::112a as permitted sender) client-ip=2607:f8b0:4864:20::112a; Received: by mail-yw1-x112a.google.com with SMTP id 00721157ae682-81ed073fed0so81814757b3.0 for ; Tue, 21 Jul 2026 15:28:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1784672886; cv=none; d=google.com; s=arc-20260327; b=bC2ryc2a/B2TmrnzudUnzELJI+0jPrHtWM95YAkH5DDgMzh5xvmZVm7COREHsZHSkS GbcGUnBDhk+QN9jdiGwHqLCopS3JkNCXfZu7kBFGmHKtjR6/CgtldACcMKxh8aOXFnQJ ll6RSl+siajzyU0ocmwB2mKlLeFEJ07uH/j5OqtONqUxCMFHMsuPhb66aR+QwWuXosnZ 3kQnUF6MiCqAvjVpDW/ILjE32NXG63iPKwPsk+xwu8nsURHkAYhiNIH9y2m1XYNYowLO KrHmzVivzKZSzfIIWkBTiifTNP2exzjV3TYjBRj4cujRCawUG3Ys35WwHFX7WrjMvfEP SdcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=/T3ZXCPr+0UolyxUOlG3LPPdqoG/YsqOMBLiEFr/Fos=; fh=hOBXq6nisExkIRIwN8IDOmOCLKwX8PM0ANlxQbNMEqA=; b=Ny5Y6gxZtVUKdHratzyhUOEQqdHd8oiJZCdJyrrlIaCWIbaU+CacQW1pCuGYYbs3Co 8MG4Pt7vQQwqiP396j56Bztpm7y/Xg1uvH6RplwgTuktqTEwu+XagXSXDBdocsBs87bx KKo6XjuijYzzLyb3+1lWMFLE2ScbaCdBO0GXzB+n5Kx4SRzmorzqTg/Ix1Fi7pZjnMpZ TDw6tGmYGagn+uA3JL4dMz2JsLCD/XdZX2sBP6TbMASuVFFmuAC7xaTwyOsoeJx2RQLI W2zPP0YwVyUMmnaX+NjsZEonN0eit7wBuxAImitK6kWek3YPt4UrWYW4/9UHcp8QzitI 3tpw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; arc=none X-Gm-Gg: AR+sD11lx7WZ+cd49B3+G3rGhAga5huiZ31lfgWZIogTMttMk6J/jW7neCx5GbBeArf 7B0LdLTLxfQJEIz7LkPjEfJ7qL68ukjHRzj8Le3xNK1QUfKCL/Qzx/l1oP9v3Lfl2fgNVxWu9iX 23jbEwAwVEaXwbVYpoplF1via/OxDVCu79QcACZZ7qcwjOG06IeNjQCd+ouLqpsEyts0Hn08r+0 1SlVYorTrYAMJMHCt4IM0vFppWThLCRDkHdbuM599nX4k21Qfrim+82EokAfr0N0TtJJVv6R+ff TUkJBzVFnEowr7Cp0kBlHH3nkakeer4UfAVkBuF7OiYsIyl2ccaQVUjltPm0Tkj/SdXXFSEw6IN OIh4O6rw1r/z6C+A= X-Received: by 2002:a05:690c:6385:b0:81e:8985:402b with SMTP id 00721157ae682-81ef2671dcamr65627937b3.33.1784672886318; Tue, 21 Jul 2026 15:28:06 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: "Roberto A. Foglietta" Date: Wed, 22 Jul 2026 00:27:29 +0200 X-Gm-Features: AUfX_mw0Tp2dSiTViHye81-t80y7Pmcq3HbfDZhdZ3wSg1L_k-hnX6Lf65GRjzo Message-ID: Subject: Fwd: How busybox is using rand(), it can be an issue To: isar-users Content-Type: text/plain; charset="UTF-8" X-Original-Sender: roberto.foglietta@gmail.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20251104 header.b=N5qPz1KQ; arc=pass (i=1); spf=pass (google.com: domain of roberto.foglietta@gmail.com designates 2607:f8b0:4864:20::112a as permitted sender) smtp.mailfrom=roberto.foglietta@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com; dara=pass header.i=@googlegroups.com Precedence: list Mailing-list: list isar-users@googlegroups.com; contact isar-users+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: isar-users@googlegroups.com X-Google-Group-Id: 914930254986 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , X-Spam-Status: No, score=-3.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FORGED_GMAIL_RCVD, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2, RCVD_IN_RP_CERTIFIED,RCVD_IN_RP_RNBL,RCVD_IN_RP_SAFE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shymkent.ilbers.de X-TUID: CitaZN09ntC+ Hi, Working on shuf to validate a 3rd-party bugfix, I realised that BusyBox uses rand() in "best effort" despite some TODO and warnings being disseminated around. Others applets that uses rand() are (for example, but not an exhaustive list) zcip.c, > awk.c, ntpd.c, telnetd.c and tls.c Searching srand, and finding that busybox uses it since 2001 despite the fact that we know that rand() in some cases cannot even fill a 16 bit register. v5 --> v6: - even when rand() is limited to 15 bits but properly seeded, the new function random_in_range() passes PractRand RNG_test for a size of 8GB which is a dramatic improvement compared the current use of rand() in BusyBox in terms of randomness. Paradoxically some people out there that went crazy about uchaos as RNG, never took into consideration to audit how busybox TLS was using rand()... LOL busybox/testsuite$ ./rtest 0 0xffffffff $(( 1 << 31 )) | RNG_test stdin64 Passing 8GB is a good sign of pseudo-RNG and not necessarily a source of randomness based on true entropy. In fact, rand() requires being seeded by srand(). Every real-entropy randomness generator is able to self-seed itself (warm-up, not technically a seeding). static inline uint32_t random_in_range(uint32_t min, uint32_t max) { uint32_t r = (rand() % RAND_MAX); /* RAND_MAX can be as small as 32767 */ r ^= (uint32_t)(rand() % RAND_MAX) << 17; r ^= (uint32_t)(rand() % RAND_MAX) << 7; r *= murmul1; r ^= r >> 16; r %= max-min; r += min; return r; } static inline void srand_init(void) { struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); srand( ts.tv_sec ^ ts.tv_nsec ); } Anyway, the combo of random_in_range() and srand_init() are shocking for their relative simplicity. They are a bit more convoluted than the srand() / rand() combo but compared to passing 8GB in RNG_test, they are pretty simple. In fact changing shuf.c required 26 bytes of extra footprint. Moving these functions in libbb.a for general usage seems the most reasonable choice, at this point and unless confutation in some relevant cases (aka downstream testing). https://github.com/robang74/busybox/ /commit/edff9d2478733a8f0df6fc7d5c1ba0e3defc8db1 So the question is: are there specific cases in which testsuite/randtest.c fails? Best regards, -- Roberto A. Foglietta +49.176.274.75.661 +39.349.33.30.697 -- You received this message because you are subscribed to the Google Groups "isar-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/isar-users/CAJGKYO5qwMO4fv4Q_oSE-j-1iMo0r52qqo5UN7fGCUg9zWQxMw%40mail.gmail.com.