Thread (19 messages) 19 messages, 5 authors, 2020-08-08
STALE2142d REVIEWED: 2 (0M)
Revisions (4)
  1. v4 [diff vs current]
  2. v5 [diff vs current]
  3. v6 [diff vs current]
  4. v7 current

[PATCH v7 6/9] pidfd: Replace open-coded receive_fd()

From: Kees Cook <hidden>
Date: 2020-07-09 18:27:33
Also in: linux-api, linux-fsdevel, linux-kselftest, lkml
Subsystem: the rest · Maintainer: Linus Torvalds

Replace the open-coded version of receive_fd() with a call to the
new helper.

Thanks to Vamshi K Sthambamkadi [off-list ref] for
catching a missed fput() in an earlier version of this patch.

Reviewed-by: Sargun Dhillon <redacted>
Acked-by: Christian Brauner <redacted>
Signed-off-by: Kees Cook <redacted>
---
 kernel/pid.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)
diff --git a/kernel/pid.c b/kernel/pid.c
index 85ed00abdc7c..da5aea5f04fa 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -636,19 +636,8 @@ static int pidfd_getfd(struct pid *pid, int fd)
 	if (IS_ERR(file))
 		return PTR_ERR(file);
 
-	ret = security_file_receive(file);
-	if (ret) {
-		fput(file);
-		return ret;
-	}
-
-	ret = get_unused_fd_flags(O_CLOEXEC);
-	if (ret < 0) {
-		fput(file);
-	} else {
-		fd_install(ret, file);
-		__receive_sock(file);
-	}
+	ret = receive_fd(file, O_CLOEXEC);
+	fput(file);
 
 	return ret;
 }
-- 
2.25.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help