Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5614069img; Wed, 27 Mar 2019 11:44:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqycN58KFN8fA1xrI1GAtxLGzTHHT08qw7JENifxToFYnFiTsJIw1IDxU6ys43FIYQFJ1zt4 X-Received: by 2002:aa7:90c7:: with SMTP id k7mr36461601pfk.186.1553712258817; Wed, 27 Mar 2019 11:44:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553712258; cv=none; d=google.com; s=arc-20160816; b=hokiPuhcQGxGlLNHLxK7XfvWYquNr1Gcxw4wjjDhKVfwBHDCr4KRVe3bFdKsP6cSGg RjxJ9kvISZElK1CtFbBf2xmfWIQYdtbJwgKyzxOi3uckdW9K0G5LNKMmb2k6q0QFgiCG 7pGHh+h2LEb7xvOwP2EI/UMQaU021+WXSqmFeeapnwzZ8Po2158FozzG7mKJ7FcH9OxY Yu7316sdJIhobdcUtNqH/LgOK0PG36DP6deAErjhgZQlmq+CuuJzeJ3M1VECXEVXw7pc NWrgFWRaBBqR+gDFha6FEMO67rVbw7NEhAo8q0HuEPfIGmuSAEKHXO2Ca5G4Qdkw/PZ5 6kJw== 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=T5OMeyF3l7fBheMQoqb4GvTvO8YAB0oD0d1pQA0iOOo=; b=xBm+S9LPt7lbYiaKsrDroQ5Rucdmcz1SvM6cniEEj9hCfwdh15g6Ifrz65ARNDrNWi B/ZhOtJXaPmJo5ZRDaLV8/jNeOFn7hvlFQfUaRnlljRnuyIHFCX6tcNx1SOeNE7z9fQe rLyEgHVoghEtlkONp3tp2VDu/549OXX6pMtxSWOmg0ovBlU6uyBLzixDoh8QKmc8qz23 7X2tr7jZa3bC3T7/7mbUjKdDJuFXA7gs2FNVcNWo2645iyonCSQMLULXp3mJrk7+BIg5 +IsqbHsc7qCNtA2Q94Gfi4QwKZdAhvWKnW3VsTzrbJHAvSfr6BTHf73qGN6c/qZ2pLM5 F9Ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aq7374Tp; 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 m22si18695485pgv.562.2019.03.27.11.44.03; Wed, 27 Mar 2019 11:44:18 -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=aq7374Tp; 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 S2403861AbfC0SW1 (ORCPT + 99 others); Wed, 27 Mar 2019 14:22:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:40530 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391040AbfC0SWZ (ORCPT ); Wed, 27 Mar 2019 14:22:25 -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 936F62082F; Wed, 27 Mar 2019 18:22:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553710944; bh=ODU6s4np1xr8i/6AARpLJgcTUk44qILuGUaoq5t38wY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aq7374TpUJWfNqg5UvbUKK3C6h1SIJfBQavcgWZQiNK7gKs76Wg+Pf/b6V59ypusv h4JZyzfVyoLF5661Q+RWAL7Z11C8PeR08UW7Wsjl20qBN0QZtOmXb7IbIN9ZJThZZ4 9aLTnC0IElXbyLWE53bOU3tY/3I3n5+24SvFaoZU= 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 4.9 57/87] fbdev: fbmem: fix memory access if logo is bigger than the screen Date: Wed, 27 Mar 2019 14:20:10 -0400 Message-Id: <20190327182040.17444-57-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327182040.17444-1-sashal@kernel.org> References: <20190327182040.17444-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 a1d93151c059..c928190666ac 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -425,6 +425,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