Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6760115ybi; Wed, 31 Jul 2019 21:06:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqxh/CRgWCgCQfE+r+eCn16R/yn0SOpcNZ0/vm6fefgA78i3SWLARrQCROqsZm5hzHxKm2G9 X-Received: by 2002:a17:902:f46:: with SMTP id 64mr124676556ply.235.1564632380519; Wed, 31 Jul 2019 21:06:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564632380; cv=none; d=google.com; s=arc-20160816; b=iz9z4RtklH+U5pM3PsImGXngHVuSW4w0lpy23jUnB9pAbGR7PuqPjNN12+5/gXe/Fq L/KWUhBbFjbE6NMr1z07W1025DnUeskIEz8gCMvf0iYf08YM+y+06wyamyz16tmBpFPn Rk/4KeQBGQ3kkZN25sh+69FzjFswn5cBF/4o1sCXiFBW5v7BDc28jhNae8+4t8Im79FY P0ttlFnygalIppZgHURN0bSIx3ylrE7LMKUNnWUXKMJVDukKtogTpH4nGbVdLCXbgjIE tGalU4MrC0kMO85ZXa6A9/unDVtRmtqeu/nBbRzCbRdIJxsNWxJzIMuGQur3vxa+ZmHN JbIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=zJG293VrjL0qlZzRWdJ37j8l/khyG838GKSe4VWZzhA=; b=W1pygWzbCSYiMIueMtPrLl1xd57po5rzxjTiPsdykyyZYwszzA2lxvc2PvGoHlkaQp b0nl94CdSIUV57LX7X1gTCIgtZt5LkVurE7KBOYsVdz/Iw+XtaV/c43F9cKACBkDDn2Z q5vCjbgUDjtzfF273+XIdfcGXwEblgzX341VaGxHDBgSvIBslfrhEdWNInTSlOnezAjn 0D28mTkDn+d05tCjnyqUWABLLRyECwRAgmMAIAoHiVRUvc5H1kBgdDh0kgYPOX/ynUum 4cfIEc+48XUk+JinXSDe8piuyAm+oME//vbXCf33OrsEkSQfm9MmmetXJszw66BUiO5D JMzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZvE7R67i; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o63si2928724pjo.94.2019.07.31.21.06.04; Wed, 31 Jul 2019 21:06:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZvE7R67i; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725958AbfHAEFX (ORCPT + 99 others); Thu, 1 Aug 2019 00:05:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:33712 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725308AbfHAEFW (ORCPT ); Thu, 1 Aug 2019 00:05:22 -0400 Received: from localhost (c-98-234-77-170.hsd1.ca.comcast.net [98.234.77.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4F7AA206A3; Thu, 1 Aug 2019 04:05:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564632321; bh=p93UwHtzJnT9bTmzWi9Xj9kNuVoH+OlrITuCGkgZCU0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZvE7R67i5/FJqUTpXXMJgmYnrP6zkjLyIIQ94Tw1YOk7s0QqPvmNW/1maP7qQTEm/ vWMPM77/byfy78m7B/pqD4jpczOqeWOzwnSaKYaX6tsk4zQMH/EQLw/tBAw4Yxb5va SVcj+hsNBIIFdLlvxBRGSUG5zSnPzPc9A2Lo+tQo= Date: Wed, 31 Jul 2019 21:05:20 -0700 From: Jaegeuk Kim To: Chao Yu Cc: Nathan Chancellor , Daniel Rosenberg , Jonathan Corbet , linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, kernel-team@android.com Subject: Re: [PATCH v4 3/3] f2fs: Support case-insensitive file name lookups Message-ID: <20190801040520.GA84433@jaegeuk-macbookpro.roam.corp.google.com> References: <20190723230529.251659-1-drosen@google.com> <20190723230529.251659-4-drosen@google.com> <20190731175748.GA48637@archlinux-threadripper> <5d6c5da8-ad1e-26e2-0a3d-84949cd4e9aa@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5d6c5da8-ad1e-26e2-0a3d-84949cd4e9aa@huawei.com> User-Agent: Mutt/1.8.2 (2017-04-18) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/01, Chao Yu wrote: > Hi Nathan, > > Thanks for the report! :) > > On 2019/8/1 1:57, Nathan Chancellor wrote: > > Hi all, > > > > > > > >> diff --git a/fs/f2fs/hash.c b/fs/f2fs/hash.c > >> index cc82f142f811f..99e79934f5088 100644 > >> --- a/fs/f2fs/hash.c > >> +++ b/fs/f2fs/hash.c > >> @@ -14,6 +14,7 @@ > >> #include > >> #include > >> #include > >> +#include > >> > >> #include "f2fs.h" > >> > >> @@ -67,7 +68,7 @@ static void str2hashbuf(const unsigned char *msg, size_t len, > >> *buf++ = pad; > >> } > >> > >> -f2fs_hash_t f2fs_dentry_hash(const struct qstr *name_info, > >> +static f2fs_hash_t __f2fs_dentry_hash(const struct qstr *name_info, > >> struct fscrypt_name *fname) > >> { > >> __u32 hash; > >> @@ -103,3 +104,35 @@ f2fs_hash_t f2fs_dentry_hash(const struct qstr *name_info, > >> f2fs_hash = cpu_to_le32(hash & ~F2FS_HASH_COL_BIT); > >> return f2fs_hash; > >> } > >> + > >> +f2fs_hash_t f2fs_dentry_hash(const struct inode *dir, > >> + const struct qstr *name_info, struct fscrypt_name *fname) > >> +{ > >> +#ifdef CONFIG_UNICODE > >> + struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb); > >> + const struct unicode_map *um = sbi->s_encoding; > >> + int r, dlen; > >> + unsigned char *buff; > >> + struct qstr *folded; > >> + > >> + if (name_info->len && IS_CASEFOLDED(dir)) { > >> + buff = f2fs_kzalloc(sbi, sizeof(char) * PATH_MAX, GFP_KERNEL); > >> + if (!buff) > >> + return -ENOMEM; > >> + > >> + dlen = utf8_casefold(um, name_info, buff, PATH_MAX); > >> + if (dlen < 0) { > >> + kvfree(buff); > >> + goto opaque_seq; > >> + } > >> + folded->name = buff; > >> + folded->len = dlen; > >> + r = __f2fs_dentry_hash(folded, fname); > >> + > >> + kvfree(buff); > >> + return r; > >> + } > >> +opaque_seq: > >> +#endif > >> + return __f2fs_dentry_hash(name_info, fname); > >> +} > > > > Clang now warns: > > > > fs/f2fs/hash.c:128:3: warning: variable 'folded' is uninitialized when used here [-Wuninitialized] > > folded->name = buff; > > ^~~~~~ > > fs/f2fs/hash.c:116:21: note: initialize the variable 'folded' to silence this warning > > struct qstr *folded; > > ^ > > = NULL > > 1 warning generated. > > > > I assume that it wants to be initialized with f2fs_kzalloc as well but > > I am not familiar with this code and what it expects to do. > > > > Please look into this when you get a chance! > > That should be a bug, it needs to define a struct qstr type variable rather than > a pointer there. > > Jaegeuk, could you fix this in you branch? Yeah, let me apply this. --- a/fs/f2fs/hash.c +++ b/fs/f2fs/hash.c @@ -113,25 +113,27 @@ f2fs_hash_t f2fs_dentry_hash(const struct inode *dir, const struct unicode_map *um = sbi->s_encoding; int r, dlen; unsigned char *buff; - struct qstr *folded; + struct qstr folded; - if (name_info->len && IS_CASEFOLDED(dir)) { - buff = f2fs_kzalloc(sbi, sizeof(char) * PATH_MAX, GFP_KERNEL); - if (!buff) - return -ENOMEM; + if (!name_info->len || !IS_CASEFOLDED(dir)) + goto opaque_seq; - dlen = utf8_casefold(um, name_info, buff, PATH_MAX); - if (dlen < 0) { - kvfree(buff); - goto opaque_seq; - } - folded->name = buff; - folded->len = dlen; - r = __f2fs_dentry_hash(folded, fname); + buff = f2fs_kzalloc(sbi, sizeof(char) * PATH_MAX, GFP_KERNEL); + if (!buff) + return -ENOMEM; + dlen = utf8_casefold(um, name_info, buff, PATH_MAX); + if (dlen < 0) { kvfree(buff); - return r; + goto opaque_seq; } + folded.name = buff; + folded.len = dlen; + r = __f2fs_dentry_hash(&folded, fname); + + kvfree(buff); + return r; + opaque_seq: #endif return __f2fs_dentry_hash(name_info, fname);