Received: by 10.192.165.148 with SMTP id m20csp922965imm; Fri, 27 Apr 2018 09:37:31 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq1QjS8HUREU4MMZWz6Lv4FYG1iERg6ieSIanfdKavYaku0Wh3yoH3iw2lO+f/n7uXpjfAB X-Received: by 2002:a17:902:2bc5:: with SMTP id l63-v6mr2823730plb.299.1524847051869; Fri, 27 Apr 2018 09:37:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524847051; cv=none; d=google.com; s=arc-20160816; b=FI8XQ6+482Jb0Nlpt/756/qGHXDOilnKj4uwkvNWd4xg/WE11RWGWwd67uKMIbXebV jydujpXLOrj/EZxpdCneVJhF/VfxrTQ+lG2gkCsNd23xes2S5NDYOrJ3iGEV7aiqM7Gv 5CfhZqZ6nrdo8/GCLWsVfXzZQ/HiWtzRT0lqlqyFpZqlH6W4vOxFsqN8heweCFqns9ot D6WaREfaXsk9bcxGvALwpgN6o6zadS4CgXWWgh/50b0y3ZCqopQZzzsspCs7wa4dlCtu s7pSXcBp3KfrJhROwRwAKbDWDIfJhdm3+I/YVxlks+ANsIvaIkw6+zKKUPJfz0LM3fr9 ajSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=oFywfgTXT+dWZgWENVhDCqJuJymwTpwuyetSq0LB3VM=; b=GCsWgIZYhbrzljYctsBukLQ08qvreYtxYxIgjMo3HL2tOy1TQowolgoQ6PM2mld0BL POq0McZJg9fU+AkAMangP8WrvwysiT0egcFNIj0+HKqzZva58W+X1y+23m+tEQQDgKeE JlCmI83LzcVD2+LTyHYtRwO+eOQ1AdzrB//n8j5bYjSC0tsjUJPexTdKBWjyVuF/IBe5 cnOrB7tp5jrOAsEE+mU2FAUiMcuRYsN+rRpPmf4VMdxgx1GXinoqbxHjFtVbD/u9R0Jt Fl7j0ixHEwzvZu6L215W8C/RyUVsjxCxKk4q5OsGkDz/BpbHOM92f7Vo4rypgdppqe73 9rmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dq9IqEbV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j63-v6si1465366pgc.474.2018.04.27.09.37.17; Fri, 27 Apr 2018 09:37:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dq9IqEbV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758800AbeD0Qev (ORCPT + 99 others); Fri, 27 Apr 2018 12:34:51 -0400 Received: from mail-it0-f66.google.com ([209.85.214.66]:52999 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758785AbeD0Qep (ORCPT ); Fri, 27 Apr 2018 12:34:45 -0400 Received: by mail-it0-f66.google.com with SMTP id f6-v6so2620017ita.2 for ; Fri, 27 Apr 2018 09:34:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=oFywfgTXT+dWZgWENVhDCqJuJymwTpwuyetSq0LB3VM=; b=dq9IqEbVxBjZUuFgVCPDDJeILq2ZxKvedI/TDnhvUZEUvFBTnj+/9hmiVqBiO1CGpz NamUCIQA6fNwQ/1qHLPqQV7XAVwI6SW0DtwAtacLVRGZCjoEjgdwMoFBbEJHf08YmeNE +Cz0z9xTpMmW8VWlvhSfWiWvHI8k3VzdmmwLs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=oFywfgTXT+dWZgWENVhDCqJuJymwTpwuyetSq0LB3VM=; b=hf6KdxELsx0mOmMJCvbv3TxDk8z9JAoJg3jyVikMLD9RVPaASlVHdc/RVOpISlhE2r aXA+0Ym+e+qnBpFlbANJZWFwjY3rp2bUI8eZGTNdbNhEUSEW5PwebVqTWQ2wTSPLGze7 IWywvfmITsIVJsdjmd9xnyiEXi7MBIKuh/D+3sTFcIeYAeeKxIwI8PKDSGD0Orp6RYmP HWkExqvwMcsV2HsWF3kg3DjSS55daV1rfos+QjakZlaaxN2fKDnMxoJ6Tv4dPskmdSjg BWP2iEG4yHpnRv8MLUdwGVNkMqn28KD9VAPyzCd7PqnhlbYduyCkzisNT3tJgXOaNVGg oOAA== X-Gm-Message-State: ALQs6tCoJUNYsOoJdXYfrR0Qr672T0973U4cFnSEyCdiRYc3CaS/GVwz Uu38zatjM1/QzRZ+FdzqemDLZgKBhWc= X-Received: by 2002:a24:9ac1:: with SMTP id l184-v6mr2612054ite.127.1524846884341; Fri, 27 Apr 2018 09:34:44 -0700 (PDT) Received: from localhost (c-68-47-89-210.hsd1.mn.comcast.net. [68.47.89.210]) by smtp.gmail.com with ESMTPSA id r1-v6sm709457ioc.57.2018.04.27.09.34.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Apr 2018 09:34:43 -0700 (PDT) Date: Fri, 27 Apr 2018 11:34:43 -0500 From: Dan Rue To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Jann Horn , Theodore Tso , stable@kernel.org, Thierry Escande , Nicolas Dechesne Subject: Re: [PATCH 4.16 163/196] random: fix crng_ready() test Message-ID: <20180427163443.fdsixdsrwwkycuhh@xps> Mail-Followup-To: Greg Kroah-Hartman , linux-kernel@vger.kernel.org, stable@vger.kernel.org, Jann Horn , Theodore Tso , stable@kernel.org, Thierry Escande , Nicolas Dechesne References: <20180422135104.278511750@linuxfoundation.org> <20180422135112.655853962@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180422135112.655853962@linuxfoundation.org> User-Agent: NeoMutt/20180323 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Apr 22, 2018 at 03:53:03PM +0200, Greg Kroah-Hartman wrote: > 4.16-stable review patch. If anyone has any objections, please let me know. > > ------------------ > > From: Theodore Ts'o > > commit 43838a23a05fbd13e47d750d3dfd77001536dd33 upstream. > > The crng_init variable has three states: > > 0: The CRNG is not initialized at all > 1: The CRNG has a small amount of entropy, hopefully good enough for > early-boot, non-cryptographical use cases > 2: The CRNG is fully initialized and we are sure it is safe for > cryptographic use cases. > > The crng_ready() function should only return true once we are in the > last state. This addresses CVE-2018-1108. > > Reported-by: Jann Horn > Fixes: e192be9d9a30 ("random: replace non-blocking pool...") > Cc: stable@kernel.org # 4.8+ > Signed-off-by: Theodore Ts'o > Reviewed-by: Jann Horn > Signed-off-by: Greg Kroah-Hartman This patch has caused a regression on 4.16 using kselftest lib/printf.sh - specifically, when it runs "/sbin/modprobe test_printf". This regression has been detected on arm64 dragonboard 410c (not seen on other arm64 or x86_64 devices). /sbin/modprobe test_printf [ 22.725551] test_printf: hashing plain 'p' has unexpected format [ 22.726031] test_printf: failed 1 out of 236 tests modprobe: ERROR: could not insert 'test_printf': Invalid argument This problem has not been seen on 4.9 or 4.14 under the same conditions. Dan > > --- > drivers/char/random.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > --- a/drivers/char/random.c > +++ b/drivers/char/random.c > @@ -427,7 +427,7 @@ struct crng_state primary_crng = { > * its value (from 0->1->2). > */ > static int crng_init = 0; > -#define crng_ready() (likely(crng_init > 0)) > +#define crng_ready() (likely(crng_init > 1)) > static int crng_init_cnt = 0; > #define CRNG_INIT_CNT_THRESH (2*CHACHA20_KEY_SIZE) > static void _extract_crng(struct crng_state *crng, > @@ -793,7 +793,7 @@ static int crng_fast_load(const char *cp > > if (!spin_trylock_irqsave(&primary_crng.lock, flags)) > return 0; > - if (crng_ready()) { > + if (crng_init != 0) { > spin_unlock_irqrestore(&primary_crng.lock, flags); > return 0; > } > @@ -855,7 +855,7 @@ static void _extract_crng(struct crng_st > { > unsigned long v, flags; > > - if (crng_init > 1 && > + if (crng_ready() && > time_after(jiffies, crng->init_time + CRNG_RESEED_INTERVAL)) > crng_reseed(crng, crng == &primary_crng ? &input_pool : NULL); > spin_lock_irqsave(&crng->lock, flags); > @@ -1141,7 +1141,7 @@ void add_interrupt_randomness(int irq, i > fast_mix(fast_pool); > add_interrupt_bench(cycles); > > - if (!crng_ready()) { > + if (unlikely(crng_init == 0)) { > if ((fast_pool->count >= 64) && > crng_fast_load((char *) fast_pool->pool, > sizeof(fast_pool->pool))) { > @@ -2214,7 +2214,7 @@ void add_hwgenerator_randomness(const ch > { > struct entropy_store *poolp = &input_pool; > > - if (!crng_ready()) { > + if (unlikely(crng_init == 0)) { > crng_fast_load(buffer, count); > return; > } > >