User: Password:
|
|
Subscribe / Log in / New account

Avoid 'names_cache' memory leak with CONFIG_AUDITSYSCALL

From:  Linux Kernel Mailing List <linux-kernel-AT-vger.kernel.org>
To:  git-commits-head-AT-vger.kernel.org
Subject:  Avoid 'names_cache' memory leak with CONFIG_AUDITSYSCALL
Date:  Thu, 6 Oct 2005 22:59:22 -0700
Archive-link:  Article, Thread

tree b38d26d6c99f043f14242351ac084f8b088a772b
parent edb4a3534adbaf90768d67da35f0bfeac4767db6
author Linus Torvalds <torvalds@g5.osdl.org> Fri, 07 Oct 2005 11:54:21 -0700
committer Linus Torvalds <torvalds@g5.osdl.org> Fri, 07 Oct 2005 11:54:21 -0700

Avoid 'names_cache' memory leak with CONFIG_AUDITSYSCALL

The nameidata "last.name" is always allocated with "__getname()", and
should always be free'd with "__putname()".

Using "putname()" without the underscores will leak memory, because the
allocation will have been hidden from the AUDITSYSCALL code.

Arguably the real bug is that the AUDITSYSCALL code is really broken,
but in the meantime this fixes the problem people see.

Reported by Robert Derr, patch by Rick Lindsley.

Acked-by: Al Viro <viro@ftp.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

 fs/namei.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1551,19 +1551,19 @@ do_link:
 	if (nd->last_type != LAST_NORM)
 		goto exit;
 	if (nd->last.name[nd->last.len]) {
-		putname(nd->last.name);
+		__putname(nd->last.name);
 		goto exit;
 	}
 	error = -ELOOP;
 	if (count++==32) {
-		putname(nd->last.name);
+		__putname(nd->last.name);
 		goto exit;
 	}
 	dir = nd->dentry;
 	down(&dir->d_inode->i_sem);
 	path.dentry = __lookup_hash(&nd->last, nd->dentry, nd);
 	path.mnt = nd->mnt;
-	putname(nd->last.name);
+	__putname(nd->last.name);
 	goto do_last;
 }
 


(Log in to post comments)


Copyright © 2005, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds