From patchwork Mon Apr 30 22:51:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 10373033 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 1DE246032A for ; Mon, 30 Apr 2018 22:57:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0BDA31FF83 for ; Mon, 30 Apr 2018 22:57:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 003E8212DA; Mon, 30 Apr 2018 22:57:01 +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=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, 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 9CFDC1FF83 for ; Mon, 30 Apr 2018 22:57:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755430AbeD3W4u (ORCPT ); Mon, 30 Apr 2018 18:56:50 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:42276 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755381AbeD3W4r (ORCPT ); Mon, 30 Apr 2018 18:56:47 -0400 Received: by mail-pf0-f195.google.com with SMTP id a11so7865699pfn.9; Mon, 30 Apr 2018 15:56:46 -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=Uea0xpw287CzFIPmQeLSWYI5fhVgb78MFSq1WmN6FRA=; b=DI59IGctw7L0dfiJwbuYZoTE72Sp7K6nCO5FVbHLKxre+EM1MlKurtlQzaAqqUfYDY McQlbMY+YyAkKzFW9HTEgwhrrZ0IfrxHoYvPEcn8gIur0hHnGXgXWwpZM1o/78lOWhGe B/i0D9ZCWRX2eXYPkx3rtF3bfk0wmaRiaFgnrt0OdhbDbXhSAmgDpKWocYBJee0Dk69E 3KBRCVPtaSqHSWAFYj+nYFbh9WRsUNv9o84C0VxkSftT48mo0BIj5Ea4eUb0KMRbxS/B hdRFs2dwb2s/i9dX5OwGsDoxHr7Wgqax/XK7rbnTnjspIABGtcAIbPylsQlDUpUqnnAG qRrg== 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=Uea0xpw287CzFIPmQeLSWYI5fhVgb78MFSq1WmN6FRA=; b=NsdDIPZ/SPkhFUq0nCHScc0TgpkEvVeSm0zIuzlwEbmNcPD5hodAAnXw93MsFA6MrR ecINEC7LSgIXCrlVP0BhbBI/MVPOHYxBxZ55C6m1bX6G7/Q5AT5G2kRaVzcYlJbbEGdX Lah5puqrS/7tqrsBnWnoBR70b7PHvPx9g+3oOTp9q5YgLLrk1AQdPQ0ZYdNO6QfqeG6T 23RBqpjw7QHuWVE+GJIG31ol5mmDem0XNV1mSXZntCrOpRHJHli0FOtyf8M0dRkcRs55 NqFSCqIsWo93rxVyElwShZ5+e1HG8tEom3/IxIsAiR/vDbvyNKMJrOrf3GdXGzNqeyhQ zzrQ== X-Gm-Message-State: ALQs6tDZ2yn1gHoaDVvu9XyvUawpcx8FjLIdxT3mWXlqcHF0jG7+dunx rkJ9M7kTgHUConS1JbdWB7t5K/hL X-Google-Smtp-Source: AB8JxZoms4xCBbVaVfDQSX0xGICsD9w+PtG3Jq5iBuxPF0fZjwkBxvaKGYmG8Y/CiZ69JOzQSb/Sog== X-Received: by 2002:a63:a412:: with SMTP id c18-v6mr11298516pgf.85.1525129006165; Mon, 30 Apr 2018 15:56:46 -0700 (PDT) Received: from ebiggers-linuxstation.kir.corp.google.com ([2620:15c:17:3:dc28:5c82:b905:e8a8]) by smtp.gmail.com with ESMTPSA id b15sm12969305pfi.111.2018.04.30.15.56.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Apr 2018 15:56:45 -0700 (PDT) From: Eric Biggers To: linux-fscrypt@vger.kernel.org, "Theodore Y . Ts'o" Cc: Jaegeuk Kim , linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-mtd@lists.infradead.org, Eric Biggers Subject: [PATCH 08/15] fscrypt: drop max_namelen check from fname_decrypt() Date: Mon, 30 Apr 2018 15:51:42 -0700 Message-Id: <20180430225149.183514-9-ebiggers3@gmail.com> X-Mailer: git-send-email 2.17.0.441.gb46fe60e1d-goog In-Reply-To: <20180430225149.183514-1-ebiggers3@gmail.com> References: <20180430225149.183514-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 fname_decrypt() returns an error if the input filename is longer than the inode's ->max_namelen() as given by the filesystem. But, this doesn't actually make sense because the filesystem provided the input filename in the first place, where it was subject to the filesystem's limits. And fname_decrypt() has no internal limit itself. Thus, remove this unnecessary check. Signed-off-by: Eric Biggers --- fs/crypto/fname.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/fs/crypto/fname.c b/fs/crypto/fname.c index 8088a606c0aa..cc9590b5f371 100644 --- a/fs/crypto/fname.c +++ b/fs/crypto/fname.c @@ -93,14 +93,11 @@ static int fname_decrypt(struct inode *inode, struct skcipher_request *req = NULL; DECLARE_CRYPTO_WAIT(wait); struct scatterlist src_sg, dst_sg; - struct fscrypt_info *ci = inode->i_crypt_info; - struct crypto_skcipher *tfm = ci->ci_ctfm; + struct crypto_skcipher *tfm = inode->i_crypt_info->ci_ctfm; int res = 0; char iv[FS_CRYPTO_BLOCK_SIZE]; - unsigned lim; - lim = inode->i_sb->s_cop->max_namelen(inode); - if (iname->len <= 0 || iname->len > lim) + if (iname->len <= 0) return -EIO; /* Allocate request */