From patchwork Wed Dec 13 18:37:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 10110627 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 6A392602B3 for ; Wed, 13 Dec 2017 18:38:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C4F0289E2 for ; Wed, 13 Dec 2017 18:38:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5055328C7D; Wed, 13 Dec 2017 18:38:29 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 D51D0289E2 for ; Wed, 13 Dec 2017 18:38:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753151AbdLMSi2 (ORCPT ); Wed, 13 Dec 2017 13:38:28 -0500 Received: from mail-it0-f68.google.com ([209.85.214.68]:37214 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753051AbdLMSi1 (ORCPT ); Wed, 13 Dec 2017 13:38:27 -0500 Received: by mail-it0-f68.google.com with SMTP id d137so5075251itc.2 for ; Wed, 13 Dec 2017 10:38:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=KA9MXMVa0pUU+q/hSUWHFAkGdbzAO5XZVvfxEuRUI0o=; b=eHmnAkAKNuKmU5kJS6k9TqMrsDPAdF3ux1QYRS95x9INbuWXT7UmVby1HNfIZfSyR5 gs+RMzG0egflK1Ny42l0PL+CPCSGQgH6ESD4hyF9RGhdGJ5cpYFPvfGmx/dCjz0JMhqO X4IBbIQzh/sqJ8QMihbfpKvKvJdAoIR4VS/4wHuTG+H4CO/vWN2kSnXcQ1+CtcjM/+/X AasiLGJBnOdh3DipLJ34yQFVcfUx4um9g9/QPB/NhOrkVzFIENo6MQMDoLbBkEPuxiRk 4muakQW5T5Sr3PCa3fYHtBCLQd0yXFgTwMBWb8a1eSU/WcRsKp3w6tiOw4BDlBsipcnu ylOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=KA9MXMVa0pUU+q/hSUWHFAkGdbzAO5XZVvfxEuRUI0o=; b=gwyeWP0hLcpOZ29pN/0cj53CDD92UWA1H/vpBfVQRiphoAXiO02wlYs7DUVJlsyPGS LsPjkpxZqBKRfZ5PzJvRii+MzdHmGF3B6z+oNH2eCwJgicgMyJKLo/CB7CBt7KT7u43o Ngmg+xB2oFaKC3Z7Di9vQqpXOhA36F3cCmB1b46KUqR7fodO6mrpuzpoB7rNjyoKIElq zg/3WYR71zQ+KcEhqI9z7N791XVzMkZxzgS1ySiktdIHGuxwwmisKVJCzNM9I5BYa3L7 flH48Cnch957tYixk/o13G9LbPSCKf7TYYnNWmtQTT0D2E58Ccc71ZqJpe4T+Pa3ofry /Isg== X-Gm-Message-State: AKGB3mIxP2HJWJwjv/82rA6k80qusfNIWXU0WMltNokF2VMJXdjggg8Z tC0kFNYN2qXXZSk/4Ls8Dore19AnUvQ= X-Google-Smtp-Source: ACJfBoub/zHeJWxbjcdK3AeVpr4Kw2Lf5pmhfpBUwDz1HqpFUnkhRt45SdfbKs7cbKdYxP6NIZlmxA== X-Received: by 10.36.34.12 with SMTP id o12mr4055157ito.115.1513190306760; Wed, 13 Dec 2017 10:38:26 -0800 (PST) Received: from ebiggers-linuxstation.kir.corp.google.com ([100.66.175.88]) by smtp.gmail.com with ESMTPSA id c79sm1342571itd.21.2017.12.13.10.38.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 Dec 2017 10:38:26 -0800 (PST) From: Eric Biggers To: linux-fscrypt@vger.kernel.org, "Theodore Y . Ts'o" Cc: Jaegeuk Kim , Eric Biggers Subject: [PATCH] fscrypt: remove 'ci' parameter from fscrypt_put_encryption_info() Date: Wed, 13 Dec 2017 10:37:05 -0800 Message-Id: <20171213183705.195254-1-ebiggers3@gmail.com> X-Mailer: git-send-email 2.15.1.504.g5279b80103-goog 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 fscrypt_put_encryption_info() is only called when evicting an inode, so the 'struct fscrypt_info *ci' parameter is always NULL, and there cannot be races with other threads. This was cruft left over from the broken key revocation code. Remove the unused parameter and the cmpxchg(). Also remove the #ifdefs around the fscrypt_put_encryption_info() calls, since fscrypt_notsupp.h defines a no-op stub for it. Signed-off-by: Eric Biggers --- fs/crypto/keyinfo.c | 16 +++------------- fs/ext4/super.c | 4 +--- fs/f2fs/inode.c | 2 +- fs/ubifs/super.c | 4 +--- include/linux/fscrypt_notsupp.h | 3 +-- include/linux/fscrypt_supp.h | 2 +- 6 files changed, 8 insertions(+), 23 deletions(-) diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c index 5e6e846f5a24..4d75af57aa52 100644 --- a/fs/crypto/keyinfo.c +++ b/fs/crypto/keyinfo.c @@ -354,19 +354,9 @@ int fscrypt_get_encryption_info(struct inode *inode) } EXPORT_SYMBOL(fscrypt_get_encryption_info); -void fscrypt_put_encryption_info(struct inode *inode, struct fscrypt_info *ci) +void fscrypt_put_encryption_info(struct inode *inode) { - struct fscrypt_info *prev; - - if (ci == NULL) - ci = READ_ONCE(inode->i_crypt_info); - if (ci == NULL) - return; - - prev = cmpxchg(&inode->i_crypt_info, ci, NULL); - if (prev != ci) - return; - - put_crypt_info(ci); + put_crypt_info(inode->i_crypt_info); + inode->i_crypt_info = NULL; } EXPORT_SYMBOL(fscrypt_put_encryption_info); diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 7c46693a14d7..152d05d983f6 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1069,9 +1069,7 @@ void ext4_clear_inode(struct inode *inode) jbd2_free_inode(EXT4_I(inode)->jinode); EXT4_I(inode)->jinode = NULL; } -#ifdef CONFIG_EXT4_FS_ENCRYPTION - fscrypt_put_encryption_info(inode, NULL); -#endif + fscrypt_put_encryption_info(inode); } static struct inode *ext4_nfs_get_inode(struct super_block *sb, diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c index b4c4f2b25304..22a5607a0518 100644 --- a/fs/f2fs/inode.c +++ b/fs/f2fs/inode.c @@ -569,7 +569,7 @@ void f2fs_evict_inode(struct inode *inode) !exist_written_data(sbi, inode->i_ino, ORPHAN_INO)); } out_clear: - fscrypt_put_encryption_info(inode, NULL); + fscrypt_put_encryption_info(inode); clear_inode(inode); } diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 0beb285b143d..b16ef162344a 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -379,9 +379,7 @@ static void ubifs_evict_inode(struct inode *inode) } done: clear_inode(inode); -#ifdef CONFIG_UBIFS_FS_ENCRYPTION - fscrypt_put_encryption_info(inode, NULL); -#endif + fscrypt_put_encryption_info(inode); } static void ubifs_dirty_inode(struct inode *inode, int flags) diff --git a/include/linux/fscrypt_notsupp.h b/include/linux/fscrypt_notsupp.h index 63e58808519a..71cee8a431fc 100644 --- a/include/linux/fscrypt_notsupp.h +++ b/include/linux/fscrypt_notsupp.h @@ -90,8 +90,7 @@ static inline int fscrypt_get_encryption_info(struct inode *inode) return -EOPNOTSUPP; } -static inline void fscrypt_put_encryption_info(struct inode *inode, - struct fscrypt_info *ci) +static inline void fscrypt_put_encryption_info(struct inode *inode) { return; } diff --git a/include/linux/fscrypt_supp.h b/include/linux/fscrypt_supp.h index cf9e9fc02f0a..872f7514e63c 100644 --- a/include/linux/fscrypt_supp.h +++ b/include/linux/fscrypt_supp.h @@ -44,7 +44,7 @@ extern int fscrypt_inherit_context(struct inode *, struct inode *, void *, bool); /* keyinfo.c */ extern int fscrypt_get_encryption_info(struct inode *); -extern void fscrypt_put_encryption_info(struct inode *, struct fscrypt_info *); +extern void fscrypt_put_encryption_info(struct inode *); /* fname.c */ extern int fscrypt_setup_filename(struct inode *, const struct qstr *,