From patchwork Fri Apr 17 09:48:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manfred Schlaegl X-Patchwork-Id: 6229871 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 506709F1C4 for ; Fri, 17 Apr 2015 09:48:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7AE0620381 for ; Fri, 17 Apr 2015 09:48:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8C33C2037D for ; Fri, 17 Apr 2015 09:48:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752933AbbDQJsI (ORCPT ); Fri, 17 Apr 2015 05:48:08 -0400 Received: from mout.gmx.net ([212.227.17.20]:52779 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752391AbbDQJsH (ORCPT ); Fri, 17 Apr 2015 05:48:07 -0400 Received: from [10.10.1.106] ([90.146.13.66]) by mail.gmx.com (mrgmx102) with ESMTPSA (Nemesis) id 0La2Xx-1ZCv7p1kGT-00lnGl; Fri, 17 Apr 2015 11:48:04 +0200 Message-ID: <5530D6D2.8080103@gmx.at> Date: Fri, 17 Apr 2015 11:48:02 +0200 From: Manfred Schlaegl User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Icedove/31.6.0 MIME-Version: 1.0 To: Jean-Christophe Plagniol-Villard , Tomi Valkeinen CC: Manfred Schlaegl , linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, Manfred Schlaegl Subject: [PATCH] video/logo: fix use logo after free prevention X-Provags-ID: V03:K0:zrz5uj6FjyNIJZSlpVkWmYbTG6qMwJUrHtg7jpvjM9bGKwBqQyy IyHZcrBD/9z/rnWGBUlAluesr2bqDL6CPuQ1RHdbd+7fmjF8T/a/mJcMbW+3apDRCYhBFmf qHrCoG/ykE1LU0MaXHYXdTDJDw8hzx8whwBPIVsJEhVW8WRvuUV984ZCQY7MFhkTEe84sHS b+0sVgREhPCTPf9IWJFvw== X-UI-Out-Filterresults: notjunk:1; Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP After 92b004d1aa9f367c372511ca0330f58216b25703 the logos disappeared on Freescale i.MX53 and i.MX6 SoC's (detected on linux-3.12.37). This happens because the fb_find_logo function is validly called (initdata still not freed) AFTER newly introduced latecall fb_logo_late_init. Instead of stetting a logos_freed flag somewhere in lateinit, this patch uses system_state==SYSTEM_BOOTING as indication for valid initdata. Signed-off-by: Manfred Schlaegl --- drivers/video/logo/logo.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/drivers/video/logo/logo.c b/drivers/video/logo/logo.c index 10fbfd8..ad37561 100644 --- a/drivers/video/logo/logo.c +++ b/drivers/video/logo/logo.c @@ -21,21 +21,6 @@ static bool nologo; module_param(nologo, bool, 0); MODULE_PARM_DESC(nologo, "Disables startup logo"); -/* - * Logos are located in the initdata, and will be freed in kernel_init. - * Use late_init to mark the logos as freed to prevent any further use. - */ - -static bool logos_freed; - -static int __init fb_logo_late_init(void) -{ - logos_freed = true; - return 0; -} - -late_initcall(fb_logo_late_init); - /* logo's are marked __initdata. Use __init_refok to tell * modpost that it is intended that this function uses data * marked __initdata. @@ -44,7 +29,11 @@ const struct linux_logo * __init_refok fb_find_logo(int depth) { const struct linux_logo *logo = NULL; - if (nologo || logos_freed) + /* + * Logos are located in the initdata, and will be freed in kernel_init. + * Use system_state to determine, if initdata is still useable. + */ + if (nologo || system_state != SYSTEM_BOOTING) return NULL; if (depth >= 1) {