Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3287287imu; Mon, 28 Jan 2019 02:05:15 -0800 (PST) X-Google-Smtp-Source: ALg8bN6PHeFPg5qrcgMZygO74eqcvU11HYZ9yvcBbPZhclXme63HctdYIfLEfp1MRt5yUYW0WkWS X-Received: by 2002:a63:c64f:: with SMTP id x15mr18775909pgg.16.1548669915630; Mon, 28 Jan 2019 02:05:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548669915; cv=none; d=google.com; s=arc-20160816; b=gWzBp+lfsuyX6jPgYn+3pBcBord3wSzoyY3ru/rE0Hlc6tAQB/Zg233StQxgqlm6oX tWPSq3wKi2jVipzw53HFy7AQyihZcjVFVdchR1kvO913DW7mP6+QRmR0GAKftz19//tw lxircWO/JzpfHF+TXgNWh+AxyZEMGEV031G0GUYukxSJpvuHKUbXDKWuXdBKdBTJzPab nkNBr2tWvNsn/IjpouIIBMVqYMUcJiB9xC72h46ukfN0LAHHSWRK+tXPZ4eZZpqPvXs6 tYg6+jgEd8XsqUfMyRUMj3SoEqWVMWZMTJJQ+FdocQ4eyFu1ViD7m2RQ2apGV66CcVmd JFQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=/aPQUp5E7TE46adv0zapFXT4Q+Nb7tDC8cqSFQvHJAY=; b=mVzpe741Rn5NO2hCCcr7QPdbvMg3xIowPIC8O3BtgUzoTnCqGtzrX9wZsPZsrFNzsh F4BQi1gDGQaNTb1VyIWac/RjGDxESPjVRSGEEIRiDOkeZ23oJ1LB4uEIof1S21H5g94d g9MAZCUdb4AvkYhgmKyYl0LlkOrSSoIZmfzEjPmhsZbW1RxaqS5Lbk4VYMduq49MTBQG UnRPcImVUKDRp3xrrXI/XeKcM/nWzc2dfR/XwMFTUKesJgvKvVxTNIbP9BglAqSFnNaq LKjCqwNvNAhlVxlOdl61KZOIjh45zj/LYb06Jqf7EoU2H/eZtYtXDy4xM/cvXeFLqGBz KDPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@posteo.de header.s=2017 header.b=hxyfj+YD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g5si17760023plo.108.2019.01.28.02.05.00; Mon, 28 Jan 2019 02:05:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@posteo.de header.s=2017 header.b=hxyfj+YD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726853AbfA1KEn (ORCPT + 99 others); Mon, 28 Jan 2019 05:04:43 -0500 Received: from mout02.posteo.de ([185.67.36.66]:57467 "EHLO mout02.posteo.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726832AbfA1KEm (ORCPT ); Mon, 28 Jan 2019 05:04:42 -0500 Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id A509C2400FC for ; Mon, 28 Jan 2019 11:04:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1548669880; bh=qZmb/C+xRGeTA0pyxMfIlRobHToBGwXPBkxzlgge6M4=; h=From:To:Cc:Subject:Date:From; b=hxyfj+YD1wFDf0icZGQUC0oW9zbqtFTqvZnBgm42sdDMHkb4ECl4v2PgiTfjq8a2i /nID4rxbH/21jNHFVwss/IkiIsEda3rxybYyCNuuAe5+SkNsVWDSojpepUIgbFC85A cxUvQRrR7EwF8NEmdQE0WsPrX/KSmyVXvMhymyb17Jf8cqKiFBoT4cqDzkuzdUjtu9 kZmw8yhWP2tP5KRQzvuOxjVmdo3yMgoM7eTkCNe4oPXPnxIaXbO3DMurm2cJeESmBi peuQi8fTAXYwOT++2epxlzZwyi5JGfxsSWNjGre2aH/WCAW98xJu8bvG8yUuc8+1Ba 1F+WxYRCfnKzg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 43p4x2674wz9rxf; Mon, 28 Jan 2019 11:04:38 +0100 (CET) From: Martin Kepplinger To: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, b.zolnierkie@samsung.com Cc: daniel.vetter@ffwll.ch, manfred.schlaegl@ginzinger.com, linux-kernel@vger.kernel.org, Martin Kepplinger Subject: [PATCH] fbdev: fbmem: fix memory access if logo is bigger than the screen Date: Mon, 28 Jan 2019 11:04:35 +0100 Message-Id: <20190128100435.759-1-martink@posteo.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Manfred Schlaegl There is no clipping on the x or y axis for logos larger that the framebuffer size. Therefore: a logo bigger than screen size leads to invalid memory access: [ 1.254664] Backtrace: [ 1.254728] [] (cfb_imageblit) from [] (fb_show_logo+0x620/0x684) [ 1.254763] r10:00000003 r9:00027fd8 r8:c6a40000 r7:c6a36e50 r6:00000000 r5:c06b81e4 [ 1.254774] r4:c6a3e800 [ 1.254810] [] (fb_show_logo) from [] (fbcon_switch+0x3fc/0x46c) [ 1.254842] r10:c6a3e824 r9:c6a3e800 r8:00000000 r7:c6a0c000 r6:c070b014 r5:c6a3e800 [ 1.254852] r4:c6808c00 [ 1.254889] [] (fbcon_switch) from [] (redraw_screen+0xf0/0x1e8) [ 1.254918] r10:00000000 r9:00000000 r8:00000000 r7:00000000 r6:c070d5a0 r5:00000080 [ 1.254928] r4:c6808c00 [ 1.254961] [] (redraw_screen) from [] (do_bind_con_driver+0x194/0x2e4) [ 1.254991] r9:00000000 r8:00000000 r7:00000014 r6:c070d5a0 r5:c070d5a0 r4:c070d5a0 So prevent displaying a logo bigger than screen size and avoid invalid memory access. Signed-off-by: Manfred Schlaegl Signed-off-by: Martin Kepplinger --- drivers/video/fbdev/core/fbmem.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index cb43a2258c51..4721491e6c8c 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -431,6 +431,9 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image, { unsigned int x; + if (image->width > info->var.xres || image->height > info->var.yres) + return; + if (rotate == FB_ROTATE_UR) { for (x = 0; x < num && image->dx + image->width <= info->var.xres; -- 2.20.1