@@ -804,58 +804,8 @@ static int pidfs_export_permission(struct handle_to_path_ctx *ctx,
804804 return 0 ;
805805}
806806
807- static inline bool pidfs_pid_valid (struct pid * pid , const struct path * path ,
808- unsigned int flags )
809- {
810- enum pid_type type ;
811-
812- if (flags & PIDFD_STALE )
813- return true;
814-
815- /*
816- * Make sure that if a pidfd is created PIDFD_INFO_EXIT
817- * information will be available. So after an inode for the
818- * pidfd has been allocated perform another check that the pid
819- * is still alive. If it is exit information is available even
820- * if the task gets reaped before the pidfd is returned to
821- * userspace. The only exception are indicated by PIDFD_STALE:
822- *
823- * (1) The kernel is in the middle of task creation and thus no
824- * task linkage has been established yet.
825- * (2) The caller knows @pid has been registered in pidfs at a
826- * time when the task was still alive.
827- *
828- * In both cases exit information will have been reported.
829- */
830- if (flags & PIDFD_THREAD )
831- type = PIDTYPE_PID ;
832- else
833- type = PIDTYPE_TGID ;
834-
835- /*
836- * Since pidfs_exit() is called before struct pid's task linkage
837- * is removed the case where the task got reaped but a dentry
838- * was already attached to struct pid and exit information was
839- * recorded and published can be handled correctly.
840- */
841- if (unlikely (!pid_has_task (pid , type ))) {
842- struct pidfs_attr * attr ;
843-
844- attr = READ_ONCE (pid -> attr );
845- if (!attr )
846- return false;
847- if (!READ_ONCE (attr -> exit_info ))
848- return false;
849- }
850-
851- return true;
852- }
853-
854807static struct file * pidfs_export_open (struct path * path , unsigned int oflags )
855808{
856- if (!pidfs_pid_valid (d_inode (path -> dentry )-> i_private , path , oflags ))
857- return ERR_PTR (- ESRCH );
858-
859809 /*
860810 * Clear O_LARGEFILE as open_by_handle_at() forces it and raise
861811 * O_RDWR as pidfds always are.
@@ -993,9 +943,6 @@ struct file *pidfs_alloc_file(struct pid *pid, unsigned int flags)
993943 if (ret < 0 )
994944 return ERR_PTR (ret );
995945
996- if (!pidfs_pid_valid (pid , & path , flags ))
997- return ERR_PTR (- ESRCH );
998-
999946 flags &= ~PIDFD_STALE ;
1000947 flags |= O_RDWR ;
1001948 pidfd_file = dentry_open (& path , flags , current_cred ());
0 commit comments