[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200128134337.GC17943@redhat.com>
Date: Tue, 28 Jan 2020 14:43:37 +0100
From: Oleg Nesterov <oleg@...hat.com>
To: Alexey Gladkov <gladkov.alexey@...il.com>
Cc: LKML <linux-kernel@...r.kernel.org>,
Kernel Hardening <kernel-hardening@...ts.openwall.com>,
Linux API <linux-api@...r.kernel.org>,
Linux FS Devel <linux-fsdevel@...r.kernel.org>,
Linux Security Module <linux-security-module@...r.kernel.org>,
Akinobu Mita <akinobu.mita@...il.com>,
Alexander Viro <viro@...iv.linux.org.uk>,
Alexey Dobriyan <adobriyan@...il.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Andy Lutomirski <luto@...nel.org>,
Daniel Micay <danielmicay@...il.com>,
Djalal Harouni <tixxdz@...il.com>,
"Dmitry V . Levin" <ldv@...linux.org>,
"Eric W . Biederman" <ebiederm@...ssion.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Ingo Molnar <mingo@...nel.org>,
"J . Bruce Fields" <bfields@...ldses.org>,
Jeff Layton <jlayton@...chiereds.net>,
Jonathan Corbet <corbet@....net>,
Kees Cook <keescook@...omium.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Solar Designer <solar@...nwall.com>,
Stephen Rothwell <sfr@...b.auug.org.au>
Subject: Re: [PATCH v7 02/11] proc: add proc_fs_info struct to store proc
information
On 01/25, Alexey Gladkov wrote:
>
> static int proc_init_fs_context(struct fs_context *fc)
> {
> struct proc_fs_context *ctx;
> + struct pid_namespace *pid_ns;
>
> ctx = kzalloc(sizeof(struct proc_fs_context), GFP_KERNEL);
> if (!ctx)
> return -ENOMEM;
>
> - ctx->pid_ns = get_pid_ns(task_active_pid_ns(current));
> + pid_ns = get_pid_ns(task_active_pid_ns(current));
> +
> + if (!pid_ns->proc_mnt) {
> + ctx->fs_info = kzalloc(sizeof(struct proc_fs_info), GFP_KERNEL);
> + if (!ctx->fs_info) {
> + kfree(ctx);
> + return -ENOMEM;
> + }
> + ctx->fs_info->pid_ns = pid_ns;
> + } else {
> + ctx->fs_info = proc_sb_info(pid_ns->proc_mnt->mnt_sb);
> + }
> +
it seems that this code lacks put_pid_ns() if pid_ns->proc_mnt != NULL
or if kzalloc() fails?
Or, better,
pid_ns = task_active_pid_ns();
if (!pid_ns->proc_mnt) {
ctx->fs_info = kzalloc();
...
ctx->fs_info->pid_ns = get_pid_ns(pid_ns);
}
No?
Oleg.
Powered by blists - more mailing lists