提交 c32bdc5e 编写于 作者: J Johan Hovold 提交者: Zheng Zengkai

tty: moxa: fix TIOCSSERIAL permission check

stable inclusion
from stable-5.10.37
commit af5145c8efa652f0adaec4f344fd2e2b4676a1b6
bugzilla: 51868
CVE: NA

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

commit dc8c8437 upstream.

Changing the port close delay or type are privileged operations so make
sure to return -EPERM if a regular user tries to change them.

Cc: stable@vger.kernel.org
Signed-off-by: NJohan Hovold <johan@kernel.org>
Link: https://lore.kernel.org/r/20210407102334.32361-12-johan@kernel.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 a786c8c0
......@@ -2050,6 +2050,7 @@ static int moxa_set_serial_info(struct tty_struct *tty,
struct serial_struct *ss)
{
struct moxa_port *info = tty->driver_data;
unsigned int close_delay;
if (tty->index == MAX_PORTS)
return -EINVAL;
......@@ -2061,19 +2062,24 @@ static int moxa_set_serial_info(struct tty_struct *tty,
ss->baud_base != 921600)
return -EPERM;
close_delay = msecs_to_jiffies(ss->close_delay * 10);
mutex_lock(&info->port.mutex);
if (!capable(CAP_SYS_ADMIN)) {
if (((ss->flags & ~ASYNC_USR_MASK) !=
if (close_delay != info->port.close_delay ||
ss->type != info->type ||
((ss->flags & ~ASYNC_USR_MASK) !=
(info->port.flags & ~ASYNC_USR_MASK))) {
mutex_unlock(&info->port.mutex);
return -EPERM;
}
}
info->port.close_delay = msecs_to_jiffies(ss->close_delay * 10);
} else {
info->port.close_delay = close_delay;
MoxaSetFifo(info, ss->type == PORT_16550A);
MoxaSetFifo(info, ss->type == PORT_16550A);
info->type = ss->type;
info->type = ss->type;
}
mutex_unlock(&info->port.mutex);
return 0;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册