Re: Does anyone care about a race free ptsname?

From: H. Peter Anvin
Date: Tue Apr 19 2016 - 17:00:20 EST


On 04/19/2016 01:32 PM, Eric W. Biederman wrote:
>
> The challenge came in operations such as granpt. Where you are passed
> in a ptmx file descriptor from who knows where, and you pass it on
> to applications such as pt_chown which run with elevatated privileged.
>
> As the information is available of where devpts is mounted in
> relationship to /dev/ptmx I have no more concerns about implementing
> ptsname. Path pased is also sufficiently backwards compatible it would
> not usually be wrong even on existing kernels.
>

pt_chown is evil. It should have been removed ages ago, and from the
very beginning have failed if run on a devpts filesystem. Unfortunately
the glibc people didn't do so, and that is a major reason we're in the
current mess.

That being said, the ioctl(TIOCOPENSLAVE) idea would deal with that.

-hpa