Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1929510ybv; Fri, 14 Feb 2020 08:24:14 -0800 (PST) X-Google-Smtp-Source: APXvYqxgcSG66OeLeLROAEBkMaN3nAKxZPyrZJyAnSSTAXnf1UjFLe/LcH90WfHC0pNQAFRKg7x3 X-Received: by 2002:a9d:3b09:: with SMTP id z9mr2950270otb.195.1581697454465; Fri, 14 Feb 2020 08:24:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581697454; cv=none; d=google.com; s=arc-20160816; b=KFizEHZjGr99sO2glCGnjb/COKR6zrJmG22pnEiBF4+wd4slJdDv+HReNqyS3tRMnr KFfPvI49eWND57uBp8gxXv2E3mg008krlVIGY5n8dlwjTnimGv18DoOXoq0s/dNlpa0H 5tpK+f7It+ta8kRDLfmxnHiLS53peN+T3yQ+ZMZDk4HcyfIuGvKipaZX29ZioHQ0bSk5 5GCE68GBrwm+H/VtWmVccDogu8NgOr+ANGp51kl6TnNhqe0EOEs1nj8nqe/78yaSLlJk J/aqMZPPyIMvD/Lj1EWtNTjkLqGukUH9Lob9MvLEoQW4jdM+HQz5GSFDk1YCtOCIKC8L RZHw== 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=hbKB0P/mH1/FYkJZHUNoPqBD/XFRBuKViBPaCrwOzj8=; b=r2dHRnBjIwh3Hx3aLrto/lJR+dKHA5EDyfhj1CSsERxGsy4tEqOJ9nn0n/MvIewl3s cMWxhKus/Tov41KVjPZrHXEQY8rRDVgp9aaowHPTMfEQDaWC+EPwqge41oZqNy6s0E+q pRQ/nerzZ8K/wuQmKhgd4a42NJrICgJtzqW+n3qVcZo1rAWJo+y1dWzHanCZ6ptBeLVh y63IeQzhKIlfU56jN/wbak/k3b3ldZrDqvYTV35k8AWQBoOJU8HQqVvOM78mHIUYZE52 qn4a6eQs4Xbl9/X+O9X0V5XOM8F6E2Qdx8qhmTOefEDyWF0o3OY40kxB5z+TdVmz1uVG urwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=D2bCFylm; 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 a14si3365756otk.2.2020.02.14.08.24.01; Fri, 14 Feb 2020 08:24:14 -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=@kernel.org header.s=default header.b=D2bCFylm; 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 S2405637AbgBNQXW (ORCPT + 99 others); Fri, 14 Feb 2020 11:23:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:56804 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393111AbgBNQVw (ORCPT ); Fri, 14 Feb 2020 11:21:52 -0500 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 28C41246BB; Fri, 14 Feb 2020 16:21:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581697311; bh=gAkfpv4ncOrLT6/j6G/W8e8xXZzuNMbpqDoVeHHi7gw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D2bCFylmkbxkxBpj85XFoVZsMu2NvGMpx3EYDLLrIsfcvzUYW1eZer8wM7npsh3Fr 5H+UX+CpIIAOj0WW7JDU69I6jyEmeNfIo/9mmVWTardIhR++R0u+q6P+xXkpPKh6Ml pAObNBm79v9XRUAWNqb4bMWAmdJ35NMpa0dB7QgU= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Arvind Sankar , Christopher Head , Borislav Petkov , Sasha Levin Subject: [PATCH AUTOSEL 4.9 023/141] x86/sysfb: Fix check for bad VRAM size Date: Fri, 14 Feb 2020 11:19:23 -0500 Message-Id: <20200214162122.19794-23-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200214162122.19794-1-sashal@kernel.org> References: <20200214162122.19794-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review 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: Arvind Sankar [ Upstream commit dacc9092336be20b01642afe1a51720b31f60369 ] When checking whether the reported lfb_size makes sense, the height * stride result is page-aligned before seeing whether it exceeds the reported size. This doesn't work if height * stride is not an exact number of pages. For example, as reported in the kernel bugzilla below, an 800x600x32 EFI framebuffer gets skipped because of this. Move the PAGE_ALIGN to after the check vs size. Reported-by: Christopher Head Tested-by: Christopher Head Signed-off-by: Arvind Sankar Signed-off-by: Borislav Petkov Link: https://bugzilla.kernel.org/show_bug.cgi?id=206051 Link: https://lkml.kernel.org/r/20200107230410.2291947-1-nivedita@alum.mit.edu Signed-off-by: Sasha Levin --- arch/x86/kernel/sysfb_simplefb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/sysfb_simplefb.c b/arch/x86/kernel/sysfb_simplefb.c index 85195d447a922..f3215346e47fd 100644 --- a/arch/x86/kernel/sysfb_simplefb.c +++ b/arch/x86/kernel/sysfb_simplefb.c @@ -94,11 +94,11 @@ __init int create_simplefb(const struct screen_info *si, if (si->orig_video_isVGA == VIDEO_TYPE_VLFB) size <<= 16; length = mode->height * mode->stride; - length = PAGE_ALIGN(length); if (length > size) { printk(KERN_WARNING "sysfb: VRAM smaller than advertised\n"); return -EINVAL; } + length = PAGE_ALIGN(length); /* setup IORESOURCE_MEM as framebuffer memory */ memset(&res, 0, sizeof(res)); -- 2.20.1