From: Ilija Hadzic Subject: drm_fb_helper question Date: Tue, 18 Oct 2011 09:25:33 -0500 (CDT) Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: Received: from ihemail4.lucent.com (ihemail4.lucent.com [135.245.0.39]) by gabe.freedesktop.org (Postfix) with ESMTP id 8BF459E907 for ; Tue, 18 Oct 2011 07:25:40 -0700 (PDT) Received: from usnavsmail1.ndc.alcatel-lucent.com (usnavsmail1.ndc.alcatel-lucent.com [135.3.39.9]) by ihemail4.lucent.com (8.13.8/IER-o) with ESMTP id p9IEPXCi021280 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 18 Oct 2011 09:25:33 -0500 (CDT) Received: from umail.lucent.com (umail-ce2.ndc.lucent.com [135.3.40.63]) by usnavsmail1.ndc.alcatel-lucent.com (8.14.3/8.14.3/GMO) with ESMTP id p9IEPX2m007012 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Tue, 18 Oct 2011 09:25:33 -0500 Received: from umail-ce2 (umail-ce2 [135.3.40.63]) by umail.lucent.com (8.13.8/TPES) with ESMTP id p9IEPX87018717 for ; Tue, 18 Oct 2011 09:25:33 -0500 (CDT) List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org While hacking something else, I stumbled upon two potential issues in drm_fb_helper. Could someone who knows this better than me enlighten whether the problem is realistic or whether I am overseeing something ? If the problem is real (or a potential trouble waiting to happen), I have cut some patches that address this and I can send them. First, in drm_fb_helper_init, the size of crtc_info allocated is for crtc_count entries, the loop that populates crtc_info at the end of the _init function scans the whole list of connectors. So if GPU specifies crtc_count that is smaller than the total number of CRTCs, the loop will overrun the allocated space and corrupt memory. Although no GPU driver in current tree does that, I could imagine a GPU using the smaller number for crtc_count if it does not want some CRTCs used for fbcon. Second (similar in nature) problem is the loop at the end of drm_setup_crtcs function that populates modeset->connectors array. The size of that array is fb_helper->max_conn_count (which is specified by the GPU driver and can be anything), while the the loop runs for fb_helper->connector_count iterations which can include all available connectors (per drm_fb_helper_single_add_all_connectors). So at least in theory that loop can overrun the modset->connectors array and corrupt memory too. Both cases may be theoretical at this time, but they look like a trouble waiting to happen (e.g., future GPUs may have a mix of CRTCs and connectors that could evoke the described error). If those who know better, agree with my analysis, I'll be glad to send some patchwork. thanks, Ilija