[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1702647690-6787-1-git-send-email-quic_zijuhu@quicinc.com>
Date: Fri, 15 Dec 2023 21:41:30 +0800
From: Zijun Hu <quic_zijuhu@...cinc.com>
To: <gregkh@...uxfoundation.org>, <jirislaby@...nel.org>,
<quic_qiancai@...cinc.com>, <quic_arandive@...cinc.com>,
<quic_saipraka@...cinc.com>, <quic_vnivarth@...cinc.com>,
<quic_eberman@...cinc.com>
CC: <quic_zijuhu@...cinc.com>, <linux-serial@...r.kernel.org>,
<linux-kernel@...r.kernel.org>
Subject: [PATCH v2] tty: Add comments for tty-ldisc module loading logic
Current tty-ldisc module loading logic within tty_ldisc_get()
is prone to mislead beginner that the module is able to be loaded
by a user without capability CAP_SYS_MODULE, add comments to make
the logic easy to undertand.
Signed-off-by: Zijun Hu <quic_zijuhu@...cinc.com>
---
Changes in v2:
- Remove condition checking changes
drivers/tty/tty_ldisc.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index 3f68e213df1f..34526ffaccbc 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -150,6 +150,10 @@ static struct tty_ldisc *tty_ldisc_get(struct tty_struct *tty, int disc)
*/
ldops = get_ldops(disc);
if (IS_ERR(ldops)) {
+ /*
+ * Always request tty-ldisc module regardless of user's
+ * CAP_SYS_MODULE if autoload is enabled.
+ */
if (!capable(CAP_SYS_MODULE) && !tty_ldisc_autoload)
return ERR_PTR(-EPERM);
request_module("tty-ldisc-%d", disc);
--
The Qualcomm Innovation Center
Powered by blists - more mailing lists