All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Anthony Canino <anthony.canino1@gmail.com>
Cc: linux-serial@vger.kernel.org
Subject: Re: Possible bug in drivers/tty/vt/vt.c
Date: Tue, 23 Jun 2020 13:51:48 +0200	[thread overview]
Message-ID: <20200623115148.GC1963415@kroah.com> (raw)
In-Reply-To: <CA+dbEpt3YmDE7Q_BBhZZw9CfrUJfrhfR16XVoevXSqi=kOQjJg@mail.gmail.com>

On Tue, Jun 23, 2020 at 05:27:33AM -0400, Anthony Canino wrote:
> Hi all,
> 
> I hope this is the right place to ask about a potential bug in the TTY
> that I may have found in the TTY layer in the linux kernel. I have
> failed a bug report
> (https://bugzilla.kernel.org/show_bug.cgi?id=208293) but wanted to
> email the list for the TTY layer directly. In summary, in the con_init
> function of drivers/tty/vt/vt.c, I think this code is possibly buggy
> is kzalloc fails to allocate:
> 
>   3391   for (currcons = 0; currcons < MIN_NR_CONSOLES; currcons++) {
>   3392     vc_cons[currcons].d = vc = kzalloc(sizeof(struct vc_data),
> GFP_NOWAIT);
>   3393     INIT_WORK(&vc_cons[currcons].SAK_work, vc_SAK);
>   3394     tty_port_init(&vc->port);
>   3395     visual_init(vc, currcons, 1);
>   3396     vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_NOWAIT);
>   3397     vc_init(vc, vc->vc_rows, vc->vc_cols,
>   3398       currcons || !vc->vc_sw->con_save_screen);
>   3399   }
>   3400   currcons = fg_console = 0;
>   3401   master_display_fg = vc = vc_cons[currcons].d;
>   3402   set_origin(vc);
> 
> If kzalloc returns null on 3396, I think during set_origin(vc) it is
> possible vc_screenbuf will be dereferenced. I'd be happy to discuss
> further if needed.

Yes, horrible and bad things will happen if kzalloc fails at that point
in time.

Luckily, it is impossible for that to happen, so we really do not need
to worry about it at all.  This comes up every other year or so, and the
gyrations that people have gone through to try to fix this up, for
something that is impossible to ever hit, always end up breaking the
codebase or doing other horrible things.

In short, don't worry about it, unless you can show me how that can ever
happen in a normal (i.e. not instrumented) system?

thanks,

greg k-h

  reply	other threads:[~2020-06-23 11:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CA+dbEpsJs8AgcpjU_-Vwh60BRL4Eq21L1=3sDNJRGHr2acLWLg@mail.gmail.com>
2020-06-23  9:27 ` Possible bug in drivers/tty/vt/vt.c Anthony Canino
2020-06-23 11:51   ` Greg KH [this message]
2020-06-25 14:44     ` Anthony Canino
2020-06-25 14:59       ` Greg KH

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=20200623115148.GC1963415@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=anthony.canino1@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.