From patchwork Thu Aug 4 12:41:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zheyu Ma X-Patchwork-Id: 595409 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD482C19F2D for ; Thu, 4 Aug 2022 12:41:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239344AbiHDMlt (ORCPT ); Thu, 4 Aug 2022 08:41:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239368AbiHDMlr (ORCPT ); Thu, 4 Aug 2022 08:41:47 -0400 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AFCB3205A; Thu, 4 Aug 2022 05:41:45 -0700 (PDT) Received: by mail-pg1-x535.google.com with SMTP id 12so17863333pga.1; Thu, 04 Aug 2022 05:41:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=w0Xxsd10rxzXzo6/5gdWcIy61xCxC4G1bz1u1E9fXCo=; b=qD8j7MqqhHWzCEXuJN+GpeSzUdlAxRyaiur92DU6at98u5tgv2exchm9KnIJRPGGwS 4RgMLhbFh/yr8Q5O4ECnkUGj9S8gVPjiXPm2LAFsx62EZjdxCo/OrIO5X5UEUWZsK5PU UJFOkziuTiJVtruzn+BZy2AXNBM9tOueP9AeUKB8Os84d2OHraomImWx0uk3mxj4ocS9 yt97Dn5UzB1sUM9GM90TBP/DX0MFg4Jas3MDnu477/0yYH7Q8QAuxZGpZ0l1JAg0BiAr f1sP+x3t5jzGDNAbbDywp0l0mt82aC4dm5lR37ou1KVyg69+j4Q+f6p4AxwrxFDJ3bHw 8OLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=w0Xxsd10rxzXzo6/5gdWcIy61xCxC4G1bz1u1E9fXCo=; b=WDF3klEnKUm4HXOPV8XktOXTkjLHfohs84MJffvV75wcTfElTMfDSMzmr6lvoaMads 2zO7QWfg/r3e8wldVIrffJO+yq9pnL6ogrKneRll71mbliS2i/ydeJRW4YVdvzZtzNQl oyiKSZDTf7hzwNk4oWJpQwvYnzJSwVVKzfGFgYZCz/u7lKlLRAGhACV4Q+0/r8gGODsR Eu0aQDd8QQfa+97uReqZ3c26iLVTNJLsTXc2+O+9TQYCnJYZR/47XknSzHDUQIWREmCS Vl1pJsng5ccsF2LHKrsXkblWVH8p6NnCxjHN1BXBU8dRyd4x0j9NmvvTGvB6SfoPqtZC Yo7A== X-Gm-Message-State: ACgBeo0V4BJvoK5TdxcVQcKOAN6Vj5dQqL57wn49Lo6fJMFrU874QFp3 R86L1JCA0wLVjL58u1Srpw== X-Google-Smtp-Source: AA6agR5DWlGw0W1xZXujx2KGDv9sHfvTIt+iTdErPfZLMXgRlBBtcYlNDb72wX2TK2CqsJhy7Jwogw== X-Received: by 2002:a63:1658:0:b0:41a:4118:f4b9 with SMTP id 24-20020a631658000000b0041a4118f4b9mr1497090pgw.153.1659616904598; Thu, 04 Aug 2022 05:41:44 -0700 (PDT) Received: from localhost.localdomain ([166.111.133.51]) by smtp.gmail.com with ESMTPSA id i8-20020a63bf48000000b0041b672e93c2sm1070769pgo.17.2022.08.04.05.41.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Aug 2022 05:41:44 -0700 (PDT) From: Zheyu Ma To: deller@gmx.de, adaplas@gmail.com, santiago@crfreenet.org, akpm@linux-foundation.org Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Zheyu Ma Subject: [PATCH 1/3] video: fbdev: vt8623fb: Check the size of screen before memset_io() Date: Thu, 4 Aug 2022 20:41:23 +0800 Message-Id: <20220804124125.3506755-2-zheyuma97@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220804124125.3506755-1-zheyuma97@gmail.com> References: <20220804124125.3506755-1-zheyuma97@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org 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 --- 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 a92a8c670cf0..4274c6efb249 100644 --- a/drivers/video/fbdev/vt8623fb.c +++ b/drivers/video/fbdev/vt8623fb.c @@ -507,6 +507,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 */ From patchwork Thu Aug 4 12:41:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zheyu Ma X-Patchwork-Id: 595663 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C27EC19F2A for ; Thu, 4 Aug 2022 12:41:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239158AbiHDMlv (ORCPT ); Thu, 4 Aug 2022 08:41:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239405AbiHDMlu (ORCPT ); Thu, 4 Aug 2022 08:41:50 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51E972B188; Thu, 4 Aug 2022 05:41:48 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id b4so9247937pji.4; Thu, 04 Aug 2022 05:41:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=CCsyUyjtcxiqdAio61EdLoryAiVvM5FMmKPvH5Lk+7M=; b=p5VexO3soXHRkRquHKXZkC8JYq5rp2/+hH5cdP/9ybw6xveovaMm7vq9DULzixLiIm 2zQcITt0lDLza3JpyfTFtjiOf0ZjmkAYHl4dKyTmQHDnE5c264USvOJ3qUjPd8re+1o7 zMBGJm0vtdWGJhS35PJZI4FYub9oNCtlU5UqZpszGvlk3jzNvYf6EHshWdYWHXhjPxW/ hLb7yHDT1MRtKEEJgwiC1xcwkMDg6y7w4BivcoGWlgniNUlUueoeqLrT4pMYt0A0z4+G UnV3o+nvdprd6/CrmPtNzyvie7pw4bPdGQYISWpnMsWAxhHFAoD+J5qGzNQVecUS11rp fYYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=CCsyUyjtcxiqdAio61EdLoryAiVvM5FMmKPvH5Lk+7M=; b=eDHr/FFsIxqaf/DjBTtQDZvLT01o3pP2SEJ/ReZHSavgBH/B9dM/7a6L5O/XriSq2K 5XRV1JzfRtvBEmpXeUpP1T85yF93vaJVW1NoKAP1rbW3LuwhFa+plzgLPRvBKUiVPYcs /vSu/i4diOBw03dxPhpWESdhsRVtjtaEFmeMtiOI8XKtPio/bo+tiT+GKhN767wIkAj7 HrGx8iya/Xldf0DE00ARMcjirPA++FT4JwIcZOXEg3sV7+j5AwU07eobVddUh+rSedqs OGjYW2NEXL4zluiZyxocL1xl1+mDBMUJehMhzO2Lco+wvHXvfdp8nIbcqKWR8B9E2r6H pYng== X-Gm-Message-State: ACgBeo11c+6WLoLY9RcTje3W9O1qSuU6sbP63cUP5Y+yfMxEkGmd8Xxy v+S2tll+EtuQstNnJAbrbA== X-Google-Smtp-Source: AA6agR4X8s+bYDtMYD6EK98FWif6GTdlWCPPlzexQu4yKAsAh28bchh+1VCurElhJCelSbWYzUEB1g== X-Received: by 2002:a17:90a:fc91:b0:1f3:1f3a:54d5 with SMTP id ci17-20020a17090afc9100b001f31f3a54d5mr2006808pjb.74.1659616907801; Thu, 04 Aug 2022 05:41:47 -0700 (PDT) Received: from localhost.localdomain ([166.111.133.51]) by smtp.gmail.com with ESMTPSA id i8-20020a63bf48000000b0041b672e93c2sm1070769pgo.17.2022.08.04.05.41.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Aug 2022 05:41:47 -0700 (PDT) From: Zheyu Ma To: deller@gmx.de, adaplas@gmail.com, santiago@crfreenet.org, akpm@linux-foundation.org Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Zheyu Ma Subject: [PATCH 2/3] video: fbdev: arkfb: Check the size of screen before memset_io() Date: Thu, 4 Aug 2022 20:41:24 +0800 Message-Id: <20220804124125.3506755-3-zheyuma97@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220804124125.3506755-1-zheyuma97@gmail.com> References: <20220804124125.3506755-1-zheyuma97@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org In the function arkfb_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: [ 659.399066] BUG: unable to handle page fault for address: ffffc90003000000 [ 659.399077] #PF: supervisor write access in kernel mode [ 659.399079] #PF: error_code(0x0002) - not-present page [ 659.399094] RIP: 0010:memset_orig+0x33/0xb0 [ 659.399116] Call Trace: [ 659.399122] arkfb_set_par+0x143f/0x24c0 [ 659.399130] fb_set_var+0x604/0xeb0 [ 659.399161] do_fb_ioctl+0x234/0x670 [ 659.399189] fb_ioctl+0xdd/0x130 Fix the this by checking the value of 'screen_size' before memset_io(). Fixes: 681e14730c73 ("arkfb: new framebuffer driver for ARK Logic cards") Signed-off-by: Zheyu Ma --- drivers/video/fbdev/arkfb.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/video/fbdev/arkfb.c b/drivers/video/fbdev/arkfb.c index eb3e47c58c5f..de4002914f9e 100644 --- a/drivers/video/fbdev/arkfb.c +++ b/drivers/video/fbdev/arkfb.c @@ -792,6 +792,8 @@ static int arkfb_set_par(struct fb_info *info) value = ((value * hmul / hdiv) / 8) - 5; vga_wcrt(par->state.vgabase, 0x42, (value + 1) / 2); + 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); From patchwork Thu Aug 4 12:41:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zheyu Ma X-Patchwork-Id: 595408 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BEEFC19F2D for ; Thu, 4 Aug 2022 12:42:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239737AbiHDMmC (ORCPT ); Thu, 4 Aug 2022 08:42:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239734AbiHDMly (ORCPT ); Thu, 4 Aug 2022 08:41:54 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D9B92AE36; Thu, 4 Aug 2022 05:41:51 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id 13so3395663pgc.8; Thu, 04 Aug 2022 05:41:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=IqELUni7yOqBktpdBBbucmyGM38f0JGBlZ/P93Fp8ag=; b=oBx+siF17fjl9i5BvuQZ1qdK+rLtEzpUk3uCVRXEgskaRkyISP+iIlQ/giaOVIkrjI DPz9ffqSLfP6X23W/ejCdA0cHjdTajv5ZfB1JtrOqFFzYggakVhJNuyRdXM5xbYVQkgl FmW/0YPo2cmc7/vmgIsBSLBP3DlTQwPEWWb4qqNYgpHQXTyzRl2vns7C0LKp2Y+6UTn5 SCmWIea5jDUf8jIiSHCOqmUlTa/HV5QTMluEe/494XOSjLsXKHQLHwh6EdjCLwd0hlXp UCrEc7VNk3jN0/Ie+66c/4j2NaDf30FsSvABj3QtrD4Jk2ZtzdGdXowveIvnqTxgXoM8 XQtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=IqELUni7yOqBktpdBBbucmyGM38f0JGBlZ/P93Fp8ag=; b=QUS57aUr0Z/QqCNfHR3umsmtgilQJRIEHQ4ND+9ISQgDJQWbfJtZ4dZFas88j3alNh qzPmogL+irs/9WVNshAydxePj8Nc+3vcpFuT36dJll0J4bUrPxpqpSuTVNJTtp08Wkyn Cc7aghcYFN2T5mqIDQeqtuquHJlnzr+44YpfD4FO0Mi6BxfUiVYsND1FMCKD1ODRoEU2 d0K+Fw6K7qjhn625d9w5Yihq33WtpgAcHAKZr+0/Qh5TPbKBbccB7JueYWjWL7bwOPV0 KIeHBK0OePILFT0JRF+LJ4YQBnbzkhZEdfy5t50swsD0gZ6ktuZ6Qae3KvlEqAPXT7qf PM+A== X-Gm-Message-State: ACgBeo0znInLhi70XCswTYsssiWtdPVi+aA3vR3xW6uuA1MZR1p8tZY6 3DDV84M8+6sYnfL20n5aGw== X-Google-Smtp-Source: AA6agR7gwCQb5q3QUQuJgu3QIPH6DlUeRZ3KtvNPz5dZcndSktas2nIs8wSYnDaG/RC6A1skS2l6mA== X-Received: by 2002:a05:6a00:17a8:b0:52e:6e3e:9ff with SMTP id s40-20020a056a0017a800b0052e6e3e09ffmr1828954pfg.42.1659616910895; Thu, 04 Aug 2022 05:41:50 -0700 (PDT) Received: from localhost.localdomain ([166.111.133.51]) by smtp.gmail.com with ESMTPSA id i8-20020a63bf48000000b0041b672e93c2sm1070769pgo.17.2022.08.04.05.41.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Aug 2022 05:41:50 -0700 (PDT) From: Zheyu Ma To: deller@gmx.de, adaplas@gmail.com, santiago@crfreenet.org, akpm@linux-foundation.org Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Zheyu Ma Subject: [PATCH 3/3] video: fbdev: s3fb: Check the size of screen before memset_io() Date: Thu, 4 Aug 2022 20:41:25 +0800 Message-Id: <20220804124125.3506755-4-zheyuma97@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220804124125.3506755-1-zheyuma97@gmail.com> References: <20220804124125.3506755-1-zheyuma97@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org 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 ("[PATCH] fbdev driver for S3 Trio/Virge") Signed-off-by: Zheyu Ma --- 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);