[PATCH] linux ttyname and ttyname_r: return link if appropriate

Florian Weimer fweimer@redhat.com
Wed Aug 10 06:38:00 GMT 2016


On 08/09/2016 11:39 PM, Serge E. Hallyn wrote:
> 2. If the passed-in link (say /proc/self/fd/0) points to
> a device, say /dev/pts/2, in a parent mount namespace, and
> /dev/pts/2 does not exist in the current namespace, it
> returns success but an empty name.  As far as I can tell,
> there is no reason for it to not return /proc/self/fd/0.

I'm still concerned that returning something which is not a stable 
reference to a fixed PTY could introduce security vulnerabilities 
because some applications may assume that if ttyname succeeds, the 
returned name is safe to chmod/chown (even if the descriptor is closed 
beforehand).

Maybe this is small risk and is worth the change.  It seems rather 
unlikely that the process would close the descriptor and open a new one 
in its place before the file system change.

Florian



More information about the Libc-alpha mailing list