Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1682299pxb; Thu, 16 Sep 2021 12:52:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIS94sgBhFqdwtKXlfBBeeBpN+89DNLz5uZyR6P87ygpwL2SNjNWvkY/GV9tw2g/0LJeUo X-Received: by 2002:a05:6e02:1d8b:: with SMTP id h11mr4870915ila.94.1631821936130; Thu, 16 Sep 2021 12:52:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631821936; cv=none; d=google.com; s=arc-20160816; b=JLoTmF+/5AC4Z2Eym1vOsyRKX/VhSok2Lv/dq4FOAR+nF6lziD9xaBOayhVLmCvvmZ n0M1K1Uyy/FNaFYkAy4jx08H4aQXw4hJ8E2G15Qsw9Ds9hPGm4m9CvUzUQbg0qpWOFYc NZlfUQHlQ7hRx3rKJaQQMWfzTP5iSJPZVEJRaJ91NdUVYrEe06JTsXqdjIdOrdSGx4JL nXtm00Ko7bYurT1/3ezeETFbXdVXrPe2/S0WMqUpBxOBHgrYf367bIQDbsTNjofyeFND doksNzRLELhS5+YFvql58u8aKuFvqg3eSlmV5kN3eMX5EhpCgzJ0upTG61ac2H/gq0yQ WMqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZnA7J0jGDMTcWTEBQPzBGi5ikyEFYA5nzreyxXV7bkw=; b=P0fMcUP23ok9Q+v8AvQxiLNsOKGwfaawLjRra1MYipOA5c6KU7KgagKzQh1Vx9EwzE OSljYVuXN+K1ggfElf2pDoFgGUW031+0+qVX/Cl/IV1oD2HIqfOb6MiqX2FCIw6JQ3NM r6/3jeqG6TQ8LKJ0TBCmbw79t6w2zmlwmIZpk8Qg1NzOr+e0tsUZ4AlxVeRC8qioWgDO 9yRPZSce2XSN4AOCX8fPj8Ql12xl8OSJN2Fx9hg4+13m9re2kdWTQZ4R+EHOwgO93IFO 2YOQi/9Ht74KdYxlW3H42SpFdIFy2oGVPCFeQ1rj/wiivYjq0jQsmssoRjZvbuSmY4bA BYXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=N6ksJeps; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x19si3171299ilc.166.2021.09.16.12.52.00; Thu, 16 Sep 2021 12:52:16 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=N6ksJeps; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241822AbhIPQWJ (ORCPT + 99 others); Thu, 16 Sep 2021 12:22:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:49144 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233284AbhIPQNj (ORCPT ); Thu, 16 Sep 2021 12:13:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8B67D6137D; Thu, 16 Sep 2021 16:10:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631808602; bh=CFxoJqTD6D2XgEUt9WJ2SR1eXohXAMMWRfLmxb/Gz8Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N6ksJepscFFL9IrVPxmngx3g0YPdWaIYvR1wfNnKUYvEBCS30NoiCr/9bUyizY5DR YcFZ3eZhUHbdlDmgZfsXH1Wx0CyPPh1zf0+tFYEf9j1o9tu3Hy9sZS+DCotSux756u gQIA04hFjmbvgP8dlACnRk9WRwtFTSl1zLDIER9A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zheyu Ma , Sam Ravnborg , Sasha Levin Subject: [PATCH 5.10 154/306] video: fbdev: asiliantfb: Error out if pixclock equals zero Date: Thu, 16 Sep 2021 17:58:19 +0200 Message-Id: <20210916155759.339526829@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155753.903069397@linuxfoundation.org> References: <20210916155753.903069397@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zheyu Ma [ Upstream commit b36b242d4b8ea178f7fd038965e3cac7f30c3f09 ] 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 first. The following log reveals it: [ 43.861711] divide error: 0000 [#1] PREEMPT SMP KASAN PTI [ 43.861737] CPU: 2 PID: 11764 Comm: i740 Not tainted 5.14.0-rc2-00513-gac532c9bbcfb-dirty #224 [ 43.861756] RIP: 0010:asiliantfb_check_var+0x4e/0x730 [ 43.861843] Call Trace: [ 43.861848] ? asiliantfb_remove+0x190/0x190 [ 43.861858] fb_set_var+0x2e4/0xeb0 [ 43.861866] ? fb_blank+0x1a0/0x1a0 [ 43.861873] ? lock_acquire+0x1ef/0x530 [ 43.861884] ? lock_release+0x810/0x810 [ 43.861892] ? lock_is_held_type+0x100/0x140 [ 43.861903] ? ___might_sleep+0x1ee/0x2d0 [ 43.861914] ? __mutex_lock+0x620/0x1190 [ 43.861921] ? do_fb_ioctl+0x313/0x700 [ 43.861929] ? mutex_lock_io_nested+0xfa0/0xfa0 [ 43.861936] ? __this_cpu_preempt_check+0x1d/0x30 [ 43.861944] ? _raw_spin_unlock_irqrestore+0x46/0x60 [ 43.861952] ? lockdep_hardirqs_on+0x59/0x100 [ 43.861959] ? _raw_spin_unlock_irqrestore+0x46/0x60 [ 43.861967] ? trace_hardirqs_on+0x6a/0x1c0 [ 43.861978] do_fb_ioctl+0x31e/0x700 Signed-off-by: Zheyu Ma Signed-off-by: Sam Ravnborg Link: https://patchwork.freedesktop.org/patch/msgid/1627293835-17441-2-git-send-email-zheyuma97@gmail.com Signed-off-by: Sasha Levin --- drivers/video/fbdev/asiliantfb.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/video/fbdev/asiliantfb.c b/drivers/video/fbdev/asiliantfb.c index 3e006da47752..84c56f525889 100644 --- a/drivers/video/fbdev/asiliantfb.c +++ b/drivers/video/fbdev/asiliantfb.c @@ -227,6 +227,9 @@ static int asiliantfb_check_var(struct fb_var_screeninfo *var, { unsigned long Ftarget, ratio, remainder; + if (!var->pixclock) + return -EINVAL; + ratio = 1000000 / var->pixclock; remainder = 1000000 % var->pixclock; Ftarget = 1000000 * ratio + (1000000 * remainder) / var->pixclock; -- 2.30.2