All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][next] apparmor: fix memory leak on buffer on error exit path
@ 2018-03-27 13:35 ` Colin King
  0 siblings, 0 replies; 6+ messages in thread
From: Colin King @ 2018-03-27 13:35 UTC (permalink / raw)
  To: John Johansen, James Morris, linux-security-module
  Cc: kernel-janitors, Serge E . Hallyn, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Currently on the error exit path the allocated buffer is not free'd
causing a memory leak. Fix this by kfree'ing it.

Detected by CoverityScan, CID#1466876 ("Resource leaks")

Fixes: 1180b4c757aa ("apparmor: fix dangling symlinks to policy rawdata after replacement")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 security/apparmor/apparmorfs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
index 96bb6b73af65..949dd8a48164 100644
--- a/security/apparmor/apparmorfs.c
+++ b/security/apparmor/apparmorfs.c
@@ -1497,8 +1497,10 @@ static char *gen_symlink_name(int depth, const char *dirname, const char *fname)
 	}
 
 	error = snprintf(s, size, "raw_data/%s/%s", dirname, fname);
-	if (error >= size || error < 0)
+	if (error >= size || error < 0) {
+		kfree(buffer);
 		return ERR_PTR(-ENAMETOOLONG);
+	}
 
 	return buffer;
 }
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH][next] apparmor: fix memory leak on buffer on error exit path
@ 2018-03-27 13:35 ` Colin King
  0 siblings, 0 replies; 6+ messages in thread
From: Colin King @ 2018-03-27 13:35 UTC (permalink / raw)
  To: linux-security-module

From: Colin Ian King <colin.king@canonical.com>

Currently on the error exit path the allocated buffer is not free'd
causing a memory leak. Fix this by kfree'ing it.

Detected by CoverityScan, CID#1466876 ("Resource leaks")

Fixes: 1180b4c757aa ("apparmor: fix dangling symlinks to policy rawdata after replacement")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 security/apparmor/apparmorfs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
index 96bb6b73af65..949dd8a48164 100644
--- a/security/apparmor/apparmorfs.c
+++ b/security/apparmor/apparmorfs.c
@@ -1497,8 +1497,10 @@ static char *gen_symlink_name(int depth, const char *dirname, const char *fname)
 	}
 
 	error = snprintf(s, size, "raw_data/%s/%s", dirname, fname);
-	if (error >= size || error < 0)
+	if (error >= size || error < 0) {
+		kfree(buffer);
 		return ERR_PTR(-ENAMETOOLONG);
+	}
 
 	return buffer;
 }
-- 
2.15.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH][next] apparmor: fix memory leak on buffer on error exit path
@ 2018-03-27 13:35 ` Colin King
  0 siblings, 0 replies; 6+ messages in thread
From: Colin King @ 2018-03-27 13:35 UTC (permalink / raw)
  To: linux-security-module

From: Colin Ian King <colin.king@canonical.com>

Currently on the error exit path the allocated buffer is not free'd
causing a memory leak. Fix this by kfree'ing it.

Detected by CoverityScan, CID#1466876 ("Resource leaks")

Fixes: 1180b4c757aa ("apparmor: fix dangling symlinks to policy rawdata after replacement")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 security/apparmor/apparmorfs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
index 96bb6b73af65..949dd8a48164 100644
--- a/security/apparmor/apparmorfs.c
+++ b/security/apparmor/apparmorfs.c
@@ -1497,8 +1497,10 @@ static char *gen_symlink_name(int depth, const char *dirname, const char *fname)
 	}
 
 	error = snprintf(s, size, "raw_data/%s/%s", dirname, fname);
-	if (error >= size || error < 0)
+	if (error >= size || error < 0) {
+		kfree(buffer);
 		return ERR_PTR(-ENAMETOOLONG);
+	}
 
 	return buffer;
 }
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info@ http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH][next] apparmor: fix memory leak on buffer on error exit path
  2018-03-27 13:35 ` Colin King
  (?)
@ 2018-03-31  4:12   ` John Johansen
  -1 siblings, 0 replies; 6+ messages in thread
From: John Johansen @ 2018-03-31  4:12 UTC (permalink / raw)
  To: Colin King, James Morris, linux-security-module
  Cc: kernel-janitors, Serge E . Hallyn, linux-kernel

On 03/27/2018 06:35 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently on the error exit path the allocated buffer is not free'd
> causing a memory leak. Fix this by kfree'ing it.
> 
> Detected by CoverityScan, CID#1466876 ("Resource leaks")
> 
> Fixes: 1180b4c757aa ("apparmor: fix dangling symlinks to policy rawdata after replacement")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

thanks Colin

I've pulled it into apparmor-next

> ---
>  security/apparmor/apparmorfs.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
> index 96bb6b73af65..949dd8a48164 100644
> --- a/security/apparmor/apparmorfs.c
> +++ b/security/apparmor/apparmorfs.c
> @@ -1497,8 +1497,10 @@ static char *gen_symlink_name(int depth, const char *dirname, const char *fname)
>  	}
>  
>  	error = snprintf(s, size, "raw_data/%s/%s", dirname, fname);
> -	if (error >= size || error < 0)
> +	if (error >= size || error < 0) {
> +		kfree(buffer);
>  		return ERR_PTR(-ENAMETOOLONG);
> +	}
>  
>  	return buffer;
>  }
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH][next] apparmor: fix memory leak on buffer on error exit path
@ 2018-03-31  4:12   ` John Johansen
  0 siblings, 0 replies; 6+ messages in thread
From: John Johansen @ 2018-03-31  4:12 UTC (permalink / raw)
  To: linux-security-module

On 03/27/2018 06:35 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently on the error exit path the allocated buffer is not free'd
> causing a memory leak. Fix this by kfree'ing it.
> 
> Detected by CoverityScan, CID#1466876 ("Resource leaks")
> 
> Fixes: 1180b4c757aa ("apparmor: fix dangling symlinks to policy rawdata after replacement")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

thanks Colin

I've pulled it into apparmor-next

> ---
>  security/apparmor/apparmorfs.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
> index 96bb6b73af65..949dd8a48164 100644
> --- a/security/apparmor/apparmorfs.c
> +++ b/security/apparmor/apparmorfs.c
> @@ -1497,8 +1497,10 @@ static char *gen_symlink_name(int depth, const char *dirname, const char *fname)
>  	}
>  
>  	error = snprintf(s, size, "raw_data/%s/%s", dirname, fname);
> -	if (error >= size || error < 0)
> +	if (error >= size || error < 0) {
> +		kfree(buffer);
>  		return ERR_PTR(-ENAMETOOLONG);
> +	}
>  
>  	return buffer;
>  }
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH][next] apparmor: fix memory leak on buffer on error exit path
@ 2018-03-31  4:12   ` John Johansen
  0 siblings, 0 replies; 6+ messages in thread
From: John Johansen @ 2018-03-31  4:12 UTC (permalink / raw)
  To: linux-security-module

On 03/27/2018 06:35 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently on the error exit path the allocated buffer is not free'd
> causing a memory leak. Fix this by kfree'ing it.
> 
> Detected by CoverityScan, CID#1466876 ("Resource leaks")
> 
> Fixes: 1180b4c757aa ("apparmor: fix dangling symlinks to policy rawdata after replacement")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

thanks Colin

I've pulled it into apparmor-next

> ---
>  security/apparmor/apparmorfs.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
> index 96bb6b73af65..949dd8a48164 100644
> --- a/security/apparmor/apparmorfs.c
> +++ b/security/apparmor/apparmorfs.c
> @@ -1497,8 +1497,10 @@ static char *gen_symlink_name(int depth, const char *dirname, const char *fname)
>  	}
>  
>  	error = snprintf(s, size, "raw_data/%s/%s", dirname, fname);
> -	if (error >= size || error < 0)
> +	if (error >= size || error < 0) {
> +		kfree(buffer);
>  		return ERR_PTR(-ENAMETOOLONG);
> +	}
>  
>  	return buffer;
>  }
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-03-31  4:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-27 13:35 [PATCH][next] apparmor: fix memory leak on buffer on error exit path Colin King
2018-03-27 13:35 ` Colin King
2018-03-27 13:35 ` Colin King
2018-03-31  4:12 ` John Johansen
2018-03-31  4:12   ` John Johansen
2018-03-31  4:12   ` John Johansen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.