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]
Message-ID: <64ynd5y4deefh5wmoudu6j6pud67373hf3esrm4ssn4qi3wq6f@y5ytbxbenwnm>
Date: Tue, 18 Nov 2025 16:34:04 -0500
From: "Liam R. Howlett" <Liam.Howlett@...cle.com>
To: Pavel Tikhomirov <ptikhomirov@...tuozzo.com>
Cc: Ingo Molnar <mingo@...hat.com>, Peter Zijlstra <peterz@...radead.org>,
        Juri Lelli <juri.lelli@...hat.com>,
        Vincent Guittot <vincent.guittot@...aro.org>,
        Dietmar Eggemann <dietmar.eggemann@....com>,
        Steven Rostedt <rostedt@...dmis.org>, Ben Segall <bsegall@...gle.com>,
        Mel Gorman <mgorman@...e.de>, Valentin Schneider <vschneid@...hat.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        David Hildenbrand <david@...nel.org>,
        Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
        Vlastimil Babka <vbabka@...e.cz>, Mike Rapoport <rppt@...nel.org>,
        Suren Baghdasaryan <surenb@...gle.com>, Michal Hocko <mhocko@...e.com>,
        Kees Cook <kees@...nel.org>,
        "Eric W. Biederman" <ebiederm@...ssion.com>,
        Alexey Gladkov <legion@...nel.org>, linux-kernel@...r.kernel.org,
        linux-mm@...ck.org
Subject: Re: [PATCH] unshare: Fix nsproxy leak on set_cred_ucounts() error
 path

* Pavel Tikhomirov <ptikhomirov@...tuozzo.com> [251118 01:46]:
> If unshare_nsproxy_namespaces() successfully creates the new_nsproxy,
> but then set_cred_ucounts() fails, on its error path there is no cleanup
> for new_nsproxy, so it is leaked. Let's fix that by freeing new_nsproxy
> if it's not NULL on this error path.

new_nsproxy may be set to an error pointer, but that case is handled
earlier in this function.  That's a pretty subtle detail.
unshare_nsproxy_namespaces() should probably set it to NULL if it's an
error.. everywhere else looks fine.

This fix looks good!

Reviewed-by: Liam R. Howlett <Liam.Howlett@...cle.com>

> 
> Fixes: 905ae01c4ae2a ("Add a reference to ucounts for each cred")
> Signed-off-by: Pavel Tikhomirov <ptikhomirov@...tuozzo.com>
> ---
>  kernel/fork.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/fork.c b/kernel/fork.c
> index 3da0f08615a95..6f7332e3e0c8c 100644
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -3133,8 +3133,11 @@ int ksys_unshare(unsigned long unshare_flags)
>  
>  	if (new_cred) {
>  		err = set_cred_ucounts(new_cred);
> -		if (err)
> +		if (err) {
> +			if (new_nsproxy)
> +				free_nsproxy(new_nsproxy);
>  			goto bad_unshare_cleanup_cred;
> +		}
>  	}
>  
>  	if (new_fs || new_fd || do_sysvsem || new_cred || new_nsproxy) {
> -- 
> 2.51.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ