Linux Framebuffer Layer development
 help / color / mirror / Atom feed
From: James Bates <james.h.bates@gmail.com>
To: Peter Jones <pjones@redhat.com>,
	Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>,
	Tomi Valkeinen <tomi.valkeinen@ti.com>,
	linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] efifb: prevent null dereferences by removing unused array  indices from dmi_list
Date: Tue, 06 Aug 2013 23:15:29 +0000	[thread overview]
Message-ID: <C9C6655E-4974-4C04-8CEE-CA16563F4CC5@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2368 bytes --]

Hi all,

The dmi_list array is initialized using gnu designated initializers, and therefore
contains fewer explicitly defined entries as there are elements in it. This
is because the enum above with M_blabla constants contains more items than the designated
initializer. Those elements not explicitly initialized are implicitly set to 0.

Now efifb_setup(), L.322 & L.323, loops through all these array elements, and performs
a strcmp o a field (optname) in each item. For non explicitly initialized elements this
will be a null pointer:

                        for (i = 0; i < M_UNKNOWN; i++) {
                                if (!strcmp(this_opt, dmi_list[i].optname) &&

On my macbook6,1 the predefined values are for some reason incorrect, and most parameters
are preset correctly by my efi bootloader (elilo). but stride/line_length is not detected
correctly and so I wish to set it explicitly using a "video=efifb:stride:2048" command-line
argument. Because of the above null dereference, an exception (presumably) occurs before
the parsing code (L.333) is ever reached. I say presumably since the mac hangs on boot
without a console, and I can therefore not see any output.

By removing the unused values from the enum, and thus preventing implicitly initialized items
in the dmi_list array, the null dereference does not occur, my customer command-line arg is
parsed correctly, and my console displays correctly.

Signed-off-by: James Bates <james.h.bates@gmail.com>
---
 drivers/video/efifb.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/video/efifb.c b/drivers/video/efifb.c
index 50fe668..52d1d88 100644
--- a/drivers/video/efifb.c
+++ b/drivers/video/efifb.c
@@ -50,12 +50,9 @@ enum {
        M_MINI_3_1,     /* Mac Mini, 3,1th gen */
        M_MINI_4_1,     /* Mac Mini, 4,1th gen */
        M_MB,           /* MacBook */
-       M_MB_2,         /* MacBook, 2nd rev. */
-       M_MB_3,         /* MacBook, 3rd rev. */
        M_MB_5_1,       /* MacBook, 5th rev. */
        M_MB_6_1,       /* MacBook, 6th rev. */
        M_MB_7_1,       /* MacBook, 7th rev. */
-       M_MB_SR,        /* MacBook, 2nd gen, (Santa Rosa) */
        M_MBA,          /* MacBook Air */
        M_MBA_3,        /* Macbook Air, 3rd rev */
        M_MBP,          /* MacBook Pro */
--
1.7.12.4 (Apple Git-37)


[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 4151 bytes --]

             reply	other threads:[~2013-08-06 23:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-06 23:15 James Bates [this message]
2013-08-16 13:37 ` [PATCH] efifb: prevent null dereferences by removing unused array indices from dmi_list David Herrmann
     [not found]   ` <1376684395.6529.5.camel@hermes>
2013-08-16 20:36     ` [PATCH v2] " David Herrmann
2013-09-05  8:12     ` Tomi Valkeinen

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=C9C6655E-4974-4C04-8CEE-CA16563F4CC5@gmail.com \
    --to=james.h.bates@gmail.com \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pjones@redhat.com \
    --cc=plagnioj@jcrosoft.com \
    --cc=tomi.valkeinen@ti.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