Re: [PATCH] kernfs: fix off by one error.

From: Eric W. Biederman
Date: Wed Mar 05 2014 - 12:11:38 EST


Richard Cochran <richardcochran@xxxxxxxxx> 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" <ebiederm@xxxxxxxxxxxx>
> Signed-off-by: Richard Cochran <richardcochran@xxxxxxxxx>
> Cc: <stable@xxxxxxxxxxxxxxx>
> ---
> 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;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/