skipped 113 lines 114 114 u32 id; 115 115 pid_t sid; 116 116 pid_t pgrp; 117 + pid_t pid_real; 117 118 int fd; 118 119 int mnt_id; 119 120 struct tty_driver *driver; skipped 1632 lines 1752 1753 dinfo->id = id; 1753 1754 dinfo->sid = pti->sid; 1754 1755 dinfo->pgrp = pti->pgrp; 1756 + dinfo->pid_real = p->pid; 1755 1757 dinfo->fd = p->fd; 1756 1758 dinfo->mnt_id = p->mnt_id; 1757 1759 dinfo->driver = driver; skipped 353 lines 2111 2113 return ret; 2112 2114 } 2113 2115 2116 + static int tty_verify_ctty(void) 2117 + { 2118 + struct tty_dump_info *d, *p; 2119 + 2120 + list_for_each_entry(d, &all_ttys, list) { 2121 + struct tty_dump_info *n = NULL; 2122 + 2123 + if (d->driver->type != TTY_TYPE__CTTY) 2124 + continue; 2125 + 2126 + list_for_each_entry(p, &all_ttys, list) { 2127 + if (!is_pty(p->driver) || 2128 + p->sid != d->sid || 2129 + p->pgrp != d->sid) 2130 + continue; 2131 + n = p; 2132 + break; 2133 + } 2134 + 2135 + if (!n) { 2136 + pr_err("ctty inheritance detected sid/pgrp %d, " 2137 + "no PTY peer with sid/pgrp needed\n", 2138 + d->sid); 2139 + return -ENOENT; 2140 + } else if (n->pid_real != d->pid_real) { 2141 + pr_err("ctty inheritance detected sid/pgrp %d " 2142 + "(ctty pid_real %d pty pid_real %d)\n", 2143 + d->sid, d->pid_real, n->pid_real); 2144 + return -ENOENT; 2145 + } 2146 + } 2147 + 2148 + return 0; 2149 + } 2150 + 2114 2151 int tty_post_actions(void) 2115 2152 { 2153 + if (tty_verify_ctty()) 2154 + return -1; 2116 2155 if (tty_verify_active_pairs(NULL)) 2117 2156 return -1; 2118 2157 else if (tty_dump_queued_data()) skipped 157 lines