From nobody Thu Aug 01 22:27:23 2024 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WZk9R5XK3z5RZ4d; Thu, 01 Aug 2024 22:27:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WZk9R2Spzz4Yb2; Thu, 1 Aug 2024 22:27:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722551243; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=hu2k/QPGad3Bn/fo9WF7f4dpj8K4o5b8NrqfevrK600=; b=Ln3LPMAfL/ZWgE8YdYCVntw3SRmCDEbz08D6i+wmyNwWrzH7euPb4jnBJ7iniU2EdBr6bt mevSBvvAXRmX6n6rX/MbaO92Qw/6vPaIYV7EqjREzXrs8iLk927yxWYMN3KQ/+UMy6y1pt 5HaSlj23X+Rr6U+m7z8SL5+5w4HouWyOgJA4rBYmyV5DvoNNrp+jYtg5n1w7O1Gj+liZTD Q92dL9AZniaJbOseTJg5JCjOf65uHLaDd35wwp5GjAY0QaBh7FhfDJiqLR0f1aRScSWIt9 nVG++CNOcAVIFDAEP9iY79i5DJ0Dlq2UmjEZ5H+cBeWUeja1ahwXs6RpwkV6Gg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1722551243; a=rsa-sha256; cv=none; b=sYwa+fQX9nQ94tUEtrqaSrSeE3jIRx90kvwcOJxR5jQiDEYFn/8jqG1GIrUxAEw0f9anPB tWOOpLesyKp98Y6XxG2azfjy4sxvsdRrvN0yuhU6RpI9uu1za/eR+7otRR9hiLRyKzfNd0 5X/KRhcdsaq3KoSbkl9KC9OwnkY2+Pdfl/nlZ/tAj4nxB9s1dWz3ahWDbSTvRYFlIguZO2 DKRvN6m6U6IuD1ueFau81A/6CAOzKW6X6hrop1NSTmJMbEA69bPb8oD6qyEtXtDgg6Y6d8 6ec3m2miVj1nneUbA0cKLlrayjLBcjaNlQSksiPJ9D3gM08z1tNJgfnmpotTRw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722551243; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=hu2k/QPGad3Bn/fo9WF7f4dpj8K4o5b8NrqfevrK600=; b=Vf0z5FMsddiQq6rhkbF9KDQ9J5xe+tLxHECHnNyiaZHiEignWrl+UACUOvmfIzj2q40/Nh 5tRTeGIstf+I8KD4SWt2AbkCpjFQTLLlArcCJxaTV5donfZox15IFSUHN/YMoy7nQNzW0J DIS9bXrkU/cRJAgvHA//otqc5gAVkTCaBCDwu5rJeLK4QiwHyePYA554X1GE1G6p6nEh33 Mydzk38KTPHGE5xN2VSd8p4aytTQCvzKZVF+i/iVKJSY9Er4TK21Uyh3J0CL5WmJxezz+k ADnKdfgeXjV1aV/8wALZK/fUzpeZW6HQXdZiAXVbRq8r8hn63kHH9lKnjlcSeQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4WZk9R22S0z12tG; Thu, 1 Aug 2024 22:27:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 471MRNvI026923; Thu, 1 Aug 2024 22:27:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 471MRNsw026920; Thu, 1 Aug 2024 22:27:23 GMT (envelope-from git) Date: Thu, 1 Aug 2024 22:27:23 GMT Message-Id: <202408012227.471MRNsw026920@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: 4242e224e6b7 - stable/14 - LinuxKPI: Add get_random_u32_below function List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 4242e224e6b7d00020a9fcee9bc020d0816630df Auto-Submitted: auto-generated The branch stable/14 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=4242e224e6b7d00020a9fcee9bc020d0816630df commit 4242e224e6b7d00020a9fcee9bc020d0816630df Author: Vladimir Kondratyev AuthorDate: 2024-04-08 06:47:42 +0000 Commit: Vladimir Kondratyev CommitDate: 2024-08-01 21:09:38 +0000 LinuxKPI: Add get_random_u32_below function get_random_u32_below returns a random integer in the interval [0, ceil), with uniform distribution. Sponsored by: Serenity CyberSecurity, LLC Reviewed by: emaste MFC after: 1 week (cherry picked from commit 9289c1f6f1514e714b17026c50ec09282f079cba) --- sys/compat/linuxkpi/common/include/linux/random.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/random.h b/sys/compat/linuxkpi/common/include/linux/random.h index e87d4412ea4e..808c5bc55974 100644 --- a/sys/compat/linuxkpi/common/include/linux/random.h +++ b/sys/compat/linuxkpi/common/include/linux/random.h @@ -96,6 +96,12 @@ get_random_u64(void) return (val); } +static inline uint32_t +get_random_u32_below(uint32_t max) +{ + return (arc4random_uniform(max)); +} + static __inline uint32_t prandom_u32(void) {