[PATCH] [hardy & intrepid SRU, jaunty] UBUNTU: fix apparmor memory leak on unlinked file ops

Andy Whitcroft apw at canonical.com
Wed Mar 4 17:00:08 UTC 2009


On Wed, Mar 04, 2009 at 08:51:12AM -0800, Steve Beattie wrote:
> Proposed for inclusion in hardy and intrpid SRUs, also needs to be
> applied to jaunty.
> 
> Apparmor leaks memory when performing permission checks on operations on
> unlinked files; fixes LP: #329489. Bug report has a testcase attached.
> I've tested that it fixes the issue locally and have provided kernels
> in my PPA for community members to test (linked in the bug report),
> but have not received feedback.
> 
> Patch is from apparmor upstream.
> 
> (Apologies if I've messed up generating the git patch.)
> 
> From f19ad4a30674c0ffa2fdd7be9744e1716411fe66 Mon Sep 17 00:00:00 2001
> From: Steve Beattie <sbeattie at ubuntu.com>
> Date: Fri, 27 Feb 2009 11:43:22 -0800
> Subject: [PATCH] UBUNTU: fix apparmor memory leak on deleted file ops
> 
> OriginalAuthor: John Johansen <jrjohansen at verizon.net>
> OriginalLocation: https://forgesvn1.novell.com/viewsvn/apparmor?view=rev&revision=1380
> Bug: #329489
> 
> Fixes a memory leak that occurs when apparmor performs permission checks
> on paths that have been deleted (e.g. fcntl on an unlinked file).
> 
> Signed-off-by: Steve Beattie <sbeattie at ubuntu.com>
> ---
>  security/apparmor/main.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/security/apparmor/main.c b/security/apparmor/main.c
> index 9d8032a..5f9c1cd 100644
> --- a/security/apparmor/main.c
> +++ b/security/apparmor/main.c
> @@ -497,10 +497,10 @@ static char *aa_get_name(struct dentry *dentry, struct vfsmount *mnt,
>  			*buffer = buf;
>  			return name;
>  		}
> +		kfree(buf);
>  		if (PTR_ERR(name) != -ENAMETOOLONG)
>  			return name;
>  
> -		kfree(buf);
>  		size <<= 1;
>  		if (size > apparmor_path_max)
>  			return ERR_PTR(-ENAMETOOLONG);
> -- 

Obviously correct to my eye.

ACK.

-apw




More information about the kernel-team mailing list