Skip to content

Commit 88391d4

Browse files
richardcochrangregkh
authored andcommitted
kernfs: fix off by one error.
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. Signed-off-by: Richard Cochran <richardcochran@gmail.com> Cc: <stable@vger.kernel.org> Reviewed-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 13df797 commit 88391d4

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎fs/kernfs/dir.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ static unsigned int kernfs_name_hash(const char *name, const void *ns)
190190
hash = (end_name_hash(hash) ^ hash_ptr((void *)ns, 31));
191191
hash &= 0x7fffffffU;
192192
/* Reserve hash numbers 0, 1 and INT_MAX for magic directory entries */
193-
if (hash < 1)
193+
if (hash < 2)
194194
hash += 2;
195195
if (hash >= INT_MAX)
196196
hash = INT_MAX - 1;

0 commit comments

Comments
 (0)