Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp70210pxb; Tue, 5 Apr 2022 00:21:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7snQKhbmsyMB0dZW3ZSSMrv8yZ6TriO1llKsQPOGcKULNwI0FD6R91ESYSXS3mT6VtKH1 X-Received: by 2002:a17:90a:fe04:b0:1ca:c8e5:e3d with SMTP id ck4-20020a17090afe0400b001cac8e50e3dmr2524970pjb.227.1649143301502; Tue, 05 Apr 2022 00:21:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649143301; cv=none; d=google.com; s=arc-20160816; b=dQRfJr2OOvOPVtJq1pFn/7myTozF+uxZprmMzMFKwCfLuAZU2yCryTq53xn2IVeYO4 M2yq8/ORW29viQu+g45NDJN1MIaHTRTJeFhQIOgOf4n4mysYE6m2AMHRpnKkWLkt7XI8 vNHP7u3ZPwfKAy+bhFMhxwBOX3Shr21XIdXI2xBkK64CZMoa7cMQCV+OtaaG3ZfUqKyq /1gvhsWhWz7ITvQMXVxM7yTe7PNb67gKZ2r3XLlvwm344bI5rcjWPCtO5K183PlIRrxj k+OTtUxLQ9dtXqN05usevB5LfhesHWufgXweFz9KDVfmpP6N0CWGab3HTaBPLXAvA3TL noHQ== 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; bh=xS9sh+p2XRsClxVSPRroc3YnRbOn46SzHPHvIsqLwCM=; b=V2vxItyJKjEtjw5UVBOtNfh8wUoHn+X4837/J7T7rJpdUL3mwtwB3AJ7qVvIkoDdGP r1jUIVTLBIkPxx/HXaMF4o5MtAD4hA0IwBZLojUoASAUSaNCt6Qh54CGVIEBPBQTHoYQ hh4U/MiK1ELuUtDsObc9Fzc3k0bs7h4qCaPyAJcbmHNQTWSEo4O6o17oh5aCWd0OUVCy VJLD2wPl9OMx5sitKPxJ+nX8ZDPE7JRohkQsMC/UDK3W3m1LWLvnPVUNTynBk2NqP8JG ExpdaegEtApdDsmeChtE76UIsahoXvVoXTkk0VFaWDcrbKrh4G5idjfJ7s67DXfvEqF+ oXVQ== 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:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o18-20020a170902d4d200b00153b2d16637si13106631plg.575.2022.04.05.00.21.19; Tue, 05 Apr 2022 00:21:41 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231183AbiDEGyy (ORCPT + 99 others); Tue, 5 Apr 2022 02:54:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231180AbiDEGyo (ORCPT ); Tue, 5 Apr 2022 02:54:44 -0400 Received: from mail-qt1-f169.google.com (mail-qt1-f169.google.com [209.85.160.169]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C85FE8EB4A; Mon, 4 Apr 2022 23:52:46 -0700 (PDT) Received: by mail-qt1-f169.google.com with SMTP id c4so9733926qtx.1; Mon, 04 Apr 2022 23:52:46 -0700 (PDT) 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=xS9sh+p2XRsClxVSPRroc3YnRbOn46SzHPHvIsqLwCM=; b=2KMJt+uLfxx28f7xoSxHe52Np4I4DM95EoIPkeYev4LUgYR/ecfIqR7WDnGVxEsXDY tr5dNWlgif8+9mq03g5LW7f65LVkrQlLraM/YV3AUof5tPsNoWe6ZejwqaJH806fkTE1 fcci/qKc4q0jXPz+mZvjWbcPxuTrtHroWj9sV5FMHjQd/X/QN1sCodf2xxn8HUBmCkt1 V/81PbPk8Q1f5z002j34SNnptz1zSNlmv9zJ45iEW9E+UvwlAYV1Mydl25j52tcnbUoT MIgVAt6eNjwIIiNYodp31s7gKLFfKiYMfamHDnObXol3580GPbVPSzPYRLSBoTGnEamG lH7w== X-Gm-Message-State: AOAM533J4U4Gsb1sak6CDTR6MBDo7ymFQLBE6618AYQntZEQqsKWXhyC 7l7Dzl87bccje37g0SG9rGjpACPgJKRA9Q== X-Received: by 2002:a05:622a:12:b0:2eb:871f:cdc2 with SMTP id x18-20020a05622a001200b002eb871fcdc2mr1739505qtw.352.1649141565107; Mon, 04 Apr 2022 23:52:45 -0700 (PDT) Received: from mail-yb1-f172.google.com (mail-yb1-f172.google.com. [209.85.219.172]) by smtp.gmail.com with ESMTPSA id k1-20020ac85fc1000000b002e1c6420790sm11019959qta.40.2022.04.04.23.52.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 04 Apr 2022 23:52:44 -0700 (PDT) Received: by mail-yb1-f172.google.com with SMTP id f23so21677678ybj.7; Mon, 04 Apr 2022 23:52:44 -0700 (PDT) X-Received: by 2002:a25:9e89:0:b0:63c:ad37:a5de with SMTP id p9-20020a259e89000000b0063cad37a5demr1478959ybq.342.1649141564401; Mon, 04 Apr 2022 23:52:44 -0700 (PDT) MIME-Version: 1.0 References: <631f03bd-0fdf-9cc8-bf37-89235fb84162@gmx.de> In-Reply-To: From: Geert Uytterhoeven Date: Tue, 5 Apr 2022 08:52:33 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: =?UTF-8?B?UmU6IFtCVUddIGZiZGV2OiBpNzQwZmI6IERpdmlkZSBlcnJvciB3aGVuIOKAmHZhci0+cA==?= =?UTF-8?B?aXhjbG9ja+KAmSBpcyB6ZXJv?= To: Helge Deller Cc: Zheyu Ma , Linux Fbdev development list , DRI Development , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,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 Hi Helge, On Tue, Apr 5, 2022 at 8:34 AM Helge Deller wrote: > On 4/4/22 13:46, Geert Uytterhoeven wrote: > > 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. > > 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? Fair enough. And you're the maintainer ;-) Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds