Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2319687pxb; Mon, 20 Sep 2021 18:43:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxM+sOs9daP5Jw48tbc8tK3fxqdmgXWD4mOQvx8qkEVLW1eEeOztSnptE30Y/RYAg/zG59i X-Received: by 2002:a05:6e02:4a3:: with SMTP id e3mr20143085ils.229.1632188581244; Mon, 20 Sep 2021 18:43:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632188581; cv=none; d=google.com; s=arc-20160816; b=MXBvGhZNbCzQxwpoPyIUQqko268cObe0iYSnRpDHm7TEBP6IdlzNLqF27Oa9VW8p6z MTUdU1q2GAa3aWPCPVPhVm80kTfRE7lvRIVhnLzxy40aB5l12WHyLiRmBjXK528lQatd fCmQif2S5XrG/E+Uvi9hskT8Ym86L3DIK2ryb7p5h0I84WgQOmU5hXZzycR890vHXdtJ jk16UN1IdfLe6vsoUbCuNl4RsAOyR63EW0mqMR2MLO3vLtj/+VE+PXVueIXSq8LLe5Yd 2wUZPhnB3h4tvw6XoJxiJ8sUgyQk32E7pCddapRACMUOV8luwHfVqy2CaFE0dGsNW/Jk MTGg== 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=hq5uB2C6+5lgX29K0l0rSmfjn9YtkybAvR3R5qpsoSM=; b=pDSYkeu23lMQGP7p44bP9KIyTq2X6ksEFi7Uv21FTwMrwfhLQARWTt8L0jszfJqO5O Be0ah7Pp4hSqEZw9XR6wbkY7QGepil+opL03ugc+/k570WCxOfJtxUH1dVhobC2cZBZ8 j7BzYr9uz5txU9Bahhg2jwryePVXZpNrZgmqlUh81Chbs8Ib98RDEzWVdVS1lOgqpEi4 CgLxlePX8P6reXH7125BrqY9+fFZF6QrbSU23DgfJW32aL1XG3UPo3k7SIH08yIQGYzr dwl3FniNIp9wB4sIRPMx+L5s001kwgKctBNNlUw/qEiIseagVS7UszKMknKRLvDoMMy3 sZLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jNPv+d71; 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 z10si13733344ioe.51.2021.09.20.18.42.49; Mon, 20 Sep 2021 18:43:01 -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=jNPv+d71; 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 S245494AbhITQ4S (ORCPT + 99 others); Mon, 20 Sep 2021 12:56:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:38940 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245170AbhITQwh (ORCPT ); Mon, 20 Sep 2021 12:52:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 190BE6135D; Mon, 20 Sep 2021 16:49:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632156593; bh=C3nxF9C0LRqhRKmcv6kauwSpJt/jKqNfSJ8xLxPHwQs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jNPv+d71no0OdvJsdKjFwJNsE1dxMH5HObeQv0GSfAFqA+j+l586leMDYTaQHaMWd bgbyjSIzwSBIZj5XL++5Z78Us5DVoxFNhpLDhfQv2hemG8GhLU6J7XDzjmp4CObeqE CawKV4zZEvwKVCLZbzrYBorOdECAwSpu9VQgpyPU= 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 4.4 097/133] video: fbdev: kyro: Error out if pixclock equals zero Date: Mon, 20 Sep 2021 18:42:55 +0200 Message-Id: <20210920163915.806698691@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163912.603434365@linuxfoundation.org> References: <20210920163912.603434365@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 1520b4b7ba964f8eec2e7dd14c571d50de3e5191 ] 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 because the value of 'lineclock' and 'frameclock' will be zero. Fix this by checking whether 'pixclock' is zero in kyrofb_check_var(). The following log reveals it: [ 103.073930] divide error: 0000 [#1] PREEMPT SMP KASAN PTI [ 103.073942] CPU: 4 PID: 12483 Comm: syz-executor Not tainted 5.14.0-rc2-00478-g2734d6c1b1a0-dirty #118 [ 103.073959] RIP: 0010:kyrofb_set_par+0x316/0xc80 [ 103.074045] Call Trace: [ 103.074048] ? ___might_sleep+0x1ee/0x2d0 [ 103.074060] ? kyrofb_ioctl+0x330/0x330 [ 103.074069] fb_set_var+0x5bf/0xeb0 [ 103.074078] ? fb_blank+0x1a0/0x1a0 [ 103.074085] ? lock_acquire+0x3bd/0x530 [ 103.074094] ? lock_release+0x810/0x810 [ 103.074103] ? ___might_sleep+0x1ee/0x2d0 [ 103.074114] ? __mutex_lock+0x620/0x1190 [ 103.074126] ? trace_hardirqs_on+0x6a/0x1c0 [ 103.074137] do_fb_ioctl+0x31e/0x700 [ 103.074144] ? fb_getput_cmap+0x280/0x280 [ 103.074152] ? rcu_read_lock_sched_held+0x11/0x80 [ 103.074162] ? rcu_read_lock_sched_held+0x11/0x80 [ 103.074171] ? __sanitizer_cov_trace_switch+0x67/0xf0 [ 103.074181] ? __sanitizer_cov_trace_const_cmp2+0x20/0x80 [ 103.074191] ? do_vfs_ioctl+0x14b/0x16c0 [ 103.074199] ? vfs_fileattr_set+0xb60/0xb60 [ 103.074207] ? rcu_read_lock_sched_held+0x11/0x80 [ 103.074216] ? lock_release+0x483/0x810 [ 103.074224] ? __fget_files+0x217/0x3d0 [ 103.074234] ? __fget_files+0x239/0x3d0 [ 103.074243] ? do_fb_ioctl+0x700/0x700 [ 103.074250] fb_ioctl+0xe6/0x130 Signed-off-by: Zheyu Ma Signed-off-by: Sam Ravnborg Link: https://patchwork.freedesktop.org/patch/msgid/1627293835-17441-3-git-send-email-zheyuma97@gmail.com Signed-off-by: Sasha Levin --- drivers/video/fbdev/kyro/fbdev.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/video/fbdev/kyro/fbdev.c b/drivers/video/fbdev/kyro/fbdev.c index 8482444259ce..d98c3f5d80df 100644 --- a/drivers/video/fbdev/kyro/fbdev.c +++ b/drivers/video/fbdev/kyro/fbdev.c @@ -399,6 +399,9 @@ static int kyrofb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) { struct kyrofb_info *par = info->par; + if (!var->pixclock) + return -EINVAL; + if (var->bits_per_pixel != 16 && var->bits_per_pixel != 32) { printk(KERN_WARNING "kyrofb: depth not supported: %u\n", var->bits_per_pixel); return -EINVAL; -- 2.30.2