Skip to contentSkip to conversation

erofs-utils: lib: fix user-after-free in xattr.c

PATCH In review Hongzhen Luo 2 participants 2 messages Dec 2, 2024 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 erofs-utils: lib: fix user-after-free in xattr.c

Currently, put_xattritem() does not remove the item from the hash table after freeing it, which may lead to a user-after-free issue.

This patch fixes it.

Fixes 47d6895a5ff9 ("erofs-utils: introduce inline xattr support")
---
 lib/xattr.c | 1 +
 1 file changed, 1 insertion(+)
lib/xattr.c +1 -0
index 7fbd24bbdd75..e4207758fa62 100644
@@ -169,6 +169,7 @@ static unsigned int put_xattritem(struct xattr_item *item)
 {
 	if (item->count > 1)
 		return --item->count;
+	hash_del(&item->node);
 	free(item);
 	return 0;
 }
Signature · 1 line
2.43.5