Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2669406rwb; Thu, 17 Nov 2022 14:20:27 -0800 (PST) X-Google-Smtp-Source: AA0mqf5fQnJEThpYD8RLuvzuCN4sjcqfpnvm3UGpArxxwwx4RV4pQIKenZBNqSawInIqvoAYWlxs X-Received: by 2002:a17:906:50f:b0:78d:ad5d:75e with SMTP id j15-20020a170906050f00b0078dad5d075emr3795935eja.172.1668723627285; Thu, 17 Nov 2022 14:20:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668723627; cv=none; d=google.com; s=arc-20160816; b=YJ8zC8XdAy7wdxecqo6m1NaVoLqZmIkSrBSHIzYgmohpAdKY1vcMZPsqGp0a6Io3Y2 byghm+ubiATNPCWwlOpN9K2TxKb5rieOmIEGR3I92ek9KGwj8MfTkdS6bv3c3KwWRmcK JUw71138JH2FNYU83uRAO+winq/3UAIQpriUI1uOoir0EHRtcpvDRr0emQwqr2u6h8ba 1+NsGIGW8vOMwB6qkiMnmZ6NG7Re1WjMiTyICHsDZgoe4cIDPdU0Lt0900sMIWePw5T+ p1ENf/NWQqaFQvMA/keKfn6LOMHJpWLBGBsdl7IdTSezz1ouv3NO475AVgD7gxQfcOZ6 4opw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=rygZyfEpYaYVAJ9tCSA8umSS8Q+isKY6szTsi+gSRs0=; b=pD2619UI2r+z8Hl+gKtRo8bnzMvzoZL/6Qs89iV7IF3eP6QvoA/c2/5PepRJmiMfhl vVVnW4tnOONdVSOe1OAu95l7eAIpsGSKinzYBmDJ9AP3yoGqjs1lHfpIN0yhF5M0a/Gt 4eL2AVwD541ssJDSSI4a/MyHj+vCr6VDVZoJrp2cPOt1/HdXbf9OLyGt2ijmDp9vC7Cr SM0UAk4REnY4H5Oeizw+cZgLThuK7oCnX/b48y08yweP3HmXvxdW0xAFaRpPNp4wa8Fk t0L2WZLWcWexBVChtSBxda1vQDn19nns+VnI5UA8llnLII91sTFLX/l8I7XbgGpzN/YJ cGsw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s15-20020a170906c30f00b007316843d58bsi1292287ejz.925.2022.11.17.14.20.03; Thu, 17 Nov 2022 14:20:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235002AbiKQWPw convert rfc822-to-8bit (ORCPT + 99 others); Thu, 17 Nov 2022 17:15:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240397AbiKQWPr (ORCPT ); Thu, 17 Nov 2022 17:15:47 -0500 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 302C47AF52 for ; Thu, 17 Nov 2022 14:15:41 -0800 (PST) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-135-r8pLcNsHMNSPwdstNZNmIw-1; Thu, 17 Nov 2022 22:15:38 +0000 X-MC-Unique: r8pLcNsHMNSPwdstNZNmIw-1 Received: from AcuMS.Aculab.com (10.202.163.4) by AcuMS.aculab.com (10.202.163.4) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 17 Nov 2022 22:15:36 +0000 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.044; Thu, 17 Nov 2022 22:15:36 +0000 From: David Laight To: 'Theodore Ts'o' , Kees Cook CC: "Jason A. Donenfeld" , Kees Cook , "linux-kernel@vger.kernel.org" , "patches@lists.linux.dev" , Greg Kroah-Hartman , Jakub Kicinski , Russell King , Catalin Marinas , "Thomas Bogendoerfer" , Heiko Carstens , Herbert Xu , =?iso-8859-1?Q?Christoph_B=F6hmwalder?= , Jani Nikula , Jason Gunthorpe , Sakari Ailus , "Martin K . Petersen" , Andreas Dilger , Jaegeuk Kim , Richard Weinberger , "Darrick J . Wong" , SeongJae Park , "Thomas Gleixner" , Andrew Morton , Michael Ellerman , Helge Deller , "netdev@vger.kernel.org" , "linux-crypto@vger.kernel.org" , "linux-block@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-media@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "loongarch@lists.linux.dev" , "linux-mips@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "linux-mmc@vger.kernel.org" , "linux-parisc@vger.kernel.org" , "ydroneaud@opteya.com" Subject: RE: [PATCH v2 3/3] treewide: use get_random_u32_between() when possible Thread-Topic: [PATCH v2 3/3] treewide: use get_random_u32_between() when possible Thread-Index: AQHY+pt8WAMBAHgXDk6lkwvXqmmyGK5DraKg Date: Thu, 17 Nov 2022 22:15:36 +0000 Message-ID: <5b2afac148e24181a206e540768e465b@AcuMS.aculab.com> References: <20221114164558.1180362-1-Jason@zx2c4.com> <20221114164558.1180362-4-Jason@zx2c4.com> <202211161436.A45AD719A@keescook> <202211161628.164F47F@keescook> <0EE39896-C7B6-4CB6-87D5-22AA787740A9@kernel.org> In-Reply-To: Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,PDS_BAD_THREAD_QP_64, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Theodore Ts'o > Sent: 17 November 2022 15:43 ... > The problem with "between", "ranged", "spanning" is that they don't > tell the reader whether we're dealing with an "open interval" or a > "closed interval". They are just different ways of saying that it's a > range between, say, 0 and 20. But it doesn't tell you whether it > includes 0 or 20 or not. > > The only way I can see for making it ambiguous is either to use the > terminology "closed interval" or "inclusive". And "open" and "closed" > can have other meanings, so get_random_u32_inclusive() is going to be > less confusing than get_random_u32_closed(). It has to be said that removing the extra function and requiring the callers use 'base + get_random_below(high [+1] - base)' is likely to be the only way to succinctly make the code readable and understandable. Otherwise readers either have to look up another function to see what it does or waste variable brain cells on more trivia. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)