Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp64654pxb; Tue, 5 Apr 2022 00:09:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYdYRZcPJD0z7lntyv4Gu2M8WrjK95hQBovWwol/9RKydGT7QMYeLxiYDRWU+tBnIrvX/m X-Received: by 2002:a50:9eaa:0:b0:418:f708:f59c with SMTP id a39-20020a509eaa000000b00418f708f59cmr2023190edf.333.1649142559064; Tue, 05 Apr 2022 00:09:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649142559; cv=none; d=google.com; s=arc-20160816; b=gAnuwi+8CdKPxHakYIb9Q7K0VLZSqECK3AOSDXIurTLnoxnv6OWUrR/OpH7opwUHl2 wCuyRz0sb5nUhhex7ZOXQJj5j2rllj33YW2MkhTwBTIjsosd23tQPuokZ4OFbhPKTd8D 8hTuB84B011CNEXU294aCtB+oZsiphEJYuThEi4zSX7X1NW0FnwdOSHItglAegvhCbbx zlPQhKQsi2GbYXBlyYRzru9lrB43LntcOKZylQAxFyub3AMIDNt7App4FKVLdhxOFuLF SX1oM1DBv437h0O+XlPLvdK1ElP75gnjfISL0edeCLLqOKXzwCSEV1MQoTMQgMpG1Kue UIqg== 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=DycBChbb/YiWj/t2SE2tBdf8J9cKjGJ0kPUM6R2DG1c=; b=cvYs6J0bP+axzTkQxRv+A+lEPXuQA3n/mI0OpGsEkdwUmwMjIzwIj+KfPkPc8WV2uQ OgJjuYTn2rAE/t4bvqBS+nhS+15CMYGJZMPQvXXAHzO/NMkLfb1J8oI8JDo5nGm7k/yr wAXQ/h2G1yB4b9G3zvjZTB5C7ZKNesFLbJqX3k1FkXQwxLSNhyw2ha6zmLiPm7LjONOS gYHaWxklVzMzFYOlVusfTAcrxOchwOxWkTWvBrCEjxkvna720pD/qBPwUvwKLDrMgIpa PtjzYloIaGAOy/0GxU618YGEQZy558VMQNSzaQndD9bVDZW80NEI0UP8s7xrmdraqL3U p81Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=VN1tSV6j; 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=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ca23-20020aa7cd77000000b00418c2b5bf40si7965144edb.546.2022.04.05.00.08.44; Tue, 05 Apr 2022 00:09:19 -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=@gmx.net header.s=badeba3b8450 header.b=VN1tSV6j; 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=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230233AbiDEGgJ (ORCPT + 99 others); Tue, 5 Apr 2022 02:36:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229892AbiDEGgI (ORCPT ); Tue, 5 Apr 2022 02:36:08 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C0FA11A2D; Mon, 4 Apr 2022 23:34:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1649140440; bh=ko6FFCg3jTQWeYcbHsEzW71hBgUeVWbZQ08boagfVh8=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=VN1tSV6jLfLzmXOZlAnvO9bWT0yNLTouT0lzZ3D5RcATXZ8zc58gzv/lEq0zrYaTj 45rXW+yim5nJwk0VOfy1Pu8F0y8Q1JhChF/qeztUZgrHQwscqV9/ACKW7iCMx49n/d m+Nv5rOBxcR8bYLmSf+EcfanK1PDHcCPHO/hn0G0= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.20.60] ([92.116.146.134]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MFKKh-1nmLCr2YW1-00FfsL; Tue, 05 Apr 2022 08:34:00 +0200 Message-ID: Date: Tue, 5 Apr 2022 08:33:57 +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: Geert Uytterhoeven Cc: Zheyu Ma , Linux Fbdev development list , DRI Development , Linux Kernel Mailing List References: <631f03bd-0fdf-9cc8-bf37-89235fb84162@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:LAaILEqFZDZfM0xhZS/NVXXhgIYpnWNV8s/9VbcsuBDSMWLiLPU DZEl7WtmMPSH8cqpob7Mqcset1jUEFargB3vc4YKvgOwul/QMVs26H26NIoXislvjl1VLP8 J/FS1DeVpDfyjSG9fT4UzIKh1PDaExH0xAGvLK9bEKiwFs46zrvxRcsZAxNpfsxBe4CULZk mCKNkN4TMPSo3C9/DwOwA== X-UI-Out-Filterresults: notjunk:1;V03:K0:nNDHsF5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qCUDsQ1D7JxC0c9oJLcsqyMQ3njOzTD++XxLr1Uot/zUYS/RXCG8QjJU KBd9vT9B7OM87M= X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 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 value to >>> 'var->pixclock', the driver will throw a divide error. >>> >>> This bug occurs because the driver uses the value of 'var->pixclock' >>> 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 lowest >>> supported value when this field is zero. >>> I have no idea about which solution is better. >> >> Me neither. >> I think a solution like commit b36b242d4b8ea178f7fd038965e3cac7f30c3f09 >> 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 b36b242d4b8ea178f7fd038965e3cac7f30= c3f09 ? > > 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. That said, currently I'd prefer to apply the zero-checks patches over any untested patches. It's easy to revert such checks if a better solution becomes available. Thoughts? > Commit b36b242d4b8ea178 ("video: fbdev: asiliantfb: Error out if > 'pixclock' equals zero") does not do that. Helge