[LU-4362] cfs_hash_rehash_key() passed wrong parameters to cfs_hash_keycpy Created: 09/Dec/13  Updated: 20/Jan/16  Resolved: 18/Dec/13

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: Lustre 2.4.1, Lustre 2.5.0, Lustre 2.6.0
Fix Version/s: Lustre 2.6.0, Lustre 2.4.2, Lustre 2.5.1

Type: Bug Priority: Blocker
Reporter: Liang Zhen (Inactive) Assignee: Liang Zhen (Inactive)
Resolution: Fixed Votes: 1
Labels: None

Issue Links:
Related
Severity: 3
Rank (Obsolete): 11945

 Description   

cfs_hash_rehash_key()->cfs_hash_keycpy(hs, new_key, hnode);
but define of cfs_hash_keycpy is:
void cfs_hash_keycpy(cfs_hash_t *hs, struct hlist_node *hnode, void *key)

This is very dangerous because it can corrupt memory.
I will post a patch soon



 Comments   
Comment by Liang Zhen (Inactive) [ 09/Dec/13 ]

patch for master: http://review.whamcloud.com/8509
patch for b2_4: http://review.whamcloud.com/8510
patch for b2_1: http://review.whamcloud.com/8511
patch for b2_5: http://review.whamcloud.com/8512

Comment by Karsten Weiss [ 10/Dec/13 ]

IMHO the interesting question is: Why couldn't the compiler help to prevent this bug as a type error in the first place? Wouldn't it help if the prototype of cfs_hash_keycpy() did not use a void* type for the "key" argument?

Comment by Liang Zhen (Inactive) [ 11/Dec/13 ]

Karsten, I will add const for key type in upcoming patch, which can prevent this from happening.

Comment by Peter Jones [ 18/Dec/13 ]

Landed for 2.4.2 and 2.6. Will land for 2.5.1 shortly

Generated at Sat Feb 10 01:42:03 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.