Commit 5acccdd8 authored by Yi Yang's avatar Yi Yang
Browse files

tty: vt device use only n_tty ldisc

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IACT4T


CVE: CVE-2024-40966

--------------------------------

After backport mainline commit 6bd23e0c2bb6 ("tty: add the option to have
a tty reject a new ldisc") Introduced kabi breakage.
Fix kabi breakage by check whether it is vt device in tty_set_ldisc(), and
check ldisc whether it is N_TTY.

Fixes: 6bd23e0c2bb6 ("tty: add the option to have a tty reject a new ldisc")
Signed-off-by: default avatarYi Yang <yiyang13@huawei.com>
parent 5b0afd4b
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -579,11 +579,15 @@ int tty_set_ldisc(struct tty_struct *tty, int disc)
		goto out;
	}

	if (tty->ops->ldisc_ok) {
		retval = tty->ops->ldisc_ok(tty, disc);
		if (retval)
#ifdef CONFIG_VT
	/*vt device use only n_tty ldisc*/
	if (tty->ops->ioctl == vt_ioctl) {
		if (disc != N_TTY) {
			retval = -EINVAL;
			goto out;
		}
	}
#endif

	old_ldisc = tty->ldisc;

+0 −10
Original line number Diff line number Diff line
@@ -3448,15 +3448,6 @@ static void con_cleanup(struct tty_struct *tty)
	tty_port_put(&vc->port);
}

/*
 * We can't deal with anything but the N_TTY ldisc,
 * because we can sleep in our write() routine.
 */
static int con_ldisc_ok(struct tty_struct *tty, int ldisc)
{
	return ldisc == N_TTY ? 0 : -EINVAL;
}

static int default_color           = 7; /* white */
static int default_italic_color    = 2; // green (ASCII)
static int default_underline_color = 3; // cyan (ASCII)
@@ -3585,7 +3576,6 @@ static const struct tty_operations con_ops = {
	.resize = vt_resize,
	.shutdown = con_shutdown,
	.cleanup = con_cleanup,
	.ldisc_ok = con_ldisc_ok,
};

static struct cdev vc0_cdev;
+0 −1
Original line number Diff line number Diff line
@@ -256,7 +256,6 @@ struct tty_operations {
		      const unsigned char *buf, int count);
	int  (*put_char)(struct tty_struct *tty, unsigned char ch);
	void (*flush_chars)(struct tty_struct *tty);
	int (*ldisc_ok)(struct tty_struct *tty, int ldisc);
	int  (*write_room)(struct tty_struct *tty);
	int  (*chars_in_buffer)(struct tty_struct *tty);
	int  (*ioctl)(struct tty_struct *tty,