]>
Commit | Line | Data |
---|---|---|
645f4605 CW |
1 | From: Linus Torvalds <torvalds@osdl.org> |
2 | Date: Fri, 7 Oct 2005 04:54:21 +0000 (-0700) | |
3 | Subject: [PATCH] Avoid 'names_cache' memory leak with CONFIG_AUDITSYSCALL | |
4 | ||
5 | Avoid 'names_cache' memory leak with CONFIG_AUDITSYSCALL | |
f1731096 | 6 | |
645f4605 CW |
7 | The nameidata "last.name" is always allocated with "__getname()", and |
8 | should always be free'd with "__putname()". | |
9 | ||
10 | Using "putname()" without the underscores will leak memory, because the | |
11 | allocation will have been hidden from the AUDITSYSCALL code. | |
12 | ||
13 | Arguably the real bug is that the AUDITSYSCALL code is really broken, | |
14 | but in the meantime this fixes the problem people see. | |
15 | ||
16 | Reported by Robert Derr, patch by Rick Lindsley. | |
17 | ||
18 | Acked-by: Al Viro <viro@ftp.linux.org.uk> | |
19 | Signed-off-by: Linus Torvalds <torvalds@osdl.org> | |
20 | Signed-off-by: Chris Wright <chrisw@osdl.org> | |
f1731096 | 21 | Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> |
645f4605 CW |
22 | --- |
23 | fs/namei.c | 6 +++--- | |
e71f4456 | 24 | 1 file changed, 3 insertions(+), 3 deletions(-) |
645f4605 | 25 | |
645f4605 CW |
26 | --- linux-2.6.13.y.orig/fs/namei.c |
27 | +++ linux-2.6.13.y/fs/namei.c | |
28 | @@ -1557,19 +1557,19 @@ do_link: | |
29 | if (nd->last_type != LAST_NORM) | |
30 | goto exit; | |
31 | if (nd->last.name[nd->last.len]) { | |
32 | - putname(nd->last.name); | |
33 | + __putname(nd->last.name); | |
34 | goto exit; | |
35 | } | |
36 | error = -ELOOP; | |
37 | if (count++==32) { | |
38 | - putname(nd->last.name); | |
39 | + __putname(nd->last.name); | |
40 | goto exit; | |
41 | } | |
42 | dir = nd->dentry; | |
43 | down(&dir->d_inode->i_sem); | |
44 | path.dentry = __lookup_hash(&nd->last, nd->dentry, nd); | |
45 | path.mnt = nd->mnt; | |
46 | - putname(nd->last.name); | |
47 | + __putname(nd->last.name); | |
48 | goto do_last; | |
49 | } | |
50 |