Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3486171pxb; Mon, 4 Apr 2022 18:31:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjjfVkv9zsc6GDc9eFaTE2xLg1m734o1FKQAO9XUswAZ1rm0l3uLrSnKQRVWxoFqq4mvsM X-Received: by 2002:aa7:8256:0:b0:4e0:78ad:eb81 with SMTP id e22-20020aa78256000000b004e078adeb81mr1195910pfn.30.1649122269088; Mon, 04 Apr 2022 18:31:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649122269; cv=none; d=google.com; s=arc-20160816; b=J/j0Qur6N5jsEw/zyDkkqGy7gUjtFHfScEMsICrMkqg4PLnbRqvNb1wp6LG02AnlKy qLTp/QsUb49Vw9+23BKlOa7TEJ3iTiJbvZcUBYWPnaDhf3gcSUb4nC7l/N+iVmyKO4D3 GwWHn3qL/OVGjjA1fZlinESl+EwtL7EVmU2H7yhR/NasxRyw3tCBnrM2YdW/qhcp3twT XYwZh1v+imVv5RI6PK897HkUxQtdjc9WGP/95Al9856oTVJLYwj7rAPJRVHUXJH7LpO7 gAINSAiZfsJgqN2BYOGWtAttKzqiLYMo+QpLmN7OkCRH2/aMZ00i3LkX56i4qZNaWBKX RgXg== 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=AoKMmslTq9vAMf9fgCFPDKuPR8Y+Dj4j8nKqoiHe7eI=; b=bB7i1whE7hPdqRQfalzF1m7v8dqATHgy4cwKgjwLmBWqQFWFPYk/QD3urHzojotG06 bU2p/POdifft3YZWts7QA0Wy4vq6Kl4Ia0tA/86h/UQy9uErDrrvbbz9QC2c6y9cc02r dIPWuBBrpuHkLGKh9RMHXpBQUxMhGSGt5V5HhwWr+nXPJ2HPRhVHdINBPf+1amFiLdO6 CB/IWArtG1yljnOxSCV/frC95KbKCXN4H0X+FCbChqmpHkItjvk3CXnHObVwmsRTymq5 m8c4kic1Bs1Aimo1A6vJBjzHJD3q9dS8NfVOYZJCUXb49l1+E9caq2HwnfAL6anergYI Vf2w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id r9-20020a17090aa08900b001bd14e01f69si542417pjp.87.2022.04.04.18.31.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 18:31:09 -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; 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1C156E59; Mon, 4 Apr 2022 17:20:50 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378745AbiDDPyk (ORCPT + 99 others); Mon, 4 Apr 2022 11:54:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357418AbiDDPyi (ORCPT ); Mon, 4 Apr 2022 11:54:38 -0400 Received: from mail-qv1-f49.google.com (mail-qv1-f49.google.com [209.85.219.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 177504249E; Mon, 4 Apr 2022 08:52:42 -0700 (PDT) Received: by mail-qv1-f49.google.com with SMTP id e22so7759299qvf.9; Mon, 04 Apr 2022 08:52:42 -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=AoKMmslTq9vAMf9fgCFPDKuPR8Y+Dj4j8nKqoiHe7eI=; b=orYEe3782pb7f3scdOPHBOTx+0G9AEkrzmuxJv9y1NWBUaqrgkk5IfLOELobgXdy9o j+URwLav6QWmpw0kt9hYjScd090q0FdIzjB+Ms2e6i846tNR0JqEIbb6YjHPrnxw5bOI UwJN6HGKi+dzUoIiqCBYQx+JY/14CyOoHwqDv01gRr5pOWJYBQ0HYq8U4Qrrp7BCjkPL sFw04VwsNJmtqvKPtd3ZTn4adXnEm1d2WnylaGbbuV8N2ssEAjH5tNVEodgrP+ykRrKM RVfwRKYUADHAdUd36rJdv0UOHRG7t6eFtw32mHMZSC+5dgayyui6NQTKDmd6HRv76h3/ qALA== X-Gm-Message-State: AOAM5312CkqCa5Mv4NNj0bn9ucWdz+zE7PbFFNR85PnWR2nLN0uKLu1m nLRrWaHwIC3BqynQyGUqDmNP3e3MDXo6kQ== X-Received: by 2002:a0c:cd05:0:b0:443:cd52:7829 with SMTP id b5-20020a0ccd05000000b00443cd527829mr399048qvm.98.1649087560944; Mon, 04 Apr 2022 08:52:40 -0700 (PDT) Received: from mail-yb1-f169.google.com (mail-yb1-f169.google.com. [209.85.219.169]) by smtp.gmail.com with ESMTPSA id u62-20020a379241000000b0067ed2b0994dsm6592293qkd.54.2022.04.04.08.52.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 04 Apr 2022 08:52:40 -0700 (PDT) Received: by mail-yb1-f169.google.com with SMTP id d138so10015512ybc.13; Mon, 04 Apr 2022 08:52:40 -0700 (PDT) X-Received: by 2002:a25:c049:0:b0:634:6751:e8d2 with SMTP id c70-20020a25c049000000b006346751e8d2mr437586ybf.6.1649087560296; Mon, 04 Apr 2022 08:52:40 -0700 (PDT) MIME-Version: 1.0 References: <20220404084723.79089-1-zheyuma97@gmail.com> <20220404084723.79089-8-zheyuma97@gmail.com> In-Reply-To: <20220404084723.79089-8-zheyuma97@gmail.com> From: Geert Uytterhoeven Date: Mon, 4 Apr 2022 17:52:29 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 7/7] video: fbdev: s3fb: Error out if 'pixclock' equals zero To: Zheyu Ma Cc: Helge Deller , Linux Fbdev development list , DRI Development , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, 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 Mon, Apr 4, 2022 at 3:50 PM Zheyu Ma wrote: > The userspace program could pass any values to the driver through > ioctl() interface. If the driver doesn't check the value of 'pixclock', > it may cause divide error. > > Fix this by checking whether 'pixclock' is zero in s3fb_check_var(). > > The following log reveals it: > > [ 511.141561] divide error: 0000 [#1] PREEMPT SMP KASAN PTI > [ 511.141607] RIP: 0010:s3fb_check_var+0x3f3/0x530 > [ 511.141693] Call Trace: > [ 511.141695] > [ 511.141716] fb_set_var+0x367/0xeb0 > [ 511.141815] do_fb_ioctl+0x234/0x670 > [ 511.141876] fb_ioctl+0xdd/0x130 > [ 511.141888] do_syscall_64+0x3b/0x90 > > Signed-off-by: Zheyu Ma > --- > drivers/video/fbdev/s3fb.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/video/fbdev/s3fb.c b/drivers/video/fbdev/s3fb.c > index 5c74253e7b2c..b93c8eb02336 100644 > --- a/drivers/video/fbdev/s3fb.c > +++ b/drivers/video/fbdev/s3fb.c > @@ -549,6 +549,9 @@ static int s3fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) > int rv, mem, step; > u16 m, n, r; > > + if (!var->pixclock) > + return -EINVAL; > + When passed an invalid value, .check_var() is supposed to round up the invalid value to a valid value, if possible. > /* Find appropriate format */ > rv = svga_match_format (s3fb_formats, var, NULL); 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