Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3532534pxb; Mon, 4 Apr 2022 20:11:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwghmj3ze3+8gOZjUVk7fMoXF3teKhYIDHOXe9rSCmO8gZe/qfbZ2tmcxjhZ6QJ6U4NU2WQ X-Received: by 2002:a17:902:db0f:b0:156:9c3f:9dc6 with SMTP id m15-20020a170902db0f00b001569c3f9dc6mr1261708plx.113.1649128267436; Mon, 04 Apr 2022 20:11:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649128267; cv=none; d=google.com; s=arc-20160816; b=ZtjYQ5vbZN10ySAdbhWtl6azdCCnldm2ARcZDMA7HjQ93lELAQsgI48c964+rD25ln 03L4Jlkmb5lzwSE2MTZFjQ2GzZxfHdstpETdttU2GLUG3xvLxsJawueIfyVR7LkvP6Ho 2Sbb+qVmGNQlDaJhiFmhPYHE3p7x2tmyTjrMGTXPHBxWPccKaIcqxkzxZ7AOj2WLevaJ fcM/eksYBSOl1L1D0v0Cpog0/LlOdco3FTw3TSYEspFDojK4GMvalpLGzZXHqGOImr0u fMC3HMiT2Ryio44qjVpeFdsOzI0FGT2pMMQY9UOkmD8yWu+cTMCb9sY8MOCLGkqGQdnl 9vQw== 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=o3vs63IC1K0uTiORv1QjqWD3HYAAr5eIqR2CDFPF9J0=; b=paHuRXf7YW7T/TsWT0trXb3shCQ+fVS5NqpmbQIGsyiA0QLgs/pToyPwUi4YeK6Vou IDcsT0Z2w0S2Q3at7BpKXrpmD3QkeDsD8KH+ndDlX9MWzg3aQS9alL7SIyA1nwLhZfYh sunbvkuoELW/IX7PPhN0mGKW1TOUO/rZDX27Mr7Wnp5Ry7uYo7+Ja+5IXyatqjpgL8+i ISCSFGpglKT1TxQ3+ApWxQpYJJxH49YySFiSCMtC0O8aWv4K/5nIRFGdIx6TKng1OcyB HLGmxBwQM+vsQtEh7XrAaiUW6/2smZPXKObIFqXgEqLcvWAMtLr92DnOGoV71nd77h5v h/0A== 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 w21-20020a17090a529500b001bd14e0306csi940137pjh.68.2022.04.04.20.11.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 20:11:07 -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 4E41D3B1B17; Mon, 4 Apr 2022 18:11:31 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378733AbiDDPyT (ORCPT + 99 others); Mon, 4 Apr 2022 11:54:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357418AbiDDPyO (ORCPT ); Mon, 4 Apr 2022 11:54:14 -0400 Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D69944248A; Mon, 4 Apr 2022 08:52:18 -0700 (PDT) Received: by mail-qv1-f47.google.com with SMTP id kc20so7782720qvb.3; Mon, 04 Apr 2022 08:52:18 -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=o3vs63IC1K0uTiORv1QjqWD3HYAAr5eIqR2CDFPF9J0=; b=bs8HT2woZ9zZUjvs+v0jgUzAjNHMF2DxTJa2qCzwhenqWvYnBCvm/d05RcQOchrTzl FFTZZASiESxHBtxy2KGj8NvQSyVcnofSaa7QlEAV6yzkOXEk/LGFGOtLW2kjTScMzACY 1C++IkdDZBBgyCNIdLqqVrWpVLK6x24UuCpTid2N2vvg1G8rwXMmSGegLsr5kbZcry3j SpkLWAG6dTFvoICIkECpnh3tIeTAJDy3orhLIGeZ1HHRuYfFKMELmi+fh1io10SsB8m0 CHqZs65l2jIGnoEcso9GKG6emUQEhNpDmeXPePoLfNFrmKVvEDJ0rAUNBDSrDJY89n+h VTGA== X-Gm-Message-State: AOAM530DH8+PaDKYyESL8Ik9SBoMUgAiCJL5nmJmzOQ+0tEMp1HPNf3a 7ldxfC13FCFLnybt+bVLPDnv1qfaZEZbUQ== X-Received: by 2002:a0c:bf12:0:b0:42c:536d:52d7 with SMTP id m18-20020a0cbf12000000b0042c536d52d7mr183374qvi.33.1649087537741; Mon, 04 Apr 2022 08:52:17 -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 o28-20020a05620a111c00b0067d3b9ef388sm6219572qkk.98.2022.04.04.08.52.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 04 Apr 2022 08:52:17 -0700 (PDT) Received: by mail-yb1-f169.google.com with SMTP id w134so10564401ybe.10; Mon, 04 Apr 2022 08:52:17 -0700 (PDT) X-Received: by 2002:a25:45:0:b0:633:96e2:2179 with SMTP id 66-20020a250045000000b0063396e22179mr386892yba.393.1649087536915; Mon, 04 Apr 2022 08:52:16 -0700 (PDT) MIME-Version: 1.0 References: <20220404084723.79089-1-zheyuma97@gmail.com> <20220404084723.79089-7-zheyuma97@gmail.com> In-Reply-To: <20220404084723.79089-7-zheyuma97@gmail.com> From: Geert Uytterhoeven Date: Mon, 4 Apr 2022 17:52:05 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 6/7] video: fbdev: arkfb: 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:10 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. > > The following log reveals it: > > [ 76.603696] divide error: 0000 [#1] PREEMPT SMP KASAN PTI > [ 76.603712] RIP: 0010:arkfb_set_par+0x10fc/0x24f0 > [ 76.603762] Call Trace: > [ 76.603764] > [ 76.603773] fb_set_var+0x604/0xeb0 > [ 76.603827] do_fb_ioctl+0x234/0x670 > [ 76.603873] fb_ioctl+0xdd/0x130 > [ 76.603881] do_syscall_64+0x3b/0x90 > > Signed-off-by: Zheyu Ma Thanks for your patch! > --- a/drivers/video/fbdev/arkfb.c > +++ b/drivers/video/fbdev/arkfb.c > @@ -566,6 +566,9 @@ static int arkfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) > { > int rv, mem, step; > > + if (!var->pixclock) > + return -EINVAL; When passed an invalid value, .check_var() is supposed to round up the invalid to a valid value, if possible. > + > /* Find appropriate format */ > rv = svga_match_format (arkfb_formats, var, NULL); > if (rv < 0) 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