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: 9772179 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 3F3E360364 for ; Wed, 7 Jun 2017 18:16:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C584283BA for ; Wed, 7 Jun 2017 18:16:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2110028418; Wed, 7 Jun 2017 18:16:25 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 0F901283BA for ; Wed, 7 Jun 2017 18:16:23 +0000 (UTC) Received: (qmail 25754 invoked by uid 550); 7 Jun 2017 18:16:21 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 25720 invoked from network); 7 Jun 2017 18:16:20 -0000 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== X-Gm-Message-State: AKS2vOwjmDFVL9RZMHD9VloqP3VmWOGxjrvdcFYcIWeWOca0uSLV9RWY bYJRZSUH8h0fGgxS0iQslRoSg2EkqQ== 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 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: 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 Subject: [kernel-hardening] Re: [PATCH v3 03/13] random: invalidate batched entropy after crng init 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;