Commit 82984114 authored by Linus Torvalds's avatar Linus Torvalds

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: default avatarAl Viro <viro@ftp.linux.org.uk>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent edb4a353
...@@ -1551,19 +1551,19 @@ int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd) ...@@ -1551,19 +1551,19 @@ int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
if (nd->last_type != LAST_NORM) if (nd->last_type != LAST_NORM)
goto exit; goto exit;
if (nd->last.name[nd->last.len]) { if (nd->last.name[nd->last.len]) {
putname(nd->last.name); __putname(nd->last.name);
goto exit; goto exit;
} }
error = -ELOOP; error = -ELOOP;
if (count++==32) { if (count++==32) {
putname(nd->last.name); __putname(nd->last.name);
goto exit; goto exit;
} }
dir = nd->dentry; dir = nd->dentry;
down(&dir->d_inode->i_sem); down(&dir->d_inode->i_sem);
path.dentry = __lookup_hash(&nd->last, nd->dentry, nd); path.dentry = __lookup_hash(&nd->last, nd->dentry, nd);
path.mnt = nd->mnt; path.mnt = nd->mnt;
putname(nd->last.name); __putname(nd->last.name);
goto do_last; goto do_last;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment