Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp5427183pxu; Thu, 22 Oct 2020 01:51:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzz8PeURYWZI9a8azDTvng51kHvUSok9dLKOyCvzsEZd+WeaNjhS0HqYJ0BoIS9ODZ5e6NE X-Received: by 2002:aa7:d783:: with SMTP id s3mr1289927edq.214.1603356693528; Thu, 22 Oct 2020 01:51:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603356693; cv=none; d=google.com; s=arc-20160816; b=huycUVmLppOvvA3pG+3WWqwCdsXekz86aUOZtKRXwmxk+XrCaLtyDsi3EY+EyrHSZu CISDgowyuF+w2fMqwkVgjxuNVys6QMyTSJ5WryZ4dFuHki25hrCHgqkcI+bgORyS9wiA z06FkZweEvl+RVUWiIpGBrISRKkQfkCUci2JZCDlx00BoK2lWdhoazXpH0zIkXYy+ODK J+UWmRmXwjucq8RB66oKmd8UCWLqKUOMrYyz0MsGu1NW85xb5XPMoHPAwTtZgXYPBNN0 IyX4NBgMuvCfgNQWWdFx3U/uuhZPVHpfcI+r5aVJDK5fwaqdOAhwh5Y7YLQbWi37u0Gn dvTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=pn1eFgXrcB4fX3bYnAPz4boUGYxziv1VzraeZVKPKf8=; b=pZEfsKA2hdd03nk9PU0Hmur7TXuBh9Vt4SMTGLsZ/UUBSempMUyrpn+uY0FQNTWarR 4ryG3dAQRnJaSpjG12mEE4y6Vn2pRbI5Tr10cZ+Uv0TZ6xpOEd+SOPvW/yNgAL8gDJaz A3k1IzEFUz6hB+/BbuKeFPO10Jtsc4ycv4QM5BvPWBy1PAkJ1aSTD3+ElP8aGTWxfZKs uW0UP3kgHQxZ4zIlFBQGGF7J4UWkebVL5tgmcYhrlqnTlpmn0I43qZeJhGge1Os9y8L0 8CSoo6lGtbDRrajnehzYwuIYZ0i2CLNcENPezPqSkJ5PLbLrB5hzTjGMOkU7ZlKtzIlf 98pA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l90si478001edl.249.2020.10.22.01.51.11; Thu, 22 Oct 2020 01:51:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2508584AbgJVHeP (ORCPT + 99 others); Thu, 22 Oct 2020 03:34:15 -0400 Received: from mx2.suse.de ([195.135.220.15]:59490 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2506555AbgJVHeO (ORCPT ); Thu, 22 Oct 2020 03:34:14 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id B6DC5B195; Thu, 22 Oct 2020 07:34:12 +0000 (UTC) Subject: Re: [PATCH 1/1] video: fbdev: fix divide error in fbcon_switch To: saeed.mirzamohammadi@oracle.com, linux-kernel@vger.kernel.org Cc: linux-fbdev@vger.kernel.org, b.zolnierkie@samsung.com, jani.nikula@intel.com, daniel.vetter@ffwll.ch, gustavoars@kernel.org, dri-devel@lists.freedesktop.org, akpm@linux-foundation.org, rppt@kernel.org References: <20201021235758.59993-1-saeed.mirzamohammadi@oracle.com> From: Thomas Zimmermann Message-ID: Date: Thu, 22 Oct 2020 09:34:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.2 MIME-Version: 1.0 In-Reply-To: <20201021235758.59993-1-saeed.mirzamohammadi@oracle.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi On 22.10.20 01:57, saeed.mirzamohammadi@oracle.com wrote: > From: Saeed Mirzamohammadi > > This patch fixes the issue due to: > > [ 89.572883] divide_error: 0000 [#1] SMP KASAN PTI > [ 89.572897] CPU: 3 PID: 16083 Comm: repro Not tainted 5.9.0-rc7.20200930.rc1.allarch-19-g3e32d0d.syzk #5 > [ 89.572902] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 0.5.1 01/01/2011 > [ 89.572934] RIP: 0010:cirrusfb_check_var+0x84/0x1260 BTW, if you run qemu with cirrus, there's also a DRM driver named cirrus.ko. Might be a better choice than the old fbdev driver. If you just care about qemu, but not the actual graphics device, take a look at https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/ Anyway, thanks for your patch. Best regards Thomas > > The error happens when the pixels value is calculated before performing the sanity checks on bits_per_pixel. > A bits_per_pixel set to zero causes divide by zero error. > > This patch moves the calculation after the sanity check. > > Signed-off-by: Saeed Mirzamohammadi > Tested-by: Saeed Mirzamohammadi > --- > drivers/video/fbdev/cirrusfb.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/video/fbdev/cirrusfb.c b/drivers/video/fbdev/cirrusfb.c > index 15a9ee7cd734..a7749101b094 100644 > --- a/drivers/video/fbdev/cirrusfb.c > +++ b/drivers/video/fbdev/cirrusfb.c > @@ -531,7 +531,7 @@ static int cirrusfb_check_var(struct fb_var_screeninfo *var, > { > int yres; > /* memory size in pixels */ > - unsigned pixels = info->screen_size * 8 / var->bits_per_pixel; > + unsigned int pixels; > struct cirrusfb_info *cinfo = info->par; > > switch (var->bits_per_pixel) { > @@ -573,6 +573,7 @@ static int cirrusfb_check_var(struct fb_var_screeninfo *var, > return -EINVAL; > } > > + pixels = info->screen_size * 8 / var->bits_per_pixel; > if (var->xres_virtual < var->xres) > var->xres_virtual = var->xres; > /* use highest possible virtual resolution */ > -- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Felix Imendörffer