Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6163815iog; Thu, 23 Jun 2022 12:41:37 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tw0sl8S5BP+gUTYH70EivthD5MhuiiKv//zx+YR2aVXttstRnOYECOxH9XI8zRH5z6RFm0 X-Received: by 2002:a05:6402:606:b0:435:72af:4680 with SMTP id n6-20020a056402060600b0043572af4680mr12607977edv.224.1656013297526; Thu, 23 Jun 2022 12:41:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656013297; cv=none; d=google.com; s=arc-20160816; b=X+iKqStvgp6iab13ELfEowgUFnws3G7zDRMEdVCCmN7OhZ3QiXFbbiXtTX9J/JXWJ0 7kvhqKHPd+t28GN52WfJLYQagEyJka2L/SBYTNUoagLcj/Y/3C5vX13qEmxMdtWUtqbe pwDlcSsH+esVJBgtZxdU9s9wQ+h07nrTIEFB7yAgkEZmtseWufiBNdCKzSryDjU9kjjW 6xyWoXXT2Z5cMI06Mq8mdl8drfM1y7brUJoL5w2877Sd6J8cvA/UDTYONwQO237omqeI SY+iHOYo4Bqc4nrTMx5q/GSNYXuOtmDFQEn+YM7/+AYVcKmVpydg+FGdBeo6KFAEDihx aDuA== 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=KrPWxMJyAdJOhI1osU9RgqZ+wVkEhrBWbK7RJOAjMl8=; b=CzbgrFPUEGiSRdRB6aEhBbpqXkFbXCd5vUc6uxwxos2XPl7URHkHngw3Tw+yOjYIbF M+bJoewDxOGRcr3mVoe1NsxE78AjKcg2cfgzfR+uuoAfyz4a6E010E89P/Z5kJszl9BG yl9ZLmTkzMjvhlUea2VoVsg6MyAzzaVJP1FnJn9eQ3BuebPC6Bif6BfWjMWe8l8885mv PXh4En+fAK6IUZL4hUi0drmLRmDmMA090rtXoubVGurzY64jauqlGMoIXuzzA5BICDsa rSMczPjbiOj5HDL9tGvf4gzISUUJcuTMnnamP1t9S0uMvG82r6REaWFSt/YRa0jLcv95 h5HA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=NWL2BxHI; 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=NONE sp=NONE 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 f21-20020a0564021e9500b004357dec0f7csi522574edf.571.2022.06.23.12.41.12; Thu, 23 Jun 2022 12:41:37 -0700 (PDT) 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=NWL2BxHI; 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=NONE sp=NONE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231341AbiFWTdO (ORCPT + 99 others); Thu, 23 Jun 2022 15:33:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232269AbiFWTcv (ORCPT ); Thu, 23 Jun 2022 15:32:51 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5CCB4F44A; Thu, 23 Jun 2022 12:11:49 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id 78310B824BD; Thu, 23 Jun 2022 19:11:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88012C341C0; Thu, 23 Jun 2022 19:11:46 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="NWL2BxHI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1656011505; 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=KrPWxMJyAdJOhI1osU9RgqZ+wVkEhrBWbK7RJOAjMl8=; b=NWL2BxHIsjgB7FSRs2SCmcvc1J23o45nP0A2irXHHPKRoN4OWrL3Ph1NyqyJsa9Xfkr7k2 8B9kE2WwHm+RHTAnML+mn+5mJh9XzmMIZdVRsPl6gnlasznNhwig5kth0LqeVKujbO+MIn IvvYKmjIjlVXx/G0EZhMIvxYDxgnwU0= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 0599986e (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO); Thu, 23 Jun 2022 19:11:44 +0000 (UTC) Received: by mail-io1-f51.google.com with SMTP id p69so400756iod.10; Thu, 23 Jun 2022 12:11:44 -0700 (PDT) X-Gm-Message-State: AJIora/DRe+84mglFt3Hkzxmg57/um1uYCOkMBeMTy3fAm83eTsfH6Hi Q6qjMMB59+SWBXSCxB2Tc6MiYexh8WByeQFZzzs= X-Received: by 2002:a02:9709:0:b0:339:ef87:c30b with SMTP id x9-20020a029709000000b00339ef87c30bmr1720807jai.214.1656011503557; Thu, 23 Jun 2022 12:11:43 -0700 (PDT) MIME-Version: 1.0 References: <20220623190014.1355583-1-Jason@zx2c4.com> In-Reply-To: From: "Jason A. Donenfeld" Date: Thu, 23 Jun 2022 21:11:32 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3] timekeeping: contribute wall clock to rng on time change To: Eric Biggers Cc: LKML , Thomas Gleixner , Linux Crypto Mailing List , stable Content-Type: text/plain; charset="UTF-8" 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,T_SCC_BODY_TEXT_LINE 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, Jun 23, 2022 at 9:10 PM Eric Biggers wrote: > > On Thu, Jun 23, 2022 at 09:00:14PM +0200, Jason A. Donenfeld wrote: > > The rng's random_init() function contributes the real time to the rng at > > boot time, so that events can at least start in relation to something > > particular in the real world. But this clock might not yet be set that > > point in boot, so nothing is contributed. In addition, the relation > > between minor clock changes from, say, NTP, and the cycle counter is > > potentially useful entropic data. > > > > This commit addresses this by mixing in a time stamp on calls to > > settimeofday and adjtimex. No entropy is credited in doing so, so it > > doesn't make initialization faster, but it is still useful input to > > have. > > > > Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") > > Cc: stable@vger.kernel.org > > Signed-off-by: Jason A. Donenfeld > > --- > > kernel/time/timekeeping.c | 7 ++++++- > > 1 file changed, 6 insertions(+), 1 deletion(-) > > > > diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c > > index 8e4b3c32fcf9..49ee8ef16544 100644 > > --- a/kernel/time/timekeeping.c > > +++ b/kernel/time/timekeeping.c > > @@ -23,6 +23,7 @@ > > #include > > #include > > #include > > +#include > > > > #include "tick-internal.h" > > #include "ntp_internal.h" > > @@ -1343,8 +1344,10 @@ int do_settimeofday64(const struct timespec64 *ts) > > /* Signal hrtimers about time change */ > > clock_was_set(CLOCK_SET_WALL); > > > > - if (!ret) > > + if (!ret) { > > audit_tk_injoffset(ts_delta); > > + add_device_randomness(&ts, sizeof(ts)); > > + } > > It should be: > > add_device_randomness(ts, sizeof(*ts)); This simple patch... I swear I know C, I promise... Thanks again, and sorry. Jason