lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Wed, 30 Jul 2008 01:16:40 -0700
From:	"Paul Menage" <menage@...gle.com>
To:	"Li Zefan" <lizf@...fujitsu.com>
Cc:	"Andrew Morton" <akpm@...ux-foundation.org>,
	LKML <linux-kernel@...r.kernel.org>,
	"Linux Containers" <containers@...ts.linux-foundation.org>
Subject: Re: [PATCH] cgroup: fix possible memory leak

On Sun, Jul 27, 2008 at 7:20 PM, Li Zefan <lizf@...fujitsu.com> wrote:
> There's a leak if copy_from_user() returns failure.
>
> Signed-off-by: Li Zefan <lizf@...fujitsu.com>

Acked-by: Paul Menage <menage@...gle.com>

Thanks, good catch.

> ---
>  kernel/cgroup.c |    7 +++++--
>  1 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/cgroup.c b/kernel/cgroup.c
> index 657f8f8..28debe4 100644
> --- a/kernel/cgroup.c
> +++ b/kernel/cgroup.c
> @@ -1424,14 +1424,17 @@ static ssize_t cgroup_write_string(struct cgroup *cgrp, struct cftype *cft,
>                if (buffer == NULL)
>                        return -ENOMEM;
>        }
> -       if (nbytes && copy_from_user(buffer, userbuf, nbytes))
> -               return -EFAULT;
> +       if (nbytes && copy_from_user(buffer, userbuf, nbytes)) {
> +               retval = -EFAULT;
> +               goto out;
> +       }
>
>        buffer[nbytes] = 0;     /* nul-terminate */
>        strstrip(buffer);
>        retval = cft->write_string(cgrp, cft, buffer);
>        if (!retval)
>                retval = nbytes;
> +out:
>        if (buffer != local_buffer)
>                kfree(buffer);
>        return retval;
> --
> 1.5.4.rc3
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists