Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1111908pxb; Wed, 6 Apr 2022 09:01:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbr+x+F/+sB5h8vAXijz8p8Q1MO3HfLE/n2kNj9xh1qBuh+sq7NeBf/QRPcKxR3/BdjwoS X-Received: by 2002:aa7:8d47:0:b0:4f6:a7f9:1ead with SMTP id s7-20020aa78d47000000b004f6a7f91eadmr9381397pfe.42.1649260862517; Wed, 06 Apr 2022 09:01:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649260862; cv=none; d=google.com; s=arc-20160816; b=XkC7d3qgdbSQ/ZOceYTAaylFV7PZmBqa6MWXgox1KYh1b1X3Irsc6yDLrhiBbMVB+v 9aBtF5s2iDHKOgp4IrbCmJcUQD0mIpurp6aD0CfvhTJod3NrOu5LOGvgMpDKFF9aDJyD YkrIipoFXmyAWxen9qGiggiQYLC3j+UrTrnW8Q1CwqCSkJ+3G0fwV2IddRvAX3H3eqbQ VHAe9l/u1X2TLq/dd37hczKZs95sLpoyGrx5QW5nzLItZ2OUe3tAhxdup/hnpNKPKFuT x7Ip00Pc8E+0v8UZ7QW/5fknV3rQJY2gkAtRbLUYQo7ChXTEMRXP9Y41QcHx1KezRrCe jV2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=+kvmNeaIx7IB5BYMxWZTmG2UdGRttU94dBZuAtL4Mmo=; b=Qf1wSMrDCyduCXl7grI/oydQPYqT1FQvNj0mcmJt2cO+4PDoDUMqQr08s7/8GcCqZt jjkiLdnMpUjN7+K6HV2ynMGMiOd+2bycxMeJ+eTWFBOqbUSSS1qM5fjIQU/GsFg8th4s g4caQMPu3LsEoyngmMO2o4metPIOl16AHX4N+Zk7gdVXs7aHKNI/TT1kWdJCQTeO2vpa Hv35yGZ3YnoGUy+Qtt6HDJC0Y+IVR8uj3gaoHI2mbnhSzgqbns7+a4Ob+/MKbfD6EPXM 9y6Ok9uXCmHJmM815R6C7qvK0fgZbZvlr2LvSPdg9HLE4+I7NUzjZ6bpQkp7c9AK3j+M Rh0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LEzG1yPF; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id z37-20020a634c25000000b0039958d8b11asi5675208pga.500.2022.04.06.09.01.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 09:01:02 -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=@gmail.com header.s=20210112 header.b=LEzG1yPF; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4C2654C009C; Wed, 6 Apr 2022 07:51:29 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235039AbiDFOxE (ORCPT + 99 others); Wed, 6 Apr 2022 10:53:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235048AbiDFOwp (ORCPT ); Wed, 6 Apr 2022 10:52:45 -0400 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05A54278540; Tue, 5 Apr 2022 18:24:32 -0700 (PDT) Received: by mail-pg1-x531.google.com with SMTP id 66so869924pga.12; Tue, 05 Apr 2022 18:24:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+kvmNeaIx7IB5BYMxWZTmG2UdGRttU94dBZuAtL4Mmo=; b=LEzG1yPF+iOw/30hd5E7mWGalRFTazmZ26PA34EyQTbkg0YljKXLaPf2eOppyTj4H6 yLrLvmCh4vLS4e2+5tjq6DOsc6DDq3GCdY9pxzAAVprQOEvgGRqi/GvrU1xlenMON/oq vqkTGOyRs5HC02ZNBLpMhFjGj8eayV8R8iQ4TlHoXJUQ6x8p1czQStn3js4L+fBTje6D D9DXldHCWPPs3LnMdGHflwmMfHA4JbQ0XtCSRo6SWODePkGh6Q2o1+rlWu9XV6ZxJBvE WKfi+upKy5fetBruNDSKmuKInPS/KDtKhk4gPSPMsFIHEDOfnCEdEMka4RBlnM5rIHVv VTSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+kvmNeaIx7IB5BYMxWZTmG2UdGRttU94dBZuAtL4Mmo=; b=GeKK+TT4Os8Iv3J1j3gn2/gs5w6uyLZK6ljYAUGFEIPl6MntscdHodiAwCYOwN/BKb h1N9cUPWfA1H8L0IaRHCxOTB6MOfI7mf4pDtaUXih0vxBALU/h0THXR/zN7xl3usUVYV 7mEmSQamYg1WtJi7v04QeMcLDPuDA08yT64+9ALE81pi8IuWaIRILPfTLrcC0dCXQKlN HOkNk/b47lZ0/hHGrmFoJrIh0zRR1v+F+w6aRvNin2GWhX+kV143ZsUFqNmyeG9+KGKF ohcFgX3z4+ibni5MHwjD8143494noTazIXtP6EMVz9G8vHFsBqIEKkliUlkr53ediXaa +YpQ== X-Gm-Message-State: AOAM530BNqw5YP0UqCXx4CRsG8BatEWATRKw3fNMHabTiXA4WbOTWf+0 OeeeNAiy6D15auOavZlBj0n36fWzQ1bht35ZACGpzMqIl1QL9lY= X-Received: by 2002:a62:4e4e:0:b0:4fa:b1d4:3405 with SMTP id c75-20020a624e4e000000b004fab1d43405mr6433730pfb.71.1649208271487; Tue, 05 Apr 2022 18:24:31 -0700 (PDT) MIME-Version: 1.0 References: <202204051946.43277.linux@zary.sk> <527a8c23-609f-5f8a-e076-a8a59da59865@gmx.de> In-Reply-To: <527a8c23-609f-5f8a-e076-a8a59da59865@gmx.de> From: Zheyu Ma Date: Wed, 6 Apr 2022 09:24:20 +0800 Message-ID: Subject: =?UTF-8?B?UmU6IFtCVUddIGZiZGV2OiBpNzQwZmI6IERpdmlkZSBlcnJvciB3aGVuIOKAmHZhci0+cA==?= =?UTF-8?B?aXhjbG9ja+KAmSBpcyB6ZXJv?= To: Helge Deller Cc: Ondrej Zary , Geert Uytterhoeven , Linux Fbdev development list , DRI Development , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 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 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. > > 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/ Zheyu Ma