History

tty: add TIOCGPTPEER ioctl

When opening the slave end of a PTY, it is not possible for userspace to safely ensure that /dev/pts/$num is actually a slave (in cases where the mount namespace in which devpts was mounted is controlled by an untrusted process). In addition, there are several unresolvable race conditions if userspace were to attempt to detect attacks through stat(2) and other similar methods [in addition it is not clear how userspace could detect attacks involving FUSE]. Resolve this by providing an interface for userpace to safely open the "peer" end of a PTY file descriptor by using the dentry cached by devpts. Since it is not possible to have an open master PTY without having its slave exposed in /dev/pts this interface is safe. This interface currently does not provide a way to get the master pty (since it is not clear whether such an interface is safe or even useful).

Aleksa Sarai committed 9 years ago

Commit 54ebbfb1 parent 5f0f1879 files · +76 −5Browse files

Showing the changes to include/uapi (1 of 9 files). Show all

Unified · Split

include/uapi/asm-generic/ioctls.h+1−0
@@ -77,6 +77,7 @@ · 76 unmodified lines
7777 #define TIOCGPKT _IOR('T', 0x38, int) /* Get packet mode state */
7878 #define TIOCGPTLCK _IOR('T', 0x39, int) /* Get Pty lock state */
7979 #define TIOCGEXCL _IOR('T', 0x40, int) /* Get exclusive mode state */
80+#define TIOCGPTPEER _IOR('T', 0x41, int) /* Safely open the slave */
8081
8182 #define FIONCLEX 0x5450
8283 #define FIOCLEX 0x5451

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t