linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: linux-fbdev@vger.kernel.org
Subject: [bug report] out of bounds read parsing vmode commandline option
Date: Wed, 04 Oct 2017 12:50:38 +0000	[thread overview]
Message-ID: <20171004125038.gkzaemlefrpfa2m2@mwanda> (raw)

This bug predates git but it looks like it might be simple to fix if the
right person looked at the code.

	drivers/video/fbdev/controlfb.c:560 control_setup()
	error: buffer overflow 'control_mac_modes' 20 <= 21

drivers/video/fbdev/controlfb.c
   549  static void __init control_setup(char *options)
   550  {
   551          char *this_opt;
   552  
   553          if (!options || !*options)
   554                  return;
   555  
   556          while ((this_opt = strsep(&options, ",")) != NULL) {
   557                  if (!strncmp(this_opt, "vmode:", 6)) {
   558                          int vmode = simple_strtoul(this_opt+6, NULL, 0);
                                    ^^^^^
We get vmode from the command line.

   559                          if (vmode > 0 && vmode <= VMODE_MAX &&
                                                          ^^^^^^^^^
We check that it's <= 22.

   560                              control_mac_modes[vmode - 1].m[1] >= 0)
                                    ^^^^^^^^^^^^^^^^^
But the problem is that control_mac_modes[] only has 20 elements so the
highest valid index is 19.  vmode - 1 can be up to 21.

   561                                  default_vmode = vmode;
   562                  } else if (!strncmp(this_opt, "cmode:", 6)) {
   563                          int depth = simple_strtoul(this_opt+6, NULL, 0);
   564                          switch (depth) {
   565                           case CMODE_8:
   566                           case CMODE_16:
   567                           case CMODE_32:
   568                                  default_cmode = depth;
   569                                  break;
   570                           case 8:
   571                                  default_cmode = CMODE_8;
   572                                  break;
   573                           case 15:
   574                           case 16:
   575                                  default_cmode = CMODE_16;
   576                                  break;
   577                           case 24:
   578                           case 32:
   579                                  default_cmode = CMODE_32;
   580                                  break;
   581                          }
   582                  }
   583          }
   584  }

regards,
dan carpenter

             reply	other threads:[~2017-10-04 12:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-04 12:50 Dan Carpenter [this message]
2017-10-04 16:42 ` [bug report] out of bounds read parsing vmode commandline option Geert Uytterhoeven
     [not found]   ` <CGME20171017133722epcas2p1361446d57dfad4ef9a9bc2a0a247e70a@epcas2p1.samsung.com>
2017-10-17 13:37     ` Bartlomiej Zolnierkiewicz

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=20171004125038.gkzaemlefrpfa2m2@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=linux-fbdev@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;
as well as URLs for NNTP newsgroup(s).