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: 9697265 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 21730603F3 for ; Mon, 24 Apr 2017 21:32:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1476228400 for ; Mon, 24 Apr 2017 21:32:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0780428423; Mon, 24 Apr 2017 21:32:04 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 79A1D28400 for ; Mon, 24 Apr 2017 21:32:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1173464AbdDXVbt (ORCPT ); Mon, 24 Apr 2017 17:31:49 -0400 Received: from mail.sigma-star.at ([95.130.255.111]:45996 "EHLO mail.sigma-star.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031030AbdDXVbr (ORCPT ); Mon, 24 Apr 2017 17:31:47 -0400 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 Cc: linux-kernel@vger.kernel.org, linux-fscrypt@vger.kernel.org, david@sigma-star.at, Richard Weinberger , stable@vger.kernel.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 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 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 {