Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2925959rwb; Mon, 15 Aug 2022 14:11:04 -0700 (PDT) X-Google-Smtp-Source: AA6agR4yRTKJMCMew2YV6K+BiewwC6vYjqdRnNePl8scBGbg1+4V0prFbdKCidJI4uloRilrV4hD X-Received: by 2002:a05:6402:1d55:b0:440:7104:240c with SMTP id dz21-20020a0564021d5500b004407104240cmr16269411edb.207.1660597863830; Mon, 15 Aug 2022 14:11:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660597863; cv=none; d=google.com; s=arc-20160816; b=PCxCzyujXTPwSfT1FYB4UExiolYJJWU9GLhFQpbWXgUYJX+CRNjtJUIHlr6TNG+jM7 GJNlsKjm6SMY/s3vwz07EBiF2z+OMPWQ5lQmIbmleEXBqtPxm7DpqA4KmSOtZgAyLDcU RjNRtD0uks9F4gK9AvX6bpyVknFHgYFrl8gdtjC9XJlu/METmsKrss6YpX2i4pBQCqg/ LCAR6GKNnP63LvMnoCx0CbaySvD8KSa5sXP80m+zR6MVTWgv3pBAEG98xSdRi027zOc0 4KdUF3ovuc/OVVjx/F5zIB9bEbJDSbW5AMy+0iL7h32N+Fd2dGgymyjQKAg4Grc3ZbiU nkqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dqc2b6oJKhgQIpg6X9XAZmW7YsfEJx1Nl+7Sp2Z6uCQ=; b=DjnGvFaH/hwrEEAolgsPSM6SGUaryNO/yx77sXLuqZcdY90Usu9kcW2mHbtlgeTgM0 HCnSTRNgMFWn0ZpKWcTfXPlE2mbeS6iy/s5KmbmgwE4k+PtqJbxIUk6ZCTFi7ptV+vec XMcVpJdtbJSGOShWGRJd44esLunbPT8PBkZoA7dQiZxOxgYaad1Kgoyi7tRXUVx7eNtq dMqX4ioCDH5bKASKqdS/ahEDl1Iu428uzv9qWQt1yYT4asFLhv0dBVhHUOZHCrbA2Wic 6OBqA5j2YnTag0SnqUOHCJDczRhzfr5Ov3Royvc1fNPnZHFWo4eE7g3PeFJT0zO/MQ4n 0TvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="O3+p/mwW"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ne18-20020a1709077b9200b0073086ecd585si8815778ejc.625.2022.08.15.14.10.38; Mon, 15 Aug 2022 14:11:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="O3+p/mwW"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345264AbiHOTtJ (ORCPT + 99 others); Mon, 15 Aug 2022 15:49:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345577AbiHOTrM (ORCPT ); Mon, 15 Aug 2022 15:47:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1B8170E6F; Mon, 15 Aug 2022 11:49:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 26174611EC; Mon, 15 Aug 2022 18:49:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A122C433C1; Mon, 15 Aug 2022 18:49:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660589371; bh=iNolcQLsPmYHRMyNxtH30MXdTPCUZ/VVHnCYzYOKTLg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O3+p/mwWVJiDJYbaxy9Espib/Ey2xhRHoxP1PZrgZJ7LrfWw6ds0JmoDKX994VnCZ oJg3lNYYejoEHNMFcQaRpnyVOuM/FtH9jagNgineZuDCmXY5sZ5RyxBA9e15Dq9qqm Mt6jxIzb+dYlYOMrLqxFLKbdKIfYphCFF73H7iXI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zheyu Ma , Helge Deller , Sasha Levin Subject: [PATCH 5.15 666/779] video: fbdev: vt8623fb: Check the size of screen before memset_io() Date: Mon, 15 Aug 2022 20:05:10 +0200 Message-Id: <20220815180405.808687784@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zheyu Ma [ Upstream commit ec0754c60217248fa77cc9005d66b2b55200ac06 ] In the function vt8623fb_set_par(), the value of 'screen_size' is calculated by the user input. If the user provides the improper value, the value of 'screen_size' may larger than 'info->screen_size', which may cause the following bug: [ 583.339036] BUG: unable to handle page fault for address: ffffc90005000000 [ 583.339049] #PF: supervisor write access in kernel mode [ 583.339052] #PF: error_code(0x0002) - not-present page [ 583.339074] RIP: 0010:memset_orig+0x33/0xb0 [ 583.339110] Call Trace: [ 583.339118] vt8623fb_set_par+0x11cd/0x21e0 [ 583.339146] fb_set_var+0x604/0xeb0 [ 583.339181] do_fb_ioctl+0x234/0x670 [ 583.339209] fb_ioctl+0xdd/0x130 Fix the this by checking the value of 'screen_size' before memset_io(). Fixes: 558b7bd86c32 ("vt8623fb: new framebuffer driver for VIA VT8623") Signed-off-by: Zheyu Ma Signed-off-by: Helge Deller Signed-off-by: Sasha Levin --- drivers/video/fbdev/vt8623fb.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/video/fbdev/vt8623fb.c b/drivers/video/fbdev/vt8623fb.c index 7a959e5ba90b..c274ec5e965c 100644 --- a/drivers/video/fbdev/vt8623fb.c +++ b/drivers/video/fbdev/vt8623fb.c @@ -504,6 +504,8 @@ static int vt8623fb_set_par(struct fb_info *info) (info->var.vmode & FB_VMODE_DOUBLE) ? 2 : 1, 1, 1, info->node); + if (screen_size > info->screen_size) + screen_size = info->screen_size; memset_io(info->screen_base, 0x00, screen_size); /* Device and screen back on */ -- 2.35.1