Linux Serial subsystem development
 help / color / mirror / Atom feed
* [PATCH v1] tty: Make tty-ldisc module loading logic easy to understand
@ 2023-12-15 11:37 Zijun Hu
  2023-12-15 12:17 ` Greg KH
  2023-12-15 13:41 ` [PATCH v2] tty: Add comments for tty-ldisc module loading logic Zijun Hu
  0 siblings, 2 replies; 10+ messages in thread
From: Zijun Hu @ 2023-12-15 11:37 UTC (permalink / raw)
  To: gregkh, jirislaby; +Cc: quic_zijuhu, linux-serial

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 and
optimize the logic to make it easy to undertand.

Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
 drivers/tty/tty_ldisc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
index 3f68e213df1f..faa125f32110 100644
--- a/drivers/tty/tty_ldisc.c
+++ b/drivers/tty/tty_ldisc.c
@@ -150,7 +150,11 @@ static struct tty_ldisc *tty_ldisc_get(struct tty_struct *tty, int disc)
 	 */
 	ldops = get_ldops(disc);
 	if (IS_ERR(ldops)) {
-		if (!capable(CAP_SYS_MODULE) && !tty_ldisc_autoload)
+		/*
+		 * Always request tty-ldisc module regardless of user's
+		 * CAP_SYS_MODULE if autoload is enabled.
+		 */
+		if (!tty_ldisc_autoload && !capable(CAP_SYS_MODULE))
 			return ERR_PTR(-EPERM);
 		request_module("tty-ldisc-%d", disc);
 		ldops = get_ldops(disc);
-- 
The Qualcomm Innovation Center


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-12-16  4:04 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-15 11:37 [PATCH v1] tty: Make tty-ldisc module loading logic easy to understand Zijun Hu
2023-12-15 12:17 ` Greg KH
2023-12-15 13:24   ` quic_zijuhu
2023-12-15 13:41 ` [PATCH v2] tty: Add comments for tty-ldisc module loading logic Zijun Hu
2023-12-15 14:12   ` Greg KH
2023-12-15 14:58     ` quic_zijuhu
2023-12-15 14:19   ` Vijaya Krishna Nivarthi
2023-12-15 17:26     ` Jiri Slaby
2023-12-15 17:51       ` Elliot Berman
2023-12-16  4:04         ` quic_zijuhu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox