Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5584115img; Wed, 27 Mar 2019 11:09:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqz+kM4CcsPzLMlIPw10IlcdPzalh4BKGZBov3h+3PFrIpe131qFM69c8ZMykjXx50pJRyNJ X-Received: by 2002:a62:19c3:: with SMTP id 186mr35298270pfz.172.1553710142212; Wed, 27 Mar 2019 11:09:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553710142; cv=none; d=google.com; s=arc-20160816; b=I3ZrHShGBmv1LjvjFLKbeboUivYqsc7O/sgsDJoskGlWb8ZiADPNhzQcsokxbXF/vu xrupYJR1FQOlZd8cEaDKFmwtZ/r5WLnXgBd+F2Hkjt5fY18ETUr7rHgqH2QgWgtBkLay KWtatFUEoZxQvXNKSQwQC6moch6EsIdCso2iIEIKRR/1/KL9QOjpjvXkO1aYx/nNHA8/ Cxhenvoba0BKpkLpKgoSwwDwbJILM0qleby6Es2WxX51OExGfBXnfjak9sJKHa8LTEGp /ztu88itcl7xthi1SjXAGPErLZdCg0iXwIkKxFswD3xEdexVTXVm9hZ4ChlyY93dq999 mGGQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bBJ+okINGE5Sswxg3d6WsM+CAUMK3bja+VqLN8MY/do=; b=FBoggP/sGHq5Zy+sVLa5UEJqdqnAFZIex4eCAL45IlgqAk+k4p3apWv+rY5nm0l9dX 3e0ofcM6+tjUZLIOJzoF6KrcWNF6u8c93ktohgKv/leCJTUc80fO7a5LIFGpqOFoIt5L aGGoBMRSPI1OMrmZXoQscJmq5BiWAWQkG0N1JLTOwRsxhNtHdDssPyLQXd8u9unytrhQ RnClQbMaM89BW/GOjAfewF095zL8smycjmVXgoADUhtvbyB5DYUtbJp3s1pjvkGES9Hv CRItHHT8BLv8kHUbemgdtHTSIdlNbjBGxidAEAa6Ry+pAz2KNGGIxppj5rHNGtGqus5M RiIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SfUCWnYz; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o90si1140451pfi.161.2019.03.27.11.08.46; Wed, 27 Mar 2019 11:09:02 -0700 (PDT) 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=@kernel.org header.s=default header.b=SfUCWnYz; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388158AbfC0SHU (ORCPT + 99 others); Wed, 27 Mar 2019 14:07:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:49122 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388147AbfC0SHT (ORCPT ); Wed, 27 Mar 2019 14:07:19 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E36B52075C; Wed, 27 Mar 2019 18:07:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553710038; bh=xCL6z6qBX8ib2Z0Foj+e6nTdaaCAXy004wAiHVt12g4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SfUCWnYzYQvhNKbdQT7HiUUEFmAwCSPIhXoLSd8FSx5ILHwCex/quRUQzK6t9t2qh R47yhBnECcn0F9S96sC2fbOFClA8NoVFKTfqEb2ugArNMNfp2sMBWaTjwZirnGrM0e 6yIAO4V7uMFwb4vnblkxepEVjetxrq4ZTJQnYAcQ= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Manfred Schlaegl , Martin Kepplinger , Daniel Vetter , Bartlomiej Zolnierkiewicz , Sasha Levin , dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.0 168/262] fbdev: fbmem: fix memory access if logo is bigger than the screen Date: Wed, 27 Mar 2019 14:00:23 -0400 Message-Id: <20190327180158.10245-168-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore 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 [ Upstream commit a5399db139cb3ad9b8502d8b1bd02da9ce0b9df0 ] 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 Cc: Daniel Vetter Signed-off-by: Bartlomiej Zolnierkiewicz Signed-off-by: Sasha Levin --- 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.19.1