Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp75933pxh; Thu, 7 Apr 2022 14:28:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxifyhMvqo7PdNpDVCaC98PaJfpYWwZlL0upO5zeqtL2akyK9rcUlgXVEOddcZeHYF/41pv X-Received: by 2002:a63:5c5c:0:b0:382:2812:9d9d with SMTP id n28-20020a635c5c000000b0038228129d9dmr12744059pgm.227.1649366890813; Thu, 07 Apr 2022 14:28:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649366890; cv=none; d=google.com; s=arc-20160816; b=K+uB7DJjtu8aofgpxgoj6fOBg88pkK16lBFXeJor9s/GS8anj38yzCo2ZGP/ezVCys 4lgKC16SdPHdLFhKJfs8JC+vBOW+Ro37JxUfuWJOTEFPjGMC9NDs1JGceiZwIwCrYl7M cpI83VN3J/hEDCyKKGnUaJBwzrMW/d78SiouNvZ2PAWZAwLqpfjDhPrvkntdWdofF0D8 Yyncb3vSfah9UOKNIpJCdQofnVTBfU7+gOclTm3oR3LjgSE1O098dCrhiWi4Thv/ScNJ Z8sU5IIg3Muq98fOWM7XneOALssX83JaQVhWDrn26fX79SUP/pc7peCMiTkHBR/Vk/Tg svwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=OvSHDVeiz4YIVUm7ZirDesvzCDfddBaDyTUusAPDLRo=; b=vLysC+qzN8TsSlIN+CljFZQebb7SJVXh7t5AMEmZAbXeKKDgTGzg538lOy5GP+NTR/ SxWZKZwao2rKUkiwlCAUdORqOZV9TX0feak3CNWGQGiNb6S1o7Pld61DB6hr3/xQdMXy d91Lm8wBYgsZPiqTyzESbnYl8nuGaHNwkSm/j8u+cxCir9FnXHsbe3q6aCwj7eDFdOI9 kB8iHvYo2+AMolyVQB9/7QK4ODbLe2Yg5/SaLbjeNEUKmaomgtshmymoSXuDGPwOs7eU Cn/VX/EtHgm6nPYu55qWeDmhBNfVSNqMcPfZ9B19/whw/uose8r4x61djyPLx7NqJw1s V28g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=YMpmWNQm; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id h2-20020a170902f54200b00156af8ef4d0si998515plf.8.2022.04.07.14.28.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 14:28:10 -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; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=YMpmWNQm; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E99144739E2; Thu, 7 Apr 2022 13:29:06 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229669AbiDGUa7 (ORCPT + 99 others); Thu, 7 Apr 2022 16:30:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229677AbiDGUac (ORCPT ); Thu, 7 Apr 2022 16:30:32 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 236462E0F33; Thu, 7 Apr 2022 13:14:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1649362493; bh=N6/FEyVpcVAz4B+dz6VLJs5njSr6wfG1FKLDFl/Zz78=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=YMpmWNQm2OdUv19j7O4H83V2BjrmoSr3pRMxdw1SfkJ3AGeFUf4uHe1sHid2daq2o MCJsEn+j5zXjz4e0B8G+2gtdKQUlvAk5eGbMl5sxCxSkTPmQxbEwXCiv+DcQGZWfFx eKCz04B9QadiWiTAqWhPvmj2Q2Q9A0DrNwHRwTLY= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.20.60] ([92.116.161.122]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M2f9h-1nYRQ20Y2B-004BOi; Thu, 07 Apr 2022 21:50:45 +0200 Message-ID: Date: Thu, 7 Apr 2022 21:49:03 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH 1/7] video: fbdev: i740fb: Error out if 'pixclock' equals zero Content-Language: en-US To: Zheyu Ma Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20220404084723.79089-1-zheyuma97@gmail.com> <20220404084723.79089-2-zheyuma97@gmail.com> From: Helge Deller In-Reply-To: <20220404084723.79089-2-zheyuma97@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:XxvmZy8oYHEoPKTe6X2SYk0Pjr8XeAjoK1SV6d6GPPRKYzfl92j 4mENiOhlREipIcFBpaEyuyq4T/upzS8fU2vT8q0RJJMgI4yc5/vQWvP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ThZEDdG7pjtjpvK5Lk/BNHkPw0KhHYDoYj28aSjhT2TTUmNzvFmhs99o9NvN roAbtOu6kSSD6ZeHx4o/WZWodgqZUPhm3ISR+tAN0lfp6y3CIsxEWtRdZcLzz2eWrW2gL4V/E mPkvD/BsdgCyAZLr4VSMRGAXSBGNREnVRlhKQOxDMB4TG5HbaIw9kTA3pFFt50I+ymySWddLx wRRGTCsjSDu2Nc= X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 4/4/22 10:47, 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 the function > i740fb_check_var(). > > The following log reveals it: > > divide error: 0000 [#1] PREEMPT SMP KASAN PTI > RIP: 0010:i740fb_decode_var drivers/video/fbdev/i740fb.c:444 [inline] > RIP: 0010:i740fb_set_par+0x272f/0x3bb0 drivers/video/fbdev/i740fb.c:739 > Call Trace: > fb_set_var+0x604/0xeb0 drivers/video/fbdev/core/fbmem.c:1036 > do_fb_ioctl+0x234/0x670 drivers/video/fbdev/core/fbmem.c:1112 > fb_ioctl+0xdd/0x130 drivers/video/fbdev/core/fbmem.c:1191 > vfs_ioctl fs/ioctl.c:51 [inline] > __do_sys_ioctl fs/ioctl.c:874 [inline] > > Signed-off-by: Zheyu Ma Hello Zheyu, I've applied the patches #2-#7 of this series, but left out this specific patch (for now). As discussed on the mailing list we can try to come up with a better fix (to round up the pixclock when it's invalid). If not, I will apply this one later. Thanks! Helge > --- > drivers/video/fbdev/i740fb.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/video/fbdev/i740fb.c b/drivers/video/fbdev/i740fb.c > index 52cce0db8bd3..b595437a5752 100644 > --- a/drivers/video/fbdev/i740fb.c > +++ b/drivers/video/fbdev/i740fb.c > @@ -657,6 +657,9 @@ static int i740fb_decode_var(const struct fb_var_scr= eeninfo *var, > > static int i740fb_check_var(struct fb_var_screeninfo *var, struct fb_in= fo *info) > { > + if (!var->pixclock) > + return -EINVAL; > + > switch (var->bits_per_pixel) { > case 8: > var->red.offset =3D var->green.offset =3D var->blue.offset =3D 0;