mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexey Dobriyan <adobriyan@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jirislaby@kernel.org>,
	linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: stack leak via uart_get_info() ?
Date: Thu, 5 Oct 2023 21:44:44 +0300	[thread overview]
Message-ID: <4bb69834-405c-40da-ac3d-f5b29d2eecf0@p183> (raw)
In-Reply-To: <2023100517-washer-why-7513@gregkh>

On Thu, Oct 05, 2023 at 07:55:34PM +0200, Greg Kroah-Hartman wrote:
> On Thu, Oct 05, 2023 at 07:34:21PM +0300, Alexey Dobriyan wrote:
> > If this check ever triggers
> > 
> > 	static int uart_get_info(struct tty_port *port, struct serial_struct *retinfo)
> > 	{
> > 
> > 		uport = uart_port_check(state);
> > 	        if (!uport)
> > 	                goto out;
> > 
> > then all those sysfs users will print stack contents to userspace.
> > 
> > Can it trigger while sysfs read is executing?
> 
> I don't think it can ever fail, we don't even check the result in other
> places, so it should all be fine.
> 
> > Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
> > ---
> > 
> > --- a/drivers/tty/serial/serial_core.c
> > +++ b/drivers/tty/serial/serial_core.c
> > @@ -775,6 +775,8 @@ static int uart_get_info(struct tty_port *port, struct serial_struct *retinfo)
> >  	struct uart_port *uport;
> >  	int ret = -ENODEV;
> >  
> > +	*retinfo = (struct serial_struct){};
> 
> This is good (although I hate the implied memcpy), a real memset would
> be best to ensure that any holes are also filled.  Want to do that, or
> want me to?

I don't mind memset(), but "struct serial_struct" structure has kernel
pointers:

	unsigned char* iomem_base;

so it is not shipped to userspace, so padding isn't an issue.

      reply	other threads:[~2023-10-05 18:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-05 16:34 Alexey Dobriyan
2023-10-05 17:55 ` Greg Kroah-Hartman
2023-10-05 18:44   ` Alexey Dobriyan [this message]

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=4bb69834-405c-40da-ac3d-f5b29d2eecf0@p183 \
    --to=adobriyan@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®