Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3407913rwa; Tue, 23 Aug 2022 04:23:41 -0700 (PDT) X-Google-Smtp-Source: AA6agR4KgTUKUnB7Kt9VBR9IDLUaHvwU+U7ILObd1unBHmVBhCkZOuki1k3n6sBU44HNa5z5r7Jk X-Received: by 2002:a05:6a00:17aa:b0:537:27e:625b with SMTP id s42-20020a056a0017aa00b00537027e625bmr2084686pfg.12.1661253820814; Tue, 23 Aug 2022 04:23:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253820; cv=none; d=google.com; s=arc-20160816; b=Qiy8PSnNzHIYw96NaN5L5BI3JuRAUdDM2U2sbUdU8SMVPvL0/uuMa6ELEYlThomey7 eWJJMBnjQF8S4x9Q4pADAsZG7s/Bt9d66N0SsgePCBo9ZGJu9onBKWMCsNJL+XNVHMVN jS4SSY8x4pzDFD59aPpTZ+z+98nIj0bK9j5bihvITQhF+Ct81GtrRxOgTcB2+lETJIOu uqwOzdO4EuUQZ93xL56b51u/hlF51Iq3pun7cXZBGB/cVfG6jla7kQM0RPfYeJmEInFP /GuhQpt03YWh7rn+xNM8uidmp0FfYrTs9nrRtJaMi7x0g0CWOeS/9vATugo0FEQ+Ywuy JFqA== 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=ti+tZSWWwaXep4vQQU0WEfpmHMmiKIpcsCakqyQOeKk=; b=jmtAA5Us1SgYLgLU/RofxIlCxVqUz3BO+Zdr6rZISVww0463Gv4LT3gCuiHKhS71hL 7o9cHUfJSUp1xxnX1hV8u70/UiuWRuT/74QlbVHafT1A6SAk3ZwZRH9K9fQCO7LzCRcH hKL4a99lBIn73WJaD1nwW6ibM8SuZ6OkEKGq1M23nIZbS63EwRx3VdRt/W7HoAqVJ/xN Wxzq133rVKaRBnJpj6628nt9zDMPWKBm3IUUUM2w4sF77sPLPamJFgA98y2kNFF7Ve6/ zpKz18vC88hc/8+zMCdIQb4fj+4qE5EHYWU9Pjj5JpfgSSLqMI0VZvsMQ1Gl44AaiYyE yIjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=f0aAi0u6; 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 c5-20020a170903234500b0016ec623eac3si16149327plh.239.2022.08.23.04.23.28; Tue, 23 Aug 2022 04:23:40 -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=f0aAi0u6; 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 S1352315AbiHWKFa (ORCPT + 99 others); Tue, 23 Aug 2022 06:05:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352049AbiHWKBK (ORCPT ); Tue, 23 Aug 2022 06:01:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6513422B0A; Tue, 23 Aug 2022 01:48:33 -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 0D1AD61538; Tue, 23 Aug 2022 08:48:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 002E3C433D6; Tue, 23 Aug 2022 08:48:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661244512; bh=HW8oSDo9+AP0Lh/FOT/cK/fI51j5qkfr5A+LITh7TqM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f0aAi0u6uPstrM22zJhT5JrZrPeaZ2lL7swExrgSyelmeOgDLcAidVr7UaiU1q7Hx 9e6TSO5D8Mglg5umhgS1NFcAxSRUpCfnVmLmHqte0SYsRjGhLX807jkfyXMu+HUYaJ /4ln8O/zDvx2ZLIpiH0MddkCIjUsF+P6Ao0xnBRE= 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 4.14 148/229] video: fbdev: s3fb: Check the size of screen before memset_io() Date: Tue, 23 Aug 2022 10:25:09 +0200 Message-Id: <20220823080058.960774264@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080053.202747790@linuxfoundation.org> References: <20220823080053.202747790@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 d63f23e26f7d..b17b806b4187 100644 --- a/drivers/video/fbdev/s3fb.c +++ b/drivers/video/fbdev/s3fb.c @@ -902,6 +902,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