Unverified Commit 669da8f4 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!10911 Fix CVE-2024-40966

Merge Pull Request from: @ci-robot 
 
PR sync from: Yi Yang <yiyang13@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/SFJWARAMHOYKMMELOAYJUCFK3KHVWWLX/ 
Fix CVE-2024-40966 for OLK-6.6

Linus Torvalds (1):
  tty: add the option to have a tty reject a new ldisc

Yi Yang (1):
  tty: fix kabi breakage in struct tty_operations


-- 
2.25.1
 
https://gitee.com/src-openeuler/kernel/issues/IACT4T 
 
Link:https://gitee.com/openeuler/kernel/pulls/10911

 

Reviewed-by: default avatarZhang Peng <zhangpeng362@huawei.com>
Signed-off-by: default avatarZhang Peng <zhangpeng362@huawei.com>
parents bd4d9615 36a5b398
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -545,6 +545,12 @@ 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)
			goto out;
	}

	old_ldisc = tty->ldisc;

	/* Shutdown the old discipline. */
+10 −0
Original line number Diff line number Diff line
@@ -3390,6 +3390,15 @@ 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)
@@ -3509,6 +3518,7 @@ 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;
+8 −1
Original line number Diff line number Diff line
@@ -156,6 +156,13 @@ struct serial_struct;
 *
 *	Optional. Called under the @tty->termios_rwsem. May sleep.
 *
 * @ldisc_ok: ``int ()(struct tty_struct *tty, int ldisc)``
 *
 *	This routine allows the @tty driver to decide if it can deal
 *	with a particular @ldisc.
 *
 *	Optional. Called under the @tty->ldisc_sem and @tty->termios_rwsem.
 *
 * @set_ldisc: ``void ()(struct tty_struct *tty)``
 *
 *	This routine allows the @tty driver to be notified when the device's
@@ -392,7 +399,7 @@ struct tty_operations {
	void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
#endif
	int (*proc_show)(struct seq_file *m, void *driver);
	KABI_RESERVE(0)
	KABI_USE(0, int (*ldisc_ok)(struct tty_struct *tty, int ldisc))
	KABI_RESERVE(1)
} __randomize_layout;