Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2669312rwb; Thu, 17 Nov 2022 14:20:20 -0800 (PST) X-Google-Smtp-Source: AA0mqf4blf3pCmVv6U+5RleWiVFTrbPQ4taF1rGtdkfesxoqVrDoHVAUTvj8Reoe+Cik1zXtYego X-Received: by 2002:a05:6402:1f89:b0:458:caec:8f1e with SMTP id c9-20020a0564021f8900b00458caec8f1emr3821978edc.280.1668723620555; Thu, 17 Nov 2022 14:20:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668723620; cv=none; d=google.com; s=arc-20160816; b=OabY0D/JOUaCThWg7h97fgDNlcwkqcAMTrwdz1KHlR9Nz7kUIOUMM8vtxkRIN1a6S8 KYSHGHT37Fx8qrsI2gbWWxzor2BXvyDyBNn7Qm7CQrodNWEX78t52BvQy+jZTpEbjMzc by7/9lP32vlJCShIpNnDBIdX5MK+UsC4M8TGP1/2TMqgaIj5W2FDbzimkjNTlrkINXWH /8J59fPsykMqhvnBGQlCWr0vtGD0let8FBcqfk2gGoq9PIZ7PaWAv0zOEspkzCIjn0z+ nhLaXfeCNAIJJKFO7kwqc3rZXC9fbqIf3y2qYko/27YlaPVyYY1U2EdhL32j3e2oA7k4 qHKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=vJhj9Z3si41Okh7QjFL8sfRqIMi0Yk5+ouF0KwmQggU=; b=f/7+6cJ0JnBKrKRYZKKiRDUF/dPH2TQZ7oNuGTPoUV16UMTKgH6EgGz1QUDsUt8gqg tXS0bdzoPugR3hR3VzBoLrm/8fPjhkYU6POUmXGijSQ0iN1vYNGmyqe+w90QWbIpWcDX DBrpjiK3tT5mf1DA4jupv+zI+tiXWioBWlTtNCaA9adQBF6E/zcsa9xNXR9YTH5AwfM1 +s+bvOSupZbCIdb2hnZdV4VKVK3kNckmrsJXaVH/H77VddfWN0JREjaDaXCmSE2zlsxZ yvT3lvpSSkHCE5/Vqx8IeXprzPQ4RuSjDYZ55TVoaXJQnzAvcM5eFVGfBoPZ4nHW6raQ Dmsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b="Q4bD/XUA"; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y11-20020a056402440b00b0046733d8f781si1995517eda.374.2022.11.17.14.19.52; Thu, 17 Nov 2022 14:20:20 -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; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b="Q4bD/XUA"; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231768AbiKQWLH (ORCPT + 99 others); Thu, 17 Nov 2022 17:11:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235100AbiKQWLE (ORCPT ); Thu, 17 Nov 2022 17:11:04 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C38CB6160; Thu, 17 Nov 2022 14:11:01 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5F1A26228C; Thu, 17 Nov 2022 22:11:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D29BC433C1; Thu, 17 Nov 2022 22:10:57 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="Q4bD/XUA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1668723055; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=vJhj9Z3si41Okh7QjFL8sfRqIMi0Yk5+ouF0KwmQggU=; b=Q4bD/XUAYdzoxgYLg+XIn4Lk+1x+8orB3IGL4+URLKCwS8OvQEFHtcJHobQ1IjE5hZQeq5 VnSTrX5zHZ2fE16n1KLU+eanYkc3vTgMFIfA+ELQ9AAw9UvTlkFM7FU8Z1ElmoQ046TyID RHhzi0IVhFVn9STyoQTnIxbYkGv6Iw8= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 1cf8d90d (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 17 Nov 2022 22:10:54 +0000 (UTC) Date: Thu, 17 Nov 2022 23:10:50 +0100 From: "Jason A. Donenfeld" To: Kees Cook Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Greg Kroah-Hartman , Jakub Kicinski , Russell King , Catalin Marinas , Thomas Bogendoerfer , Heiko Carstens , Herbert Xu , Christoph =?utf-8?Q?B=C3=B6hmwalder?= , Jani Nikula , Jason Gunthorpe , Sakari Ailus , "Martin K . Petersen" , Theodore Ts'o , 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 Subject: Re: [PATCH v3 3/3] treewide: use get_random_u32_inclusive() when possible Message-ID: References: <20221114164558.1180362-1-Jason@zx2c4.com> <20221117202906.2312482-1-Jason@zx2c4.com> <20221117202906.2312482-4-Jason@zx2c4.com> <202211171349.F42BA5B0@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <202211171349.F42BA5B0@keescook> X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 On Thu, Nov 17, 2022 at 01:57:13PM -0800, Kees Cook wrote: > The only comment I have is that maybe these cases can just be left as-is > with _below()? > > > - size_t len = get_random_u32_below(rs) + gs; > > + size_t len = get_random_u32_inclusive(gs, rs + gs - 1); > > It seems like writing it in the form of base plus [0, limit) is clearer? > > size_t len = gs + get_random_u32_below(rs); > > But there is only a handful, so *shrug* Okay, I'll drop that one. Jason