From patchwork Wed Nov 29 20:35:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 10083559 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 B39306020B for ; Wed, 29 Nov 2017 20:36:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A713429BFA for ; Wed, 29 Nov 2017 20:36:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9BBFC29BFC; Wed, 29 Nov 2017 20:36:53 +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 328E229BFD for ; Wed, 29 Nov 2017 20:36:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752499AbdK2Ugx (ORCPT ); Wed, 29 Nov 2017 15:36:53 -0500 Received: from mail-it0-f65.google.com ([209.85.214.65]:37098 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752305AbdK2Ugw (ORCPT ); Wed, 29 Nov 2017 15:36:52 -0500 Received: by mail-it0-f65.google.com with SMTP id d137so5766244itc.2 for ; Wed, 29 Nov 2017 12:36:52 -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:in-reply-to:references; bh=MLurCkKfJAsi4o+N9FViC9HZYy2enDrdExMXvNsXCrc=; b=l9qXkmOOLHBps7CK6KgzxvR7/jrF7jlH9je0cVWCdsbLySEOqTRZp4df/jM4albcSW cRNbVAsaA77wjgkcJQrhKCXRkrW6kyQ6T56HTH3PBzBevzeo+7C/+fwfYsupz5YbeUvF ypVkhF1TI72umlrqqWzqQRligu2FYAzh1wzdhbJw3ar8BfbCCLHK9FhS6m618hDkleKA 5Mpt3jjqnsN8j4nUzdnHl81s88NLp22ifAcmECci6yTc67uABNE2cvVYWyaKD4fSygxL bLa1lziCANOWfnoQ/PftG1aRZQlyv87kl5PLxzQl5V86Z0pneBhPKR4enuJInQr08DgR XINQ== 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:in-reply-to :references; bh=MLurCkKfJAsi4o+N9FViC9HZYy2enDrdExMXvNsXCrc=; b=FLpHLGm/lGPzGuAYQgsUix6Rs4khOSPeNej7GbljUkAEl8OBQEaAf+Lyr+o3zG446s 4VypodN3tSlCjHL4h/0/C5vKYt3UK7vGGlLMrBKnKHW9dD/QGRDSo7G5s8qyNhFw3kdi 1PlNqrZsYy5cEV6Amex5v5U+LzTCc+aS5WkxKs+ezK0Q6ahAay+JOBz/74mujDeVcEO0 13CT8lOAr9pksp55GN6VtSTiLCUR072tFQh3jWFZ7Jwodgd+dJQBPYpWcma9/LnkKdRY 4U4H198IgI5Zvh32fxgSQl8UiccBijqG8IY7epsQ42ZDPY1DrHNFRhFA53f4eX4KRpuV nGqg== X-Gm-Message-State: AJaThX6/ZJxzk+b8dF49zN6ngiy5UlbvYCPK9kJa7sgbjC310P9XDRZy lAZlGAQUTnmrSphw1WyXX/c= X-Google-Smtp-Source: AGs4zMbPSXyG9InH3qMubIDjqxQ407R0PW804cblYf6dCNWSm5BxuLK8Ffd7/DIYQcSBqVvqTqrp6A== X-Received: by 10.36.154.68 with SMTP id l65mr105238ite.150.1511987811664; Wed, 29 Nov 2017 12:36:51 -0800 (PST) Received: from ebiggers-linuxstation.kir.corp.google.com ([100.66.175.88]) by smtp.gmail.com with ESMTPSA id 15sm1149652ioj.80.2017.11.29.12.36.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Nov 2017 12:36:51 -0800 (PST) From: Eric Biggers To: linux-f2fs-devel@lists.sourceforge.net Cc: Jaegeuk Kim , Chao Yu , linux-fscrypt@vger.kernel.org, Eric Biggers Subject: [PATCH v2 1/5] f2fs: switch to fscrypt_file_open() Date: Wed, 29 Nov 2017 12:35:28 -0800 Message-Id: <20171129203532.87729-2-ebiggers3@gmail.com> X-Mailer: git-send-email 2.15.0.531.g2ccb3012c9-goog In-Reply-To: <20171129203532.87729-1-ebiggers3@gmail.com> References: <20171129203532.87729-1-ebiggers3@gmail.com> 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 Reviewed-by: Chao Yu Signed-off-by: Eric Biggers --- fs/f2fs/file.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 7874bbd7311d..ae2cf96190e4 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -472,22 +472,10 @@ static int f2fs_file_mmap(struct file *file, struct vm_area_struct *vma) static int f2fs_file_open(struct inode *inode, struct file *filp) { - struct dentry *dir; + int err = fscrypt_file_open(inode, filp); - if (f2fs_encrypted_inode(inode)) { - int ret = fscrypt_get_encryption_info(inode); - if (ret) - return -EACCES; - if (!fscrypt_has_encryption_key(inode)) - return -ENOKEY; - } - dir = dget_parent(file_dentry(filp)); - if (f2fs_encrypted_inode(d_inode(dir)) && - !fscrypt_has_permitted_context(d_inode(dir), inode)) { - dput(dir); - return -EPERM; - } - dput(dir); + if (err) + return err; return dquot_file_open(inode, filp); }