linux-next: manual merge of the akpm-current tree with the pidfd tree
From: Stephen Rothwell
Date: Tue Apr 23 2019 - 04:47:12 EST
Hi all,
Today's linux-next merge of the akpm-current tree got a conflict in:
kernel/fork.c
between commit:
2897d468ea48 ("clone: add CLONE_PIDFD")
from the pidfd tree and commit:
83e1afab81ac ("userfaultfd: use RCU to free the task struct when fork fails")
from the akpm-current tree.
I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging. You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.
--
Cheers,
Stephen Rothwell
diff --cc kernel/fork.c
index ad2896dd8df2,1c10a912b9b6..000000000000
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@@ -1667,58 -1673,24 +1678,76 @@@ static inline void rcu_copy_process(str
#endif /* #ifdef CONFIG_TASKS_RCU */
}
+static int pidfd_release(struct inode *inode, struct file *file)
+{
+ struct pid *pid = file->private_data;
+
+ file->private_data = NULL;
+ put_pid(pid);
+ return 0;
+}
+
+#ifdef CONFIG_PROC_FS
+static void pidfd_show_fdinfo(struct seq_file *m, struct file *f)
+{
+ struct pid_namespace *ns = proc_pid_ns(file_inode(m->file));
+ struct pid *pid = f->private_data;
+
+ seq_put_decimal_ull(m, "Pid:\t", pid_nr_ns(pid, ns));
+ seq_putc(m, '\n');
+}
+#endif
+
+const struct file_operations pidfd_fops = {
+ .release = pidfd_release,
+#ifdef CONFIG_PROC_FS
+ .show_fdinfo = pidfd_show_fdinfo,
+#endif
+};
+
+/**
+ * pidfd_create() - Create a new pid file descriptor.
+ *
+ * @pid: struct pid that the pidfd will reference
+ *
+ * This creates a new pid file descriptor with the O_CLOEXEC flag set.
+ *
+ * Note, that this function can only be called after the fd table has
+ * been unshared to avoid leaking the pidfd to the new process.
+ *
+ * Return: On success, a cloexec pidfd is returned.
+ * On error, a negative errno number will be returned.
+ */
+static int pidfd_create(struct pid *pid)
+{
+ int fd;
+
+ fd = anon_inode_getfd("[pidfd]", &pidfd_fops, get_pid(pid),
+ O_RDWR | O_CLOEXEC);
+ if (fd < 0)
+ put_pid(pid);
+
+ return fd;
+}
+
+ #ifdef CONFIG_MEMCG
+ static void __delayed_free_task(struct rcu_head *rhp)
+ {
+ struct task_struct *tsk = container_of(rhp, struct task_struct, rcu);
+
+ free_task(tsk);
+ }
+ #endif /* CONFIG_MEMCG */
+
+ static __always_inline void delayed_free_task(struct task_struct *tsk)
+ {
+ #ifdef CONFIG_MEMCG
+ call_rcu(&tsk->rcu, __delayed_free_task);
+ #else /* CONFIG_MEMCG */
+ free_task(tsk);
+ #endif /* CONFIG_MEMCG */
+ }
+
/*
* This creates a new process as a copy of the old one,
* but does not actually start it yet.
Attachment:
pgpJPjHCgOkAU.pgp
Description: OpenPGP digital signature