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] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 20 Aug 2019 13:41:51 +0000
From:   "Schumaker, Anna" <Anna.Schumaker@...app.com>
To:     "wenwen@...uga.edu" <wenwen@...uga.edu>
CC:     "linux-nfs@...r.kernel.org" <linux-nfs@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "trond.myklebust@...merspace.com" <trond.myklebust@...merspace.com>
Subject: Re: [PATCH] NFSv4: Fix a memory leak bug

Hi Wenwen,

On Tue, 2019-08-20 at 02:54 -0500, Wenwen Wang wrote:
> In nfs4_try_migration(), if nfs4_begin_drain_session() fails, the
> previously allocated 'page' and 'locations' are not deallocated,
> leading to
> memory leaks. To fix this issue, free 'page' and 'locations' before
> returning the error.
> 
> Signed-off-by: Wenwen Wang <wenwen@...uga.edu>
> ---
>  fs/nfs/nfs4state.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
> index cad4e06..37823dc 100644
> --- a/fs/nfs/nfs4state.c
> +++ b/fs/nfs/nfs4state.c
> @@ -2095,8 +2095,12 @@ static int nfs4_try_migration(struct
> nfs_server *server, const struct cred *cred
>         }
> 
>         status = nfs4_begin_drain_session(clp);
> -       if (status != 0)
> +       if (status != 0) {
> +               if (page != NULL)
> +                       __free_page(page);
> +               kfree(locations);
>                 return status;

Thanks for the suggestion! I think a better option would be to switch
the "return status" into a "goto out" so we can keep all our cleanup
code in a single place in case we ever need to change it in the future.

What do you think?
Anna

> +       }
> 
>         status = nfs4_replace_transport(server, locations);
>         if (status != 0) {
> --
> 2.7.4
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ