From patchwork Mon Apr 24 17:00:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 9696797 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 97A67603F3 for ; Mon, 24 Apr 2017 17:02:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84BCB2817F for ; Mon, 24 Apr 2017 17:02:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7960228400; Mon, 24 Apr 2017 17:02:50 +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 27E962817F for ; Mon, 24 Apr 2017 17:02:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S975362AbdDXRCs (ORCPT ); Mon, 24 Apr 2017 13:02:48 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:33831 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S975311AbdDXRC0 (ORCPT ); Mon, 24 Apr 2017 13:02:26 -0400 Received: by mail-pg0-f68.google.com with SMTP id t7so1954283pgt.1; Mon, 24 Apr 2017 10:02:26 -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=KDa73JNTh/gxEjjYUDA0M4vMZGORt8cK/EFfXdKcjA0=; b=kuMd7XW4xqAwsaBPH55ghOTFzszpxxiynFw63j814VYRMIb/8t/ItwAoH7uml6rHSZ 7gddKQ6qfFjMU8DeYixOUTWEhyMFgBfWQkL9NOMMgS3Gk+pycM9fQxBwViuK8LCCF09/ 23nq8decNtnm5k8hL+oMwPx3W0s3s8U6x8MvfCWc3KtGpze9oxQTTlKICc74cJ+gHW1e zRYU6d+ZNT0X18ngYUHltpEjVpSUpjYLvaldNowl62DTJ7FXKCxfKEMo2RJUQ8EStVOr ewIZabL8Cc7qvxppCWEWtnAgMx8gTPCcogKPop8ZK2poCmCx3yND2+Q+lApox5Edy2pI 8ifQ== 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=KDa73JNTh/gxEjjYUDA0M4vMZGORt8cK/EFfXdKcjA0=; b=HBqRYDGkZ6BgL1axDrllBRIAwzDCWdE+U7ptTO8jdM/bcOmJLyuFRdGY23ic05uinN jje9m/qwaZfRgMNN5piWLFBwFa4iQm2SMKEsdPNnBBnNnu0apZMSeqxQ0UePsPlZ1rHp C75hiiYSSxnH3DY5QPuRL6xFJtme3uGPSE3fvJv/AbPhkFmu96+kvTguq3z5CUUXOu57 tFXsspFdgwy4UovA6M3iDOAvGJdAldA0XX5cXo9xlMjUTsTma7VJkH9B5Uf7WzRerBse nFiKdO5g+x5HXGRc8x51VFHYSzeGlJz8WCM6wG1K/LztqlVaDqicRlJ04AbnXFnmpHdg iq6g== X-Gm-Message-State: AN3rC/4PfkAstgW1I35cc21OYbei7fBSdtUTBL88zsWLXxj5+8MtSik7 UbiyPaDlRXRt2Q== X-Received: by 10.99.122.81 with SMTP id j17mr6795275pgn.111.1493053335779; Mon, 24 Apr 2017 10:02:15 -0700 (PDT) Received: from ebiggers-linuxstation.kir.corp.google.com ([100.119.30.131]) by smtp.gmail.com with ESMTPSA id s89sm31927267pfi.79.2017.04.24.10.02.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Apr 2017 10:02:15 -0700 (PDT) From: Eric Biggers To: linux-fscrypt@vger.kernel.org Cc: "Theodore Y . Ts'o" , Jaegeuk Kim , linux-f2fs-devel@lists.sourceforge.net, linux-ext4@vger.kernel.org, linux-mtd@lists.infradead.org, Gwendal Grignou , hashimoto@chromium.org, kinaba@chromium.org, Eric Biggers Subject: [PATCH 4/6] ext4: switch to using fscrypt_match_name() Date: Mon, 24 Apr 2017 10:00:11 -0700 Message-Id: <20170424170013.85175-5-ebiggers3@gmail.com> X-Mailer: git-send-email 2.12.2.816.g2cccc81164-goog In-Reply-To: <20170424170013.85175-1-ebiggers3@gmail.com> References: <20170424170013.85175-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 Switch ext4 directory searches to use the fscrypt_match_name() helper function. There should be no functional change. Signed-off-by: Eric Biggers --- fs/ext4/namei.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index e6301b6933fc..6ecc3ae87a79 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -1245,29 +1245,17 @@ static void dx_insert_block(struct dx_frame *frame, u32 hash, ext4_lblk_t block) static inline int ext4_match(struct ext4_filename *fname, struct ext4_dir_entry_2 *de) { - const void *name = fname_name(fname); - u32 len = fname_len(fname); + struct fscrypt_name f; if (!de->inode) return 0; + f.usr_fname = fname->usr_fname; + f.disk_name = fname->disk_name; #ifdef CONFIG_EXT4_FS_ENCRYPTION - if (unlikely(!name)) { - if (fname->usr_fname->name[0] == '_') { - int ret; - if (de->name_len <= 32) - return 0; - ret = memcmp(de->name + ((de->name_len - 17) & ~15), - fname->crypto_buf.name + 8, 16); - return (ret == 0) ? 1 : 0; - } - name = fname->crypto_buf.name; - len = fname->crypto_buf.len; - } + f.crypto_buf = fname->crypto_buf; #endif - if (de->name_len != len) - return 0; - return (memcmp(de->name, name, len) == 0) ? 1 : 0; + return fscrypt_match_name(&f, de->name, de->name_len); } /*