From: Greg KH <gregkh@linuxfoundation.org>
To: Zijun Hu <quic_zijuhu@quicinc.com>
Cc: jirislaby@kernel.org, linux-serial@vger.kernel.org
Subject: Re: [PATCH v1] tty: Fix a security issue related to tty-ldisc module loading
Date: Fri, 15 Dec 2023 09:43:59 +0100 [thread overview]
Message-ID: <2023121530-crept-unisexual-de76@gregkh> (raw)
In-Reply-To: <1702628933-6070-1-git-send-email-quic_zijuhu@quicinc.com>
On Fri, Dec 15, 2023 at 04:28:53PM +0800, Zijun Hu wrote:
> Function tty_ldisc_get() has a simple logical error and may cause tty-ldisc
> module to be loaded by a user without CAP_SYS_MODULE, this security issue
> is fixed by correcting the logical error.
What specific security issue are you referring to here?
> Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
> ---
> drivers/tty/tty_ldisc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
> index 3f68e213df1f..b490c0adf00f 100644
> --- a/drivers/tty/tty_ldisc.c
> +++ b/drivers/tty/tty_ldisc.c
> @@ -150,7 +150,7 @@ 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)
> + if (!capable(CAP_SYS_MODULE) || !tty_ldisc_autoload)
I'm missing something, why change this?
Remember if tty_ldisc_autoload is enabled, then any user can auto-load a
tty ldisc, permissions are not needed.
as it's confusing to read, let me break this down to see if the original
code is correct or not:
If you do NOT have CAP_SYS_MODULE AND you do NOT have
tty_ldisc_autoload enabled, then the kernel will NOT call
request_module
If you do have CAP_SYS_MODULE enabled then the kernel will call
request_module()
If you do have tty_ldisc_autoload enabled, then you can autoload
a module.
Is this not the correct functionality?
You are changing this to:
If you do NOT have CAP_SYS_MODULE enabled, then no matter what,
do NOT call request_module()
If you do NOT have tty_ldisc_autoload enabled, then no matter
what, do NOT call request_module()
Are you sure that's what you want to change this to?
What am I missing here?
confused,
greg "boolean logic is hard" k-h
next prev parent reply other threads:[~2023-12-15 8:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-15 8:28 [PATCH v1] tty: Fix a security issue related to tty-ldisc module loading Zijun Hu
2023-12-15 8:43 ` Greg KH [this message]
2023-12-15 9:32 ` quic_zijuhu
2023-12-15 10:38 ` Greg KH
2023-12-15 10:45 ` quic_zijuhu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2023121530-crept-unisexual-de76@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=quic_zijuhu@quicinc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox