Skip to contentSkip to conversation

pps: reject N_PPS on pseudo-terminals

PATCH Superseded Hungyu Lin 2 participants 2 messages Nov 11 PPS support

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Hungyu Lin

author
#0 lore raw

PATCH v2 1/1 pps: reject N_PPS on pseudo-terminals

Attaching N_PPS to a PTY registers a PPS source even though PTYs do not report DCD changes. An unprivileged user can exhaust the PPS source IDs this way, causing registration of a real PPS source to fail with -EBUSY.

Reject N_PPS on PTYs before allocating a source.

Fixes a0880df0ccde ("pps: serial clients support")

---
Changes in v2:
- Reject PTYs before registering a PPS source, as suggested by Rodolfo.
- Drop the stable Cc.

v1: https://lore.kernel.org/r/[email protected]

 drivers/pps/clients/pps-ldisc.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/pps/clients/pps-ldisc.c +3 -0
index fa5660f3c4b7..83f4caced0c9 100644
@@ -46,6 +46,9 @@ static int pps_tty_open(struct tty_struct *tty)
 	struct pps_device *pps;
 	int ret;
 
+	if (drv->type == TTY_DRIVER_TYPE_PTY)
+		return -EINVAL;
+
 	info.owner = THIS_MODULE;
 	info.dev = NULL;
 	snprintf(info.name, PPS_MAX_NAME_LEN, "%s%d", drv->driver_name, index);
Signature · 1 line
2.50.1 (Apple Git-155)
maintainer Acked-by on v2 1/1
#1 lore raw
Quoted 25 lines · Hungyu Lin

Attaching N_PPS to a PTY registers a PPS source even though PTYs do not report DCD changes. An unprivileged user can exhaust the PPS source IDs this way, causing registration of a real PPS source to fail with -EBUSY.

Reject N_PPS on PTYs before allocating a source.

Fixes a0880df0ccde ("pps: serial clients support")

---
Changes in v2:
- Reject PTYs before registering a PPS source, as suggested by Rodolfo.
- Drop the stable Cc.

v1: https://lore.kernel.org/r/[email protected]

 drivers/pps/clients/pps-ldisc.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/pps/clients/pps-ldisc.c +0 -0
index fa5660f3c4b7..83f4caced0c9 100644

drivers/pps/clients/pps-ldisc.c static int pps_tty_open(struct tty_struct *tty) · line 54

Quoted 9 lines
drivers/pps/clients/pps-ldisc.c +3 -0
@@ -46,6 +46,9 @@ static int pps_tty_open(struct tty_struct *tty)
 	struct pps_device *pps;
 	int ret;
 
+	if (drv->type == TTY_DRIVER_TYPE_PTY)
+		return -EINVAL;
+
 	info.owner = THIS_MODULE;
 	info.dev = NULL;
 	snprintf(info.name, PPS_MAX_NAME_LEN, "%s%d", drv->driver_name, index);
Signature · 4 lines
GNU/Linux Solutions                  e-mail: [email protected]
Linux Device Driver                          [email protected]
Embedded Systems                     phone:  +39 349 2432127
UNIX programming