Skip to contentSkip to conversation

unused fs/jffs2/acl.c:jffs2_clear_acl()

DISCUSSION Adrian Bunk 3 participants 4 messages Jun 29, 2006 – Jul 2, 2006 Journalling flash file system V2 (JFFS2)

lore
Share & tools
lore
#0 lore raw

Hi David,

it might not have been intended that jffs2_clear_acl() in Linus' tree is unused?

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
maintainer
#1 lore raw
Quoted 2 lines · Adrian Bunk

it might not have been intended that jffs2_clear_acl() in Linus' tree is unused?

I suspect you're right -- thanks for pointing it out.

Kaigai-san?

Signature · 1 line
dwmw2
#2 lore raw
Quoted 9 lines · David Woodhouse
Quoted 2 lines · Adrian Bunk

it might not have been intended that jffs2_clear_acl() in Linus' tree is unused?

I suspect you're right -- thanks for pointing it out.

Kaigai-san?

I'm sorry, it's a serious BUG.
When an inode is cleared, jffs2_clear_acl() should be called to release on-memory ACL. Because the current implementation didn't care about this cleaning-up, we have memory-leaking.

Please wait a patch for a while.

Thanks,

Signature · 1 line
KaiGai Kohei <[email protected]>
#3 lore raw

[JFFS2][XATTR] Fix memory leak in POSIX-ACL support

* jffs2-xattr-v6.2-02-fix-posix_acl-memory-leak.patch

jffs2_clear_acl() which releases acl caches allocated by kmalloc() was defined but it was never called. Thus, we faced to the risk of memory leaking.

This patch plugs jffs2_clear_acl() into jffs2_do_clear_inode(). It ensures to release acl cache when inode is cleared.

Thanks,

Quoted 22 lines · KaiGai Kohei
Quoted 10 lines · David Woodhouse
Quoted 2 lines · Adrian Bunk

it might not have been intended that jffs2_clear_acl() in Linus' tree is unused?

I suspect you're right -- thanks for pointing it out.

Kaigai-san?

I'm sorry, it's a serious BUG.
When an inode is cleared, jffs2_clear_acl() should be called to release on-memory ACL. Because the current implementation didn't care about this cleaning-up, we have memory-leaking.

Please wait a patch for a while.

Thanks,

Signature · 1 line
KaiGai Kohei <[email protected]>
fs/jffs2/acl.c +1 -3
index 9c2077e..0ae3cd1 100644
@@ -345,10 +345,8 @@ int jffs2_init_acl(struct inode *inode, 
 	return rc;
 }
 
-void jffs2_clear_acl(struct inode *inode)
+void jffs2_clear_acl(struct jffs2_inode_info *f)
 {
-	struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
-
 	if (f->i_acl_access && f->i_acl_access != JFFS2_ACL_NOT_CACHED) {
 		posix_acl_release(f->i_acl_access);
 		f->i_acl_access = JFFS2_ACL_NOT_CACHED;
fs/jffs2/acl.h +2 -2
index 8893bd1..fa327db 100644
@@ -30,7 +30,7 @@ #define JFFS2_ACL_NOT_CACHED ((void *)-1
 extern int jffs2_permission(struct inode *, int, struct nameidata *);
 extern int jffs2_acl_chmod(struct inode *);
 extern int jffs2_init_acl(struct inode *, struct inode *);
-extern void jffs2_clear_acl(struct inode *);
+extern void jffs2_clear_acl(struct jffs2_inode_info *);
 
 extern struct xattr_handler jffs2_acl_access_xattr_handler;
 extern struct xattr_handler jffs2_acl_default_xattr_handler;
@@ -40,6 +40,6 @@ #else
 #define jffs2_permission NULL
 #define jffs2_acl_chmod(inode)		(0)
 #define jffs2_init_acl(inode,dir)	(0)
-#define jffs2_clear_acl(inode)
+#define jffs2_clear_acl(f)
 
 #endif	/* CONFIG_JFFS2_FS_POSIX_ACL */
fs/jffs2/readinode.c +1 -0
index cc18992..266423b 100644
@@ -968,6 +968,7 @@ void jffs2_do_clear_inode(struct jffs2_s
 	struct jffs2_full_dirent *fd, *fds;
 	int deleted;
 
+	jffs2_clear_acl(f);
 	jffs2_xattr_delete_inode(c, f->inocache);
 	down(&f->sem);
 	deleted = f->inocache && !f->inocache->nlink;