From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3F5F645EDE; Wed, 18 Dec 2024 18:03:12 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 70BF940F1A; Wed, 18 Dec 2024 18:03:11 +0100 (CET) Received: from mail.lysator.liu.se (mail.lysator.liu.se [130.236.254.3]) by mails.dpdk.org (Postfix) with ESMTP id 121B440DDE; Wed, 18 Dec 2024 18:03:10 +0100 (CET) Received: from mail.lysator.liu.se (localhost [127.0.0.1]) by mail.lysator.liu.se (Postfix) with ESMTP id 7585CC5B8; Wed, 18 Dec 2024 18:03:09 +0100 (CET) Received: by mail.lysator.liu.se (Postfix, from userid 1004) id 69618C4E1; Wed, 18 Dec 2024 18:03:09 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on hermod.lysator.liu.se X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=ALL_TRUSTED,AWL, T_SCC_BODY_TEXT_LINE autolearn=disabled version=4.0.0 X-Spam-Score: -1.2 Received: from [192.168.1.85] (h-62-63-215-114.A163.priv.bahnhof.se [62.63.215.114]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by mail.lysator.liu.se (Postfix) with ESMTPSA id 9065FC566; Wed, 18 Dec 2024 18:03:06 +0100 (CET) Message-ID: <45bc0287-8916-4c84-a0d8-5bc4ad2faed1@lysator.liu.se> Date: Wed, 18 Dec 2024 18:03:06 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 2/5] random: defer seeding to EAL init To: Stephen Hemminger , David Marchand Cc: dev@dpdk.org, thomas@monjalon.net, frode.nordahl@canonical.com, mattias.ronnblom@ericsson.com, anatoly.burakov@intel.com, stable@dpdk.org, Tyler Retzlaff , Bruce Richardson , Dmitry Kozlyuk , Chengwen Feng , =?UTF-8?Q?Morten_Br=C3=B8rup?= , Konstantin Ananyev References: <20241205175754.1673888-1-david.marchand@redhat.com> <20241217085954.3310414-1-david.marchand@redhat.com> <20241217085954.3310414-3-david.marchand@redhat.com> <20241218083502.266cd066@hermes.local> Content-Language: en-US From: =?UTF-8?Q?Mattias_R=C3=B6nnblom?= In-Reply-To: <20241218083502.266cd066@hermes.local> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: ClamAV using ClamSMTP X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On 2024-12-18 17:35, Stephen Hemminger wrote: > On Tue, 17 Dec 2024 09:59:49 +0100 > David Marchand wrote: > >> The RNG is documented as being seeded as part of EAL init. >> >> Move the initialisation (seeding) helper out of a constructor and >> call it explicitly from rte_eal_init() as it was done before commit >> 3f002f069612 ("eal: replace libc-based random generation with LFSR"). >> >> This also moves the unconditional lcore variable allocation out of a >> constructor. >> >> While at it, mark local symbol rand_state as static. >> >> Fixes: 29c39cd3d54d ("random: keep PRNG state in lcore variable") >> Cc: stable@dpdk.org >> >> Signed-off-by: David Marchand >> Reviewed-by: Mattias Rönnblom >> Acked-by: Anatoly Burakov > > Probably need to add a check to rte_random() so it crashes > if called before initialization, rather than returning an un-random > number which could be a hidden long term bug. If you do, do it either as a RTE_ASSERT() or an RTE_VERIFY() in the (lcore_id == LCORE_ID_ANY) path, since that is what will be taken. Preferably, you should have as little as possible in rte_rand() fast path, because this function is used in packet processing. That said, the "unrandom" number will always be 0, so it shouldn't go unnoticed for too long.