From patchwork Wed Jun 7 18:16:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 9772175 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0E54360364 for ; Wed, 7 Jun 2017 18:16:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE228283BA for ; Wed, 7 Jun 2017 18:16:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E2E5928418; Wed, 7 Jun 2017 18:16:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5125F283BA for ; Wed, 7 Jun 2017 18:16:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751722AbdFGSQK (ORCPT ); Wed, 7 Jun 2017 14:16:10 -0400 Received: from frisell.zx2c4.com ([192.95.5.64]:53441 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751717AbdFGSQJ (ORCPT ); Wed, 7 Jun 2017 14:16:09 -0400 Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 2e203ea2; Wed, 7 Jun 2017 18:15:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=mime-version :in-reply-to:references:from:date:message-id:subject:to:cc :content-type; s=mail; bh=TuI5t4bEWiFKxcMZmQY2/6O1XGc=; b=UoO3j4 T5e1i2tKhIRE/zUYlcFDV3c9H4DvG0/xWL3+lk5Vj77gE72OgkphqfDSZYqNSQrm NQuUOl7oW8A0iDxTcE5PUq6GjegRT9kxsctV92H+WLoL9LmzKZ4BsNj+5qpljzQW Mor5GkRPKKVUXT0eIbOgKu/rxn3O9Bx6TAWn13QeaF3L2RXqNvttEH3RVpr3XbS3 89eucX/R+FW2rMHEcoTcoNKXJxAKBvA+xgcTiL1dx5MQFgym0AyLrBqivjO4I+QO KoffMMBSlX7x6hEp8QMliuoBlNxZcyykBCV/+DDH8i10/K4jc4WLma/U1KKYYMtA pxq8dVWSfSzXODSA== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 03e5ec49 (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128:NO); Wed, 7 Jun 2017 18:15:39 +0000 (UTC) Received: by mail-ot0-f180.google.com with SMTP id i31so11364836ota.3; Wed, 07 Jun 2017 11:16:07 -0700 (PDT) X-Gm-Message-State: AKS2vOyOwufg26SqmIJngv1IRj2bX1jfmi3TX7RBEPY7ciYp8bcLqBCr +DGiF66n+LZiVycnDnd7h621Q+Z+mQ== X-Received: by 10.157.31.71 with SMTP id x7mr20274680otx.249.1496859365882; Wed, 07 Jun 2017 11:16:05 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.17.129 with HTTP; Wed, 7 Jun 2017 11:16:05 -0700 (PDT) In-Reply-To: <201706080107.xhkKszte%fengguang.wu@intel.com> References: <20170606005108.5646-4-Jason@zx2c4.com> <201706080107.xhkKszte%fengguang.wu@intel.com> From: "Jason A. Donenfeld" Date: Wed, 7 Jun 2017 20:16:05 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 03/13] random: invalidate batched entropy after crng init To: kbuild test robot Cc: kbuild-all@01.org, "Theodore Ts'o" , Linux Crypto Mailing List , LKML , kernel-hardening@lists.openwall.com, Greg Kroah-Hartman , David Miller Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Strange, not all compilers do this warning. Fixing with: #if BITS_PER_LONG == 64 @@ -2099,8 +2099,8 @@ static DEFINE_PER_CPU(struct batched_entropy, batched_entropy_u32); u32 get_random_u32(void) { u32 ret; - bool use_lock = crng_init < 2; - unsigned long flags; + const bool use_lock = READ_ONCE(crng_init) < 2; + unsigned long flags = 0; struct batched_entropy *batch; if (arch_get_random_int(&ret)) Const, because it's more correct. READ_ONCE to be certain that the compiler doesn't try to paste the expression into both uses. And finally flags=0 to shutup the compiler. If anybody has a better way of approaching this, feel free to chime in. diff --git a/drivers/char/random.c b/drivers/char/random.c index 12758db..5252690 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -2061,8 +2061,8 @@ static DEFINE_PER_CPU(struct batched_entropy, batched_entropy_u64); u64 get_random_u64(void) { u64 ret; - bool use_lock = crng_init < 2; - unsigned long flags; + const bool use_lock = READ_ONCE(crng_init) < 2; + unsigned long flags = 0; struct batched_entropy *batch;