On 04/14, Oleg Nesterov wrote: > > On 04/14, Christian Brauner wrote: > > > > -static int umh_pipe_setup(struct subprocess_info *info, struct cred *new) > > +static int umh_coredump_setup(struct subprocess_info *info, struct cred *new) > > { > > struct file *files[2]; > > struct coredump_params *cp = (struct coredump_params *)info->data; > > int err; > > > > + if (cp->pid) { > > + struct file *pidfs_file __free(fput) = NULL; > > + > > + pidfs_file = pidfs_alloc_file(cp->pid, 0); > > + if (IS_ERR(pidfs_file)) > > + return PTR_ERR(pidfs_file); > > + > > + /* > > + * Usermode helpers are childen of either > > + * system_unbound_wq or of kthreadd. So we know that > > + * we're starting off with a clean file descriptor > > + * table. So we should always be able to use > > + * COREDUMP_PIDFD_NUMBER as our file descriptor value. > > + */ > > + VFS_WARN_ON_ONCE((pidfs_file = fget_raw(COREDUMP_PIDFD_NUMBER)) != NULL); > > + > > + err = replace_fd(COREDUMP_PIDFD_NUMBER, pidfs_file, 0); > > + if (err < 0) > > + return err; > > Yes, but if replace_fd() succeeds we need to nullify pidfs_file > to avoid fput from __free(fput) ? Aah, please ignore me ;) replace_fd/do_dup2 does get_file() . For this series: Reviewed-by: Oleg Nesterov <oleg@xxxxxxxxxx>