From patchwork Fri Dec 15 17:42:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 10115703 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 E44246019C for ; Fri, 15 Dec 2017 17:47:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D243829EE1 for ; Fri, 15 Dec 2017 17:47:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C72342A024; Fri, 15 Dec 2017 17:47:05 +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 719AB29EE1 for ; Fri, 15 Dec 2017 17:47:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756074AbdLORrE (ORCPT ); Fri, 15 Dec 2017 12:47:04 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:43121 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755851AbdLORq4 (ORCPT ); Fri, 15 Dec 2017 12:46:56 -0500 Received: by mail-pf0-f194.google.com with SMTP id e3so6625038pfi.10; Fri, 15 Dec 2017 09:46:55 -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=ifnjri4fsAw4E6ZxjEL4oc9d1HClXCRKtuULFM4NFu0=; b=u1XS/EINbo4uvroO/67gCYljEDo06XfRzQZFuy0wB5xBR80teuwBnRr6ElK6xsPKuV nOl0y9lhAeid2X5pJYlmgYm+0ZIP8kaUIrfRDiCswf0hc2M4hJUrHmmRfVBPZpO3byzE awTM7Ob+wG0GC4cjIXoJ4HqRxJYfo2+X2qRUIif1bAdaportso9ZefliIEscEtMye6ZQ 3P+5yBZvm5bnc0vPAYjnot0Yg/SZfRnt23vz0Cxg2we+KVJroy2LGhSY/n9dzFlsasmL hZKZjlD82FGI07GH7t9QrHtjQVapX2XpRm+uTNmdTapYmQVZrMdEm4vXMVvRjLabyPxk UnBw== 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=ifnjri4fsAw4E6ZxjEL4oc9d1HClXCRKtuULFM4NFu0=; b=RlGP3NHSCUT21rUBVFBwg0kqHTE41kHZSk0BRI6vKDp3CxkBlYZNehfxy0fxp3WRyp 1HQToO+Lr7CupSyh1kRC1qFMn/FjXGNTubmCHrM54S90KS4GZDhIc4cNIRJMRZ5M5ow8 zZxmbYYvhD9exq65rrcHYYvNXjsqTYnKg4qOwHb/8vucbMy5zhRYDuPHG0xhc+jTFoNV 5UW0aGLw8CmFEJi9ntep6wkeHfd5R54eVJZcyj8zYUJF5toAr8d3tpi5cFP/uAbwNmK7 dZxWJzIeUQ6f9nFvqbt2F/R3RW/Ig8Fg7ktWem71gu6Ng4GWmfAwjQSEdVF04CxRvMX9 216A== X-Gm-Message-State: AKGB3mLmUQA5Br2jxX9DsnfjZMi6q8rWY5l2qCFjXoMZStKJPowDcQMc wi7rnmmw+wijp4+ksoBgmtyArdCxxpI= X-Google-Smtp-Source: ACJfBovR15lcnu7KgyNdlIwP2IytBhX5fvxID//vnEHcKervVDABxmNeNLsqZUj6FkB83I6mGl5C5w== X-Received: by 10.84.246.194 with SMTP id j2mr13992872plt.7.1513360014423; Fri, 15 Dec 2017 09:46:54 -0800 (PST) Received: from zzz.localdomain (c-67-185-97-198.hsd1.wa.comcast.net. [67.185.97.198]) by smtp.gmail.com with ESMTPSA id j62sm12980149pfc.18.2017.12.15.09.46.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Dec 2017 09:46:53 -0800 (PST) From: Eric Biggers To: linux-fscrypt@vger.kernel.org Cc: "Theodore Y . Ts'o" , Jaegeuk Kim , linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-mtd@lists.infradead.org, Eric Biggers Subject: [PATCH 15/24] f2fs: switch to fscrypt_get_symlink() Date: Fri, 15 Dec 2017 09:42:16 -0800 Message-Id: <20171215174225.31583-16-ebiggers3@gmail.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20171215174225.31583-1-ebiggers3@gmail.com> References: <20171215174225.31583-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/namei.c | 66 ++++++++------------------------------------------------- 1 file changed, 9 insertions(+), 57 deletions(-) diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c index 5b114844806c..37816d2ebb93 100644 --- a/fs/f2fs/namei.c +++ b/fs/f2fs/namei.c @@ -1137,68 +1137,20 @@ static const char *f2fs_encrypted_get_link(struct dentry *dentry, struct inode *inode, struct delayed_call *done) { - struct page *cpage = NULL; - char *caddr, *paddr = NULL; - struct fscrypt_str cstr = FSTR_INIT(NULL, 0); - struct fscrypt_str pstr = FSTR_INIT(NULL, 0); - struct fscrypt_symlink_data *sd; - u32 max_size = inode->i_sb->s_blocksize; - int res; + struct page *page; + const char *target; if (!dentry) return ERR_PTR(-ECHILD); - res = fscrypt_get_encryption_info(inode); - if (res) - return ERR_PTR(res); - - cpage = read_mapping_page(inode->i_mapping, 0, NULL); - if (IS_ERR(cpage)) - return ERR_CAST(cpage); - caddr = page_address(cpage); - - /* Symlink is encrypted */ - sd = (struct fscrypt_symlink_data *)caddr; - cstr.name = sd->encrypted_path; - cstr.len = le16_to_cpu(sd->len); - - /* this is broken symlink case */ - if (unlikely(cstr.len == 0)) { - res = -ENOENT; - goto errout; - } - - if ((cstr.len + sizeof(struct fscrypt_symlink_data) - 1) > max_size) { - /* Symlink data on the disk is corrupted */ - res = -EIO; - goto errout; - } - res = fscrypt_fname_alloc_buffer(inode, cstr.len, &pstr); - if (res) - goto errout; - - res = fscrypt_fname_disk_to_usr(inode, 0, 0, &cstr, &pstr); - if (res) - goto errout; - - /* this is broken symlink case */ - if (unlikely(pstr.name[0] == 0)) { - res = -ENOENT; - goto errout; - } - - paddr = pstr.name; - - /* Null-terminate the name */ - paddr[pstr.len] = '\0'; + page = read_mapping_page(inode->i_mapping, 0, NULL); + if (IS_ERR(page)) + return ERR_CAST(page); - put_page(cpage); - set_delayed_call(done, kfree_link, paddr); - return paddr; -errout: - fscrypt_fname_free_buffer(&pstr); - put_page(cpage); - return ERR_PTR(res); + target = fscrypt_get_symlink(inode, page_address(page), + inode->i_sb->s_blocksize, done); + put_page(page); + return target; } const struct inode_operations f2fs_encrypted_symlink_inode_operations = {