Subject: linux-next: manual merge of the akpm-current tree with the pidfd tree

From: Stephen Rothwell <[email-masked]>
Date: Tue, 22 Sep 2020 18:54:33 +1000

Hi all,

Today's linux-next merge of the akpm-current tree got a conflict in:

  kernel/exit.c

between commit:

  ba7d25f3dff6 ("exit: support non-blocking pidfds")

from the pidfd tree and patch:

  "pid: move pidfd_get_pid() to pid.c"

from the akpm-current tree.

I fixed it up (I made the changes from the former to kernel/pid.c - 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.

I also had to add the following fix patch after

  "mm/madvise: introduce process_madvise() syscall: an external memory hinting API"

From: Stephen Rothwell <[email-masked]>
Date: Tue, 22 Sep 2020 18:36:35 +1000
Subject: [PATCH] fix up for pidfd_get_pid() API change

Signed-off-by: Stephen Rothwell <[email-masked]>
---
 mm/madvise.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/madvise.c b/mm/madvise.c
index a0ebeb5e2411..51317bd3c69d 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -1189,11 +1189,12 @@ static ssize_t do_process_madvise(int pidfd, struct iov_iter *iter,
 	struct task_struct *task;
 	struct mm_struct *mm;
 	size_t total_len = iov_iter_count(iter);
+	unsigned int pidfd_flags;
 
 	if (flags != 0)
 		return -EINVAL;
 
-	pid = pidfd_get_pid(pidfd);
+	pid = pidfd_get_pid(pidfd, &pidfd_flags);
 	if (IS_ERR(pid))
 		return PTR_ERR(pid);
 
-- 
2.28.0

-- 
Cheers,
Stephen Rothwell

diff --git a/include/linux/pid.h b/include/linux/pid.h
index 176d6cf80e7c..fa10acb8d6a4 100644
--- a/include/linux/pid.h
+++ b/include/linux/pid.h
@@ -77,7 +77,7 @@ extern const struct file_operations pidfd_fops;
 struct file;
 
 extern struct pid *pidfd_pid(const struct file *file);
-struct pid *pidfd_get_pid(unsigned int fd);
+struct pid *pidfd_get_pid(unsigned int fd, unsigned int *flags);
 
 static inline struct pid *get_pid(struct pid *pid)
 {
diff --git a/kernel/pid.c b/kernel/pid.c
index c791fe63fa36..47466d0bbc5b 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -520,7 +520,7 @@ struct pid *find_ge_pid(int nr, struct pid_namespace *ns)
 	return idr_get_next(&ns->idr, &nr);
 }
 
-struct pid *pidfd_get_pid(unsigned int fd)
+struct pid *pidfd_get_pid(unsigned int fd, unsigned int *flags)
 {
 	struct fd f;
 	struct pid *pid;
@@ -530,8 +530,10 @@ struct pid *pidfd_get_pid(unsigned int fd)
 		return ERR_PTR(-EBADF);
 
 	pid = pidfd_pid(f.file);
-	if (!IS_ERR(pid))
+	if (!IS_ERR(pid)) {
 		get_pid(pid);
+		*flags = f.file->f_flags;
+	}
 
 	fdput(f);
 	return pid;