Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp43596pxh; Thu, 7 Apr 2022 13:27:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJHStFWph3O/jWCCTdWlSQRVPh1lBj0sARvnYv1WflARiUikhAOoqDQih/uPkshUBjCK8E X-Received: by 2002:a63:6e0b:0:b0:397:f965:64a7 with SMTP id j11-20020a636e0b000000b00397f96564a7mr12489212pgc.581.1649363233941; Thu, 07 Apr 2022 13:27:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649363233; cv=none; d=google.com; s=arc-20160816; b=ve6MYKvqGZBtTJ21HqAzJALOHMbNogOjCTHQk9Ub8xwVZWYVedfym+sVPxEH3namKd 4kwgZduVYHAa8K0YR8/nQJ7wqmFnaqyngvCTcVGBAP6ExXSm3ZEgosFMTn4Ha8H9sZKQ nBTEFJzroYo3QpE3QNKcRuzWeD1KUH611x6NqzgX/43/AuDMYkRO3F2kr/bUCuZLhl7Y UwAVR4dxCtCCfbMbd4Bk03V15TSSdqCOAppZeXvs6AGW/44aiichY6HFimxZfuJZ2XLR 4C9Ha1rt7/UUdDes1m1UioO43LFpteuxCm1sXjZDx9+oCtXiYoknfibeZUVYoXpshVFN o8Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=OD4pTzY2uIzATaP89S5hMWZHSI4+4Pk1Q4paGHv5mnA=; b=P3oIsqBOnZu868m8rAnoU5H5XTQljzV8OOXqRowIvWlmt1T63uz+ZGsEBG30kdfkZd ugQngAt8TEShhLjLkFzDlhuYme6dGqpJ4rl4ABnf9Gj/0Nxn1WvnFtcm+I/elqQa0x2+ ehy64hbr1ks8b47JflYg9/eBy8Nejzeb+mlf/fZ9wTKwlrNqH8+cWir77/I606n9ombp CtnRdQ3WDrXq27KFDupnDPFgWjVtQhjNOtDLJUVxEfoNI2X/Bj1Ca5c4DzwK5nd1jegw PgUApLVNEOsg7AwZwKKM9s2lI8sFtDkLSZa6jtpGOvASV63hcM6RXAq4/NHj0SUXVfqd crcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=LH6lTAjp; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id b22-20020a631b16000000b003816043eeffsi22634771pgb.244.2022.04.07.13.27.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 13:27:13 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=LH6lTAjp; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D957F35FCF8; Thu, 7 Apr 2022 12:42:28 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230254AbiDGPy3 (ORCPT + 99 others); Thu, 7 Apr 2022 11:54:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230513AbiDGPy0 (ORCPT ); Thu, 7 Apr 2022 11:54:26 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA29713F0A; Thu, 7 Apr 2022 08:52:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1649346737; bh=8F0t/FONcQor1dELWSbQulID3wh2RD6EgpmnVPvR4Cg=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=LH6lTAjpY2/vfJbAhwMhsLPCl5/7kNEUeo8cnzY0NdBzcCVU1yB45AhU/Ua3dIahB nN8WcqpDqyG/if4ubmgTdOjM4ZoX8Wfc5bgQmL4GLHgMwvLVR6W0E0WtaymfRI3djO jMastlx6rGqUHvMXFBVhcyCjBGyYFBe88pRMeJvg= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.20.60] ([92.116.161.122]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MysW2-1nyAD52mPK-00vz3W; Thu, 07 Apr 2022 17:52:17 +0200 Message-ID: <9f694b7e-4cd1-9682-76bd-d534b8b2a485@gmx.de> Date: Thu, 7 Apr 2022 17:50:35 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: =?UTF-8?Q?Re=3a_=5bBUG=5d_fbdev=3a_i740fb=3a_Divide_error_when_?= =?UTF-8?B?4oCYdmFyLT5waXhjbG9ja+KAmSBpcyB6ZXJv?= Content-Language: en-US To: Zheyu Ma Cc: Ondrej Zary , Geert Uytterhoeven , Linux Fbdev development list , DRI Development , Linux Kernel Mailing List References: <202204051946.43277.linux@zary.sk> <527a8c23-609f-5f8a-e076-a8a59da59865@gmx.de> From: Helge Deller In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:j7cwFdDjfVpmsMjtwyB3OUO3M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YUDavkhi+g83FZ79WTiUriggR8+R8nzhN0M/KT69ruvpIj26ul8/b u3LvavI89dl6hzJ/EV3F9brJVJch50NXOvLwFJdldJXTiFnzaHdh+Axi7p9FiGqJfJpSXlZ+K XsqPDqbwJQri8LrTrh2ugGKzL+OIe+4fm8tqPb6b2GxPW95PMHxEa5csy4rQVJ6c1aYe2dUTE 1/lSyaGB0/M9G1lkgHI2l4gvq88B0e0jm997O5oURNMoHYXHAKkXTrvltPDv+uDRAwuTv/2/s 8unlWpwiWn3YJA= X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On 4/6/22 03:24, Zheyu Ma wrote: > On Wed, Apr 6, 2022 at 2:23 AM Helge Deller wrote: >> >> On 4/5/22 19:46, Ondrej Zary wrote: >>> On Tuesday 05 April 2022 08:33:57 Helge Deller wrote: >>>> Hello Geert, >>>> >>>> On 4/4/22 13:46, Geert Uytterhoeven wrote: >>>>> Hi Helge, >>>>> >>>>> On Sun, Apr 3, 2022 at 5:41 PM Helge Deller wrote: >>>>>> On 4/3/22 13:26, Zheyu Ma wrote: >>>>>>> I found a bug in the function i740fb_set_par(). >>>>>> >>>>>> Nice catch! >>>>>> >>>>>>> When the user calls the ioctl system call without setting the valu= e to >>>>>>> 'var->pixclock', the driver will throw a divide error. >>>>>>> >>>>>>> This bug occurs because the driver uses the value of 'var->pixcloc= k' >>>>>>> without checking it, as the following code snippet show: >>>>>>> >>>>>>> if ((1000000 / var->pixclock) > DACSPEED8) { >>>>>>> dev_err(info->device, "requested pixclock %i MHz out of range >>>>>>> (max. %i MHz at 8bpp)\n", >>>>>>> 1000000 / var->pixclock, DACSPEED8); >>>>>>> return -EINVAL;x >>>>>>> } >>>>>>> >>>>>>> We can fix this by checking the value of 'var->pixclock' in the >>>>>>> function i740fb_check_var() similar to commit >>>>>>> b36b242d4b8ea178f7fd038965e3cac7f30c3f09, or we should set the low= est >>>>>>> supported value when this field is zero. >>>>>>> I have no idea about which solution is better. >>>>>> >>>>>> Me neither. >>>>>> I think a solution like commit b36b242d4b8ea178f7fd038965e3cac7f30c= 3f09 >>>>>> is sufficient. >>>>>> >>>>>> Note that i740fb_set_par() is called in i740fb_resume() as well. >>>>>> Since this doesn't comes form userspace I think adding a check for >>>>>> the return value there isn't necessary. >>>>>> >>>>>> Would you mind sending a patch like b36b242d4b8ea178f7fd038965e3cac= 7f30c3f09 ? >>>>> >>>>> When passed an invalid value, .check_var() is supposed to >>>>> round up the invalid to a valid value, if possible. >>>> >>>> I don't disagree. >>>> The main problem probably is: what is the next valid value? >>>> This needs to be analyzed on a per-driver base and ideally tested. >>>> Right now a division-by-zero is tiggered which is probably more worse= . >>> >>> I still have an i740 card so I can test it. >> >> Good. Someone wants to come up with a proposed patch? > > I have submitted patches for the i740fb driver and other drivers which > have similar bugs as follows: > https://lore.kernel.org/all/20220404084723.79089-1-zheyuma97@gmail.com/ Yes, I know. But Ondrej offered to test a patch which would round an invalid pixclock u= p instead of just returning EINVAL (which is what your patch does). So, if someone comes up with such a patch it'd be the preferred solution. Helge