linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ubifs: Correctly handle 0 value hashes in ubifs_lookup()
@ 2017-04-24 21:31 Richard Weinberger
  2017-04-24 21:41 ` Richard Weinberger
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Weinberger @ 2017-04-24 21:31 UTC (permalink / raw)
  To: linux-mtd; +Cc: linux-kernel, linux-fscrypt, david, Richard Weinberger, stable

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: <stable@vger.kernel.org>
Signed-off-by: Richard Weinberger <richard@nod.at>
---
 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 {
-- 
2.7.3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ubifs: Correctly handle 0 value hashes in ubifs_lookup()
  2017-04-24 21:31 [PATCH] ubifs: Correctly handle 0 value hashes in ubifs_lookup() Richard Weinberger
@ 2017-04-24 21:41 ` Richard Weinberger
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Weinberger @ 2017-04-24 21:41 UTC (permalink / raw)
  To: linux-mtd; +Cc: linux-kernel, linux-fscrypt, david, stable

Am 24.04.2017 um 23:31 schrieb Richard Weinberger:
> 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: <stable@vger.kernel.org>
> Signed-off-by: Richard Weinberger <richard@nod.at>
> ---
>  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 {
> 

Just realized that checking for nm.hash being non-zero is still legit on UBIFS
since UBIFS uses hash values 0, 1 and 2 in readdir() as special values.
key_mask_hash() makes sure that no hash value is smaller than 3 that goes do disk.

Thanks,
//richard

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-04-24 21:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-24 21:31 [PATCH] ubifs: Correctly handle 0 value hashes in ubifs_lookup() Richard Weinberger
2017-04-24 21:41 ` Richard Weinberger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).