Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3030233rwb; Mon, 15 Aug 2022 16:29:17 -0700 (PDT) X-Google-Smtp-Source: AA6agR53IEhu+AdLvGT7Y1X0cSeDT6RtxtPixGsNK2OhW2er4+YbjIxyF1lIhzudvo/ag5SkGJLL X-Received: by 2002:a17:907:1688:b0:730:b3ae:347 with SMTP id hc8-20020a170907168800b00730b3ae0347mr11834408ejc.756.1660606156840; Mon, 15 Aug 2022 16:29:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660606156; cv=none; d=google.com; s=arc-20160816; b=O0xbMCMt2gnzEVePjxLHwE7cFqPSZdEBfyH1BlxO13/w0Jtr5AHtWAThGYJ5kHArp1 w0i0JX1rMvLen6hFIQlEAmHDXUZeGdnAK+QscPNHLU552Jpu+Apg4r8uCDnoru0aOunm HfGpfWcyPSA0tRkDaMyKnsETwudBGBHUMK3uZFlVrChG28vthZbokyxcuZ0AgOHSf/6B A8culr50g4U5UTPqPVtzradwabHngd/dmslyI4QqMUeRv5mP6AjPy5I0r0n7xHg+0ryz Yvp/nUxVERT4VqSRmLro3wxuUetCvxa7SN5wtAP2pJ5WD6z/+xs5rURPpIr5jyDAbzfB istQ== 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=0+oAkz+A263CF4j4eDfPEc3DfR6qO/zQ3grdn9paQZs=; b=ZtmxMt1AeFx4OIkfR60PrjMOUtptMC5eED76y6i+uhdWStnWJxCYzKiNduo5Yl0+aU ezFPBRnWzqgqH6KiSXaFL/HFQws3qhUd5xkKItXjN1N1m++e8rx3M7o7cnHNFdM3g1uS Cxgxor6gmx8F4ItYVxNj0NRwm3hSIMAMhjMi3zdsS6dI9gAO9+U2NsY0ftFEVnoDZq4J oPijtOhkJIglUm28NU2xWjm+krqBSkFC+YvO3n72K/Th8Lbzc6jwdy7M5YaVXoeTcgPR 20SPg4YWJ3bu3juhfU4t/cPTTXq79imf/kRbz65kd2AkYA2BRucLY2i8k/Gsl4uBXc0e V3cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wWz0tIJz; 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 gy19-20020a170906f25300b0073097bd94ebsi7015902ejb.473.2022.08.15.16.28.49; Mon, 15 Aug 2022 16:29:16 -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=wWz0tIJz; 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 S245056AbiHOXRZ (ORCPT + 99 others); Mon, 15 Aug 2022 19:17:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241157AbiHOXOZ (ORCPT ); Mon, 15 Aug 2022 19:14:25 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4F968A1DE; Mon, 15 Aug 2022 13:01:29 -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 ams.source.kernel.org (Postfix) with ESMTPS id 889F9B80EA8; Mon, 15 Aug 2022 20:01:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E20B6C433D6; Mon, 15 Aug 2022 20:01:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660593687; bh=pNYcoTpG4Vva9kv7QzWq1FSRNEWbBS/YySs1ndBRAAg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wWz0tIJz6kysUB9dUFsZZhzroMXeu7wIQUWvJrp9H2iOEAMIkElt5PPZzA8arqDb+ H9Emd2XU2aB4L4EkfH9I37Fxfzk4NAsVVncoEPZycLk/1A6ywoW62zZI0D4huBf9CB NYp9E/Q5Aat8f4Mmw0+mv2C04TtDuoxl56O1FUAc= 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.18 0958/1095] video: fbdev: s3fb: Check the size of screen before memset_io() Date: Mon, 15 Aug 2022 20:05:57 +0200 Message-Id: <20220815180508.713587087@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@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 6ba592fa014f21f35a8ee8da4ca7b95a018f13e8 ] In the function s3fb_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: [ 54.083733] BUG: unable to handle page fault for address: ffffc90003000000 [ 54.083742] #PF: supervisor write access in kernel mode [ 54.083744] #PF: error_code(0x0002) - not-present page [ 54.083760] RIP: 0010:memset_orig+0x33/0xb0 [ 54.083782] Call Trace: [ 54.083788] s3fb_set_par+0x1ec6/0x4040 [ 54.083806] fb_set_var+0x604/0xeb0 [ 54.083836] do_fb_ioctl+0x234/0x670 Fix the this by checking the value of 'screen_size' before memset_io(). Fixes: a268422de8bf ("fbdev driver for S3 Trio/Virge") Signed-off-by: Zheyu Ma Signed-off-by: Helge Deller Signed-off-by: Sasha Levin --- drivers/video/fbdev/s3fb.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/video/fbdev/s3fb.c b/drivers/video/fbdev/s3fb.c index b93c8eb02336..5069f6f67923 100644 --- a/drivers/video/fbdev/s3fb.c +++ b/drivers/video/fbdev/s3fb.c @@ -905,6 +905,8 @@ static int s3fb_set_par(struct fb_info *info) value = clamp((htotal + hsstart + 1) / 2 + 2, hsstart + 4, htotal + 1); svga_wcrt_multi(par->state.vgabase, s3_dtpc_regs, value); + if (screen_size > info->screen_size) + screen_size = info->screen_size; memset_io(info->screen_base, 0x00, screen_size); /* Device and screen back on */ svga_wcrt_mask(par->state.vgabase, 0x17, 0x80, 0x80); -- 2.35.1