Skip to contentSkip to conversation

freeing memory allocated in security_inode_init_security()

Ocfs2-devel Mimi Zohar 3 participants 4 messages May 4, 2011 – May 30, 2011 OCFS2

lore
Share & tools
lore

Mimi Zohar

author
#0 lore raw

Hi,

Although it isn't documented in security.c, the LSM security_inode_init_security() hook allocates memory for xattr name and value, expecting the caller to release the memory afterwards.

I'm making my way through the different filesystems adding a subsequent call to evm_inode_post_init_security(). I see the call to ocfs2_init_security_and_acl() calls ocfs2_init_security_get(), which in turn calls security_inode_init_security(), but am having a hard time finding where the name and value are subsequently freed. Would appreciate if someone could point it out.

thanks,

Mimi

#1 lore raw
Quoted 10 lines · Mimi Zohar

Although it isn't documented in security.c, the LSM security_inode_init_security() hook allocates memory for xattr name and value, expecting the caller to release the memory afterwards.

I'm making my way through the different filesystems adding a subsequent call to evm_inode_post_init_security(). I see the call to ocfs2_init_security_and_acl() calls ocfs2_init_security_get(), which in turn calls security_inode_init_security(), but am having a hard time finding where the name and value are subsequently freed. Would appreciate if someone could point it out.

I think we have a leak in the reflink code path. mknod and symlink code paths free the name/value pair.

Tiger, Please could you post a fix.

#2 lore raw
Quoted 12 lines · Sunil Mushran
Quoted 10 lines · Mimi Zohar

Although it isn't documented in security.c, the LSM security_inode_init_security() hook allocates memory for xattr name and value, expecting the caller to release the memory afterwards.

I'm making my way through the different filesystems adding a subsequent call to evm_inode_post_init_security(). I see the call to ocfs2_init_security_and_acl() calls ocfs2_init_security_get(), which in turn calls security_inode_init_security(), but am having a hard time finding where the name and value are subsequently freed. Would appreciate if someone could point it out.

Quoted 4 lines

I think we have a leak in the reflink code path. mknod and symlink code paths free the name/value pair.

Tiger, Please could you post a fix.

Hi, Mimi and Sunil,

I send a patch to fix this memory leak.

Thanks,
tiger

author
#3 lore raw
In reply to Mimi Zohar
Quoted 13 lines · Mimi Zohar

Hi,

Although it isn't documented in security.c, the LSM security_inode_init_security() hook allocates memory for xattr name and value, expecting the caller to release the memory afterwards.

I'm making my way through the different filesystems adding a subsequent call to evm_inode_post_init_security(). I see the call to ocfs2_init_security_and_acl() calls ocfs2_init_security_get(), which in turn calls security_inode_init_security(), but am having a hard time finding where the name and value are subsequently freed. Would appreciate if someone could point it out.

Quoted 3 lines

thanks,

Mimi

Although the reiserfs_security_init() comment explicitly states that the caller must call reiserfs_security_free(), I don't see it being done.

Mimi