Thread (16 messages) 16 messages, 3 authors, 2020-01-28

Re: [PATCH v7 02/11] proc: add proc_fs_info struct to store proc information

From: Oleg Nesterov <oleg@redhat.com>
Date: 2020-01-28 13:43:56
Also in: linux-fsdevel, linux-security-module, lkml

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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help