From patchwork Mon Mar 18 17:24:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 10858271 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C10D5139A for ; Mon, 18 Mar 2019 17:25:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A06E28F40 for ; Mon, 18 Mar 2019 17:25:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C2A128F5A; Mon, 18 Mar 2019 17:25: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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 447C028F40 for ; Mon, 18 Mar 2019 17:25:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727243AbfCRRZK (ORCPT ); Mon, 18 Mar 2019 13:25:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:44918 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726704AbfCRRZK (ORCPT ); Mon, 18 Mar 2019 13:25:10 -0400 Received: from ebiggers-linuxstation.mtv.corp.google.com (unknown [104.132.1.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EDAF920854; Mon, 18 Mar 2019 17:25:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552929910; bh=Mzz8h//XVemd9JvhWZByDGydmf26oG3B7E658agQzAE=; h=From:To:Cc:Subject:Date:From; b=v4L7n7zjF2gIWGTICf/H2ZnIaBHqfwH7Y8DrBz/lVe+RarNW9s+/6k/5b8mF1GtZh U5uiKP9WSPVSePqXsVCC5XrQ2AKjav/HBvHGUSNYdgZ080LZCALol/avT0P7i/r4N/ eUHNc3tF87Sob+QixtKh+wheScW+VUi+j4xkNthY= From: Eric Biggers To: linux-fscrypt@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org Subject: [PATCH] fscrypt: add memory barrier when loading essiv_hash_tfm Date: Mon, 18 Mar 2019 10:24:54 -0700 Message-Id: <20190318172454.240412-1-ebiggers@kernel.org> X-Mailer: git-send-email 2.21.0.225.g810b269d1ac-goog MIME-Version: 1.0 Sender: linux-fscrypt-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fscrypt@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Biggers Load 'essiv_hash_tfm' using smp_load_acquire() to guarantee that the struct crypto_shash is seen as fully initialized before being used. Signed-off-by: Eric Biggers --- fs/crypto/keyinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c index ba74dafa18a3..d1f0f8369d51 100644 --- a/fs/crypto/keyinfo.c +++ b/fs/crypto/keyinfo.c @@ -379,7 +379,7 @@ fscrypt_get_master_key(const struct fscrypt_info *ci, struct fscrypt_mode *mode, static int derive_essiv_salt(const u8 *key, int keysize, u8 *salt) { - struct crypto_shash *tfm = READ_ONCE(essiv_hash_tfm); + struct crypto_shash *tfm = smp_load_acquire(&essiv_hash_tfm); /* init hash transform on demand */ if (unlikely(!tfm)) {