From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: ebiederm@xmission.com (Eric W. Biederman) To: Richard Cochran Cc: , Greg Kroah-Hartman , Tejun Heo , References: <74f5a436ebf5c13ed89a81c47ba09a6549e385f6.1394035568.git.richardcochran@gmail.com> Date: Wed, 05 Mar 2014 09:11:17 -0800 In-Reply-To: <74f5a436ebf5c13ed89a81c47ba09a6549e385f6.1394035568.git.richardcochran@gmail.com> (Richard Cochran's message of "Wed, 5 Mar 2014 17:10:52 +0100") Message-ID: <877g887eq2.fsf@xmission.com> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [PATCH] kernfs: fix off by one error. Sender: linux-kernel-owner@vger.kernel.org List-ID: Richard Cochran writes: > The hash values 0 and 1 are reserved for magic directory entries, but > the code only prevents names hashing to 0. This patch fixes the test > to also prevent hash value 1. > Reviewed-by: "Eric W. Biederman" > Signed-off-by: Richard Cochran > Cc: > --- > fs/kernfs/dir.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c > index bd6e18b..39c0143 100644 > --- a/fs/kernfs/dir.c > +++ b/fs/kernfs/dir.c > @@ -37,7 +37,7 @@ static unsigned int kernfs_name_hash(const char *name, const void *ns) > hash = (end_name_hash(hash) ^ hash_ptr((void *)ns, 31)); > hash &= 0x7fffffffU; > /* Reserve hash numbers 0, 1 and INT_MAX for magic directory entries */ > - if (hash < 1) > + if (hash < 2) > hash += 2; > if (hash >= INT_MAX) > hash = INT_MAX - 1;