From patchwork Mon Apr 24 21:31:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Weinberger X-Patchwork-Id: 754451 X-Patchwork-Delegate: richard@nod.at Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 3wBfgh6Rw6z9s85 for ; Tue, 25 Apr 2017 07:32:16 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="hx6hO4Dl"; dkim-atps=neutral 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: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:In-Reply-To: References:List-Owner; bh=LCp5dsDfNE2qF73ZfV5ipQCr1KyEp/mKJjsk5bPFWEM=; b=hx6 hO4DlbEzBD8fgb3WlYkiyPUaUBP2UsRRsAMoUh6/I9lNDNfHc2mZiilkgG0MHKZWLDowjreiKmCyv Go/pcd0GJ2Qas5al6qmS4oXXfeSvHfizhmQLL8zJpv0YYai+Iy5eWc6J6KKqklpA/+OowcpUk9O5i oUVcDwVMwxIRwRLSioAjoqRpHkRB1NqaIHZeXaFwQhwRGXcEu4hlOnHHGEG+BdDCJeh2HGx5RrBHw xPo0rSxYYGlb1zA27eYak0McxFeQ0nVqw2ty6BZ8e1tyTVmXioLXe/7nFIdAIDEtei5rdW7A7UmXh 2naSI3JU1XqnRnlbN2eVPMcf1L+9EDA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1d2lae-0003kM-N8; Mon, 24 Apr 2017 21:32:12 +0000 Received: from mail.sigma-star.at ([95.130.255.111]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1d2laa-0003i9-Af for linux-mtd@lists.infradead.org; Mon, 24 Apr 2017 21:32:10 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.sigma-star.at (Postfix) with ESMTP id 0B98524E0002; Mon, 24 Apr 2017 23:31:44 +0200 (CEST) Received: from linux.site (richard.vpn.sigmapriv.at [10.3.0.5]) by mail.sigma-star.at (Postfix) with ESMTPSA id 3F1E624E0001; Mon, 24 Apr 2017 23:31:43 +0200 (CEST) From: Richard Weinberger To: linux-mtd@lists.infradead.org Subject: [PATCH] ubifs: Correctly handle 0 value hashes in ubifs_lookup() Date: Mon, 24 Apr 2017 23:31:38 +0200 Message-Id: <1493069498-19505-1-git-send-email-richard@nod.at> X-Mailer: git-send-email 2.7.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170424_143208_539850_0CFDDFF4 X-CRM114-Status: GOOD ( 11.22 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 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: Richard Weinberger , linux-fscrypt@vger.kernel.org, stable@vger.kernel.org, linux-kernel@vger.kernel.org, david@sigma-star.at MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Use fname_name(&nm) == NULL to detect whether a double hash lookup should be performed instead of checking for nm.hash being non-zero. zero is a valid hash value. Fixes: f4f61d2cc6d8 ("ubifs: Implement encrypted filenames") Cc: Signed-off-by: Richard Weinberger --- fs/ubifs/dir.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c index b777bddaa1dd..ff77a0aa2f2b 100644 --- a/fs/ubifs/dir.c +++ b/fs/ubifs/dir.c @@ -249,9 +249,8 @@ static struct dentry *ubifs_lookup(struct inode *dir, struct dentry *dentry, goto out_fname; } - if (nm.hash) { + if (fname_name(&nm) == NULL) { ubifs_assert(fname_len(&nm) == 0); - ubifs_assert(fname_name(&nm) == NULL); dent_key_init_hash(c, &key, dir->i_ino, nm.hash); err = ubifs_tnc_lookup_dh(c, &key, dent, nm.minor_hash); } else {