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: 906923 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="mCNT9bX7"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="DI59IGct"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40Zg8t6gHBz9s0n for ; Tue, 1 May 2018 09:04:30 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=5vC1ptFn85YOjF84jRB19wI7dCus3SHnm2rvwrOBC4M=; b=mCNT9bX7p8YFEKVLKiNih0NoB4 vWgoKr3mKoxGzbILpRJnI0IR+op9R88yhrlf5cw7JtinQ2iEfxw/XnMEUDnj36MNTwqmByvaWmZii o3e085qJ7tI0Wa9n3Uwf+HE70ASly4PJBafP4nJitpSAwH1Zho6j16i6x+NDSgi05JQ8LPQ0hQ/Cn TXqlMsDUlmqZZSKmI1I2zvjDX7HxbqaYte5IODp7J8ReRDtcVgXOoM4uu/Z7NCfr7+HN5xiEqWfNo MeceSQoI1kxo0FwkiIASii5KXP0UzyGZ0Q//jkRx2xQpjdxRamScUpYD+njv0dRsYE8HgXNfKsKP3 5I8TwwTQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fDHqG-0000CZ-1Y; Mon, 30 Apr 2018 23:04:20 +0000 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fDHj6-0003n8-To for linux-mtd@lists.infradead.org; Mon, 30 Apr 2018 22:56:59 +0000 Received: by mail-pf0-x241.google.com with SMTP id f189so7874386pfa.7 for ; 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=lDwCqMYBvyBu/u+xjXisSuzhGg/amhJ0B18NoIq5uD1QJ5wI9s0vjE+S7aRIYEuXA3 /TOagVlK3muC6tf45fasqUzs/blrc1f/b+EGB7G4uYdrmaEMWsdhfE8ZeAalYpohxalu 0b9IXEGNfHuC49agmbODScF6AQ4szo7lh1XQ4tgvF617C34Afa6AbeKYoVuA1l1JrwCB GhN+MwZr5OMVIZRb3EO39MKnpEExd+0L1vutFTAdBe9HKvCL+HD8Mm8fjvYRci7eRKoH RBAnHb6I/JXmeOQbzjCrn4MA5IB3TEuOaCEHWuDN3O1m3idDwsq0p5SXtHJV/ADLxpC0 LsSQ== X-Gm-Message-State: ALQs6tAqTyOlkJ9RbPZyw8jauPnjutuPejCZY7VWkyr3uUq7j1ZeYICg cwotV+ROE+2IbyyASgRq8F5k9p9z 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" 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180430_155656_998355_5FB0203E X-CRM114-Status: GOOD ( 12.39 ) X-Spam-Score: 0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2607:f8b0:400e:c00:0:0:0:241 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ebiggers3[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (ebiggers3[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jaegeuk Kim , linux-ext4@vger.kernel.org, linux-mtd@lists.infradead.org, Eric Biggers , linux-f2fs-devel@lists.sourceforge.net MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 */