From patchwork Fri Mar 23 19:23:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 10305507 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 46D2B600CC for ; Fri, 23 Mar 2018 19:31:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 370CF2912B for ; Fri, 23 Mar 2018 19:31:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2C21F2912D; Fri, 23 Mar 2018 19:31:39 +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 D1EE22912B for ; Fri, 23 Mar 2018 19:31:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752578AbeCWTbi (ORCPT ); Fri, 23 Mar 2018 15:31:38 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:36908 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752324AbeCWTbT (ORCPT ); Fri, 23 Mar 2018 15:31:19 -0400 Received: by mail-pf0-f195.google.com with SMTP id t16so882078pfh.4; Fri, 23 Mar 2018 12:31:18 -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=LjgC7/TFnUw4PPDWmwXnZkp0LGc9WN/usAoVPx586r0=; b=Fe9qaQJnDduZl2ycz+kNMY0aivxvFsPSRGZzaB/kcE5E8nC3YVfRkAzi6ym18vHiR4 BDRKBoQeU/+FbOxJL9o6G453bs7RREUA+3fOLgjntx6EUycKpzgT9ALN2Xh9HvuYKOXq W0GbaR4zSpxh/dYPvG1XyzY7boupdF9y/OfTrnIOLNAYP+t4z4Uk+qyQqZ3IiTTnYvjY s4gdmeTx3R2tvTowNHuH5L57ZE0KgVRNj4RbMNnlqlL01n4gEAdZA7kxgECFFenNNgvn S8o/99u8osLclGeuavQuKXQmK+noQciNXg48p9qgHHWrjOA/C70MgUhvakWQ18Oaf+7X tdaA== 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=LjgC7/TFnUw4PPDWmwXnZkp0LGc9WN/usAoVPx586r0=; b=kjSiCdTJN4bruJjCSzNE22763p3WTPeX5jImyolei4uBVKGcqKdpJWP2+e6kQzhnb7 1dmvU9oPi8D6kChR8tlgKauNz3DQQeWSpyFU2Ia4OhGpcV902HQzxhNRYhpHffBvOVba ku8MsL5TtlhaTXbMD+uDZi++QJq4bXTbcD4+5OyGCo3zgIGwzph+Yanyx4YBWkTpwxRX EPwqfwIfkOD1/JZFyLY6OhWds7qav2elbC/IBDaiU02u7zArBaoo0PXBJ/dtCXEIyLcc C3K3GBCRRrx0/YmB3MkrXxT3M3C4ns2QUAjZPCgQDDc5Jt9zdOZNaSuPRZ4Dl1MTFfNR bRag== X-Gm-Message-State: AElRT7FvfmpfEFmT3CfVOwAQmugLkV4mkW0nX/NMqSB2hktsPagKL2vd yuQtPVMAZ05zIfWs5oIHJD2RGWn8 X-Google-Smtp-Source: AG47ELseNKJ9ng/IOFioLjnOXTX6xeJmgcEZeBuxkOD1KgWjE9tdgHuQBbIXcLsNUT9V/sjH2s0V2w== X-Received: by 10.99.143.69 with SMTP id r5mr7927721pgn.159.1521833478059; Fri, 23 Mar 2018 12:31:18 -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 x1sm20924545pfk.144.2018.03.23.12.31.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Mar 2018 12:31:17 -0700 (PDT) From: Eric Biggers To: linux-fscrypt@vger.kernel.org, "Theodore Y . Ts'o" Cc: linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-mtd@lists.infradead.org, Jaegeuk Kim , Eric Biggers Subject: [PATCH 07/14] fscrypt: drop max_namelen check from fname_decrypt() Date: Fri, 23 Mar 2018 12:23:51 -0700 Message-Id: <20180323192358.95691-8-ebiggers3@gmail.com> X-Mailer: git-send-email 2.17.0.rc0.231.g781580f067-goog In-Reply-To: <20180323192358.95691-1-ebiggers3@gmail.com> References: <20180323192358.95691-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 fscrypt_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 */