From patchwork Wed Sep 20 22:45:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 9962791 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 BFAA06057C for ; Wed, 20 Sep 2017 22:47:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B1D7D2924A for ; Wed, 20 Sep 2017 22:47:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A5EC929274; Wed, 20 Sep 2017 22:47:46 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 5C30329158 for ; Wed, 20 Sep 2017 22:47:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752019AbdITWrQ (ORCPT ); Wed, 20 Sep 2017 18:47:16 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:36388 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751899AbdITWrJ (ORCPT ); Wed, 20 Sep 2017 18:47:09 -0400 Received: by mail-pf0-f194.google.com with SMTP id f84so1721686pfj.3; Wed, 20 Sep 2017 15:47:09 -0700 (PDT) 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=lWFOShztuG2e44vH8e1SgZf/UIwGJpJgCSa+VYbcXO4=; b=NgTwGUYdOUjO/fXYhw2ld4SZkileaQ+9XFm1uzpt1ObOHN8vIXW0004SALfA4k007s PCFsFkaugfIbP8yXm+ZELQwbLOEkIbInasImNw1YyHLI3XBxjHIHw6WGeN5hyYIPv23r 3LsyS2uuNyTW1OUMiihUrHx55OXiFC9RbTZKLFz3FBgkQoufFhWiY6MXhIWRHKPMu6Vz BgIi7W4FuVgqogVoh4EJW3BBj6wWvoKPb62LRJ1W+ood82UvFWdDR2wgls5zblDDuapX nyosoWThF9ByPpEYZ9nIxiR7VOnuCTAa5r3qn434zDgGiKR8PgHhy9GiwrAz9X2dtn7N iZKg== 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=lWFOShztuG2e44vH8e1SgZf/UIwGJpJgCSa+VYbcXO4=; b=U03DaF5ylInzMcApg6ap7bdrpGv61MnAT32jewrJ7MoG7ciyzdrzUxtlrNEn3XpS6b R7BXkfizEdvFFyVXd23sajQ/vw4QEro46MmP/jrOq50eY3m1ng3UpXNHPN/oHswjayFw wizHGzXmsiZefavplLaitORuESzkVb92u3lvwUtahss4JvYDEmj9jwWDyKdMHn+T5zQ/ jZeLxJj3Aysjfsu6BpxzvjZfIbiKOpNE+3w+4cQjQvya4rncdW/5nKYv5+IAKqC4mhZC xtUCXHimFIWosGw0AuoaZMlRSREq5UOmtB9UECDjP48UNlCUgnIPuUtFSpTgFFWW5kyj 9kgQ== X-Gm-Message-State: AHPjjUhOdYRkmMmtdm95HDSITRPg8jCPaNtw6puMiE/5Ze6oOjBlofBT NY6zWj/EJjlWyoMwvKIxZ1QhlWQp/Ts= X-Google-Smtp-Source: AOwi7QAH1K8wlhT8uaaAMUDMhjqW0utGUe71+/SneycNajOruJVSL1mIOwZkmX3djJPL+pQ45IyukQ== X-Received: by 10.98.157.139 with SMTP id a11mr3733281pfk.70.1505947628626; Wed, 20 Sep 2017 15:47:08 -0700 (PDT) Received: from ebiggers-linuxstation.kir.corp.google.com ([100.66.174.81]) by smtp.gmail.com with ESMTPSA id j2sm6249pgn.26.2017.09.20.15.47.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Sep 2017 15:47:08 -0700 (PDT) From: Eric Biggers To: linux-fscrypt@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-mtd@lists.infradead.org, "Theodore Y . Ts'o" , Jaegeuk Kim , Michael Halcrow , Eric Biggers Subject: [PATCH 16/25] f2fs: switch to fscrypt_file_open() Date: Wed, 20 Sep 2017 15:45:56 -0700 Message-Id: <20170920224605.22030-17-ebiggers3@gmail.com> X-Mailer: git-send-email 2.14.1.821.g8fa685d3b7-goog In-Reply-To: <20170920224605.22030-1-ebiggers3@gmail.com> References: <20170920224605.22030-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 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 517e112c8a9a..8cef3931a00b 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -455,22 +455,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); }