Skip to content

Commit 4969f8a

Browse files
committed
pidfd: Add missing sock updates for pidfd_getfd()
The sock counting (sock_update_netprioidx() and sock_update_classid()) was missing from pidfd's implementation of received fd installation. Add a call to the new __receive_sock() helper. Cc: Christian Brauner <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Sargun Dhillon <[email protected]> Cc: Jakub Kicinski <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Fixes: 8649c32 ("pid: Implement pidfd_getfd syscall") Signed-off-by: Kees Cook <[email protected]>
1 parent d953975 commit 4969f8a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

kernel/pid.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include <linux/sched/signal.h>
4343
#include <linux/sched/task.h>
4444
#include <linux/idr.h>
45+
#include <net/sock.h>
4546

4647
struct pid init_struct_pid = {
4748
.count = REFCOUNT_INIT(1),
@@ -642,10 +643,12 @@ static int pidfd_getfd(struct pid *pid, int fd)
642643
}
643644

644645
ret = get_unused_fd_flags(O_CLOEXEC);
645-
if (ret < 0)
646+
if (ret < 0) {
646647
fput(file);
647-
else
648+
} else {
649+
__receive_sock(file);
648650
fd_install(ret, file);
651+
}
649652

650653
return ret;
651654
}

0 commit comments

Comments
 (0)