Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1283508pxb; Fri, 21 Jan 2022 14:18:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJz8pg7rVa7TwWDyMSj4dbidZMVk9IWnjoH0575bsQYot418ULOQ5lvM2z8MPnqa/gtRGJa5 X-Received: by 2002:a17:90b:224a:: with SMTP id hk10mr2679189pjb.83.1642803509277; Fri, 21 Jan 2022 14:18:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642803509; cv=none; d=google.com; s=arc-20160816; b=nhWCk+wYBhvdidqxGO5GbN4QzfBemMqPuPmlCaqFBjcHfvjYGd6c63sr8T3zDIte0s sStkX+GuW+0KRvoK/cnSCjh8Xcw61eQMbc2tUkfZKjGNLRZEYQPYTxOW71MSt59eujcI iKKdfkDnwdb90TC+HOLvxMhxTV0NQE7+qRtFw+8omgyVNdAm93jRyn6kXtbY9Xlu0h+5 OH73eMV7m9S/LIGgyEvG8TU/GMBfdVnRAlyQnqgxKjjhw9LDRzgXREW9C5URygKbXkuM QuHSMZNtx1Ir0u2KAmpFJoOF1AJMIDCSecoimdk+EZ6DZ/FpEaHVay7HGnMHIAgCJHEE co/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=DcwDRP0dP9OA/GQEOpitTE09xlkAhrUZn3ox+C9GSoY=; b=cnsBa/6BuRDqvGBZw+cDILaPK6gSc1VIkfzzonQ2hZxesdoRUDDbXlwtnC6pxMHS1r 4fAlsbkpD7FddiawC2PtBNWOcwMQLe1eIbwhrmatLVnKoHoPBXIVazyQkSvlWYhgJD/3 IKV5yQamPjfPXTB5L+v0ZCY+olu0RROHEHzkftZFxN9w1QVcC7t/w0oRLoUglf6nKThV 3Yje97TPBGWXo1hILg1mcli3jrhrX8aJb2+wHdBQlgrR0WJTuAze8dn4WVbIvpMo66z3 JugHlQ/b4ZyL2DULjZkmUvQwS9UqqGDMo1QkWzm17gh0bkU0kVcJZ6o9Y338OE+1vb4G 0+2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=iMVOSBZK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a15si6493722pls.313.2022.01.21.14.18.17; Fri, 21 Jan 2022 14:18:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=iMVOSBZK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346164AbiATPEB (ORCPT + 99 others); Thu, 20 Jan 2022 10:04:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233532AbiATPD4 (ORCPT ); Thu, 20 Jan 2022 10:03:56 -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 5BB53C061574 for ; Thu, 20 Jan 2022 07:03:56 -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 EDAC961811 for ; Thu, 20 Jan 2022 15:03:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CA00C340E9 for ; Thu, 20 Jan 2022 15:03:55 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="iMVOSBZK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1642691033; 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=DcwDRP0dP9OA/GQEOpitTE09xlkAhrUZn3ox+C9GSoY=; b=iMVOSBZK4KEG+CUCuW4emWG+Lw0L+sQuqOaW+WDcYwfsOd9woRtnWIa8CMGP20pasCCP+S 44MXtdn2vaWdoQYcQ0uskL0VqtcqJurm+aocqwQdnWUij3uyNCyskV3Xcg41LiPGjGZTwp SDvg+r51Yh8eAv5nGTBcVDZzTDFTj/A= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id e93442dd (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO) for ; Thu, 20 Jan 2022 15:03:53 +0000 (UTC) Received: by mail-yb1-f180.google.com with SMTP id r65so15040033ybc.11 for ; Thu, 20 Jan 2022 07:03:52 -0800 (PST) X-Gm-Message-State: AOAM533vShdV8iEesTPUJup7Isc1NHnOX43aZA7Q/H2dlNbt0wvh8KSM y/2aCuWqapBh91eK8E4UwhacOIS2IW8Hib/RnWw= X-Received: by 2002:a25:244b:: with SMTP id k72mr9048574ybk.638.1642691032219; Thu, 20 Jan 2022 07:03:52 -0800 (PST) MIME-Version: 1.0 References: <20211231114903.60882-1-Jason@zx2c4.com> In-Reply-To: From: "Jason A. Donenfeld" Date: Thu, 20 Jan 2022 16:03:41 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] random: avoid superfluous call to RDRAND in CRNG extraction To: "Theodore Ts'o" Cc: LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 4, 2022 at 6:55 AM Theodore Ts'o wrote: > If we want to worry about what happens if we could actually manage to > call _extract_crng() more than 2**64 times before the reseed interval > is up --- which *is* one of the benefits of: > > if (arch_get_random_long(^v)) > crng->state[14] ^= v; > > I could see doing perhaps this instead: > > if (crng->state[12] == 0) { > crng->state[13]++; > if (crng->state[13] == 0) { > crng->state[14]++; > if (crng->state[14] == 0) { > crng->state[15]++; > } > } > } While probably overkill, I've got a patch that does this while also labeling these constants. I'll send that as a reply to this message. Jason