Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp775188pxb; Tue, 5 Apr 2022 22:49:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqiDcVk5Pim9BJ4N7NEkMDdw4Fyjq7L5PT5k1bX2eokPHZSzmKEZLhE95YWaFo8p39W30Y X-Received: by 2002:a63:1117:0:b0:399:2df0:7fb9 with SMTP id g23-20020a631117000000b003992df07fb9mr5951439pgl.40.1649224152511; Tue, 05 Apr 2022 22:49:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649224152; cv=none; d=google.com; s=arc-20160816; b=hw2Tj9BscUGIh7FLZ1zD0JeHVYRz3YC40E2iSG2Q5/+sJsWjD+NiaCAwC6Z21GkUA5 /ucrl1FDme3mi06V6g3/BLMechhOFa5jWsCzMorSPadcQjC9+ATkYlmPsV/htlxc+O8N jlk+xjQcwCqywMVnTJIODpmA1nnlC9cDvZ7Ddz8wd53kiu3G6tRjmYWyYv4dJ1CIaG2Z 1ugGRe9HW06h8bBMVZmb/HWjawXujH0aE2gdWxuA4wfPY4kVpH350pgqE8WeFOJjxugG RFPD76CNX+5IySFeiZme5DBZalOAd8r8wcPz76gaBpJy+6TZ1mJBSSayyXNvjIc2WO4g xPLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:content-disposition :content-transfer-encoding:mime-version:in-reply-to:references:cc :user-agent:date:subject:to:from; bh=PDPMQdFR9ha7tkJwofNHCBqFHHKu11L3T602SqrrJ/w=; b=bIFcJ3b9r0bMT7IEIO/MdmpKmGrPxSGCHLk+8wR+3PYSJJbofejdlV6XmIokFXvnfb FSkIr5As4us8AkOnHc8+v1qrsKaeZ5M23gF7aMm3xqPzHtK/miLO070dbd31M9bt4VqR nkwiM5qJ9zWl1yBZWkGP7znkDI/QTNLtwqAc5LKzZsPxfEKDOyq5eWsXCN+7XpwUAR2S JmhxPifrBpG2EjQcf4Hwf3KmPUVExA0QYbjbJvWcf1fvU3X6MCO01QlegTbjg0BUknXQ RxECYWGf7jexDoT3ABbobJ9fgFZ+koJ1FRrtmiWcsNWX1pp1M58bK8OWFYs/LdnRw090 VlaA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 82-20020a630155000000b003824fa90821si14932822pgb.523.2022.04.05.22.49.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 22:49:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CA00849CC59; Tue, 5 Apr 2022 22:21:51 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1845018AbiDFBxk (ORCPT + 99 others); Tue, 5 Apr 2022 21:53:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1573046AbiDERsu (ORCPT ); Tue, 5 Apr 2022 13:48:50 -0400 Received: from hosting.gsystem.sk (hosting.gsystem.sk [212.5.213.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 034E4D1111 for ; Tue, 5 Apr 2022 10:46:48 -0700 (PDT) Received: from [192.168.0.2] (chello089173232159.chello.sk [89.173.232.159]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by hosting.gsystem.sk (Postfix) with ESMTPSA id 891F17A04A9; Tue, 5 Apr 2022 19:46:46 +0200 (CEST) From: Ondrej Zary To: Helge Deller Subject: Re: [BUG] fbdev: i740fb: Divide error when =?utf-8?q?=E2=80=98var-?=>=?utf-8?q?pixclock=E2=80=99_is?= zero Date: Tue, 5 Apr 2022 19:46:43 +0200 User-Agent: KMail/1.9.10 Cc: Geert Uytterhoeven , Zheyu Ma , Linux Fbdev development list , DRI Development , Linux Kernel Mailing List References: In-Reply-To: X-KMail-QuotePrefix: > MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <202204051946.43277.linux@zary.sk> X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, 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 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 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 b36b242d4b8ea178f7fd038965e3cac7f30c3f09 ? > > > > 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. > 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 > -- Ondrej Zary