Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2320057pxb; Mon, 20 Sep 2021 18:43:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw28WaMrPj9GnQjJn/nYKAzCZ/pCotZdzcmALUbjqVsPPht/ZjG9qyJC00v60OCo0EhzdfS X-Received: by 2002:a05:6638:42:: with SMTP id a2mr17482457jap.69.1632188616431; Mon, 20 Sep 2021 18:43:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632188616; cv=none; d=google.com; s=arc-20160816; b=dy8vPET1vF/x6AKdqjkY4IcHxUwLQ3t1bnUnmWT7eIxjvYLUhl/qqdvRQWPu8O3Fsy fjzFarqfMV7Yd4J1hiIFONRJffwTIIRHXdqu/D32ZdOeR6cKLn8DMHJS63J9KmbELZM4 b/cF6ZrOSCAcZ4IppshqlGjfvnryIqGjm9VpYEeRvGePGh1CFlvIG35m3liz5I7UYn7F RODv47cNgjuoy8CilGKIXD47iDDmDgz+TZ/IF7Lwvj0yla8s2dOPH//U0sVWndJQF8/R vGGhO1X9xA4LN/1QpvfdvgcxkgFH5bi5GTgSWG9sruZSfti5ZKBUxfBbGXFvJMqZa+48 KHdQ== 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=A8eA0HWIDis0Z3hvcHpTYMnKIIEkgajmAluCCzVRStg=; b=mgJoLLmiQd+BY54agjzpk0ndEsWFjnczzusvc01ERKajdgakcadAwrX3JS9qIoOg3r LzE1WpVaD/Jn882urHMnd35P2Ia2hUzedIcXfgBeKEXUw6FmNx9QASteS9bB80JpbUl3 +O2Z2RcYvxnVCiFdAXbUe5sVc88W8z+oM2IJN6bez/3BA0xPK9pQVbOsVpMer8RE2nJI V/U+JXW9Ob0C6mSEJRg9eYDhFgCTaALY5hX6EmNiXNAOPn9qw99qzQdpRvVj7ryKJ1LW RRThC6oThdI2KOvZ3IuzGhU1sOsG7mHkbGHzwb2Sy7EwqRR/luTfH1fKvGHeROCVP6xa 2Wgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PZL7UyTL; 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 e46si13135691jaf.50.2021.09.20.18.43.25; Mon, 20 Sep 2021 18:43:36 -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=PZL7UyTL; 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 S245551AbhITQ4U (ORCPT + 99 others); Mon, 20 Sep 2021 12:56:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:38968 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245176AbhITQwh (ORCPT ); Mon, 20 Sep 2021 12:52:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3E7B261362; Mon, 20 Sep 2021 16:49:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632156595; bh=P2dWfA3+6h1FBHe0VI/ugsM4VtXffXqmR7Mk0eeENhk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PZL7UyTLJJin28gfhYTzfvLF7I3qzcnsMh9LrHLcKAMrefUbXm18ExQb0iWs33B6t +aHFmWRScCz4NfIQUN6hs+m92PbkF5o/eBtIzZRk1g7Q958Ri39Zl/67SqZb2wBExE CAm2tLWqfQEJIlxze7NbMPd40Rd2Vy/Ch8mEnU8Y= 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 098/133] video: fbdev: riva: Error out if pixclock equals zero Date: Mon, 20 Sep 2021 18:42:56 +0200 Message-Id: <20210920163915.837437047@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 f92763cb0feba247e0939ed137b495601fd072a5 ] 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: [ 33.396850] divide error: 0000 [#1] PREEMPT SMP KASAN PTI [ 33.396864] CPU: 5 PID: 11754 Comm: i740 Not tainted 5.14.0-rc2-00513-gac532c9bbcfb-dirty #222 [ 33.396883] RIP: 0010:riva_load_video_mode+0x417/0xf70 [ 33.396969] Call Trace: [ 33.396973] ? debug_smp_processor_id+0x1c/0x20 [ 33.396984] ? tick_nohz_tick_stopped+0x1a/0x90 [ 33.396996] ? rivafb_copyarea+0x3c0/0x3c0 [ 33.397003] ? wake_up_klogd.part.0+0x99/0xd0 [ 33.397014] ? vprintk_emit+0x110/0x4b0 [ 33.397024] ? vprintk_default+0x26/0x30 [ 33.397033] ? vprintk+0x9c/0x1f0 [ 33.397041] ? printk+0xba/0xed [ 33.397054] ? record_print_text.cold+0x16/0x16 [ 33.397063] ? __kasan_check_read+0x11/0x20 [ 33.397074] ? profile_tick+0xc0/0x100 [ 33.397084] ? __sanitizer_cov_trace_const_cmp4+0x24/0x80 [ 33.397094] ? riva_set_rop_solid+0x2a0/0x2a0 [ 33.397102] rivafb_set_par+0xbe/0x610 [ 33.397111] ? riva_set_rop_solid+0x2a0/0x2a0 [ 33.397119] fb_set_var+0x5bf/0xeb0 [ 33.397127] ? fb_blank+0x1a0/0x1a0 [ 33.397134] ? lock_acquire+0x1ef/0x530 [ 33.397143] ? lock_release+0x810/0x810 [ 33.397151] ? lock_is_held_type+0x100/0x140 [ 33.397159] ? ___might_sleep+0x1ee/0x2d0 [ 33.397170] ? __mutex_lock+0x620/0x1190 [ 33.397180] ? trace_hardirqs_on+0x6a/0x1c0 [ 33.397190] do_fb_ioctl+0x31e/0x700 Signed-off-by: Zheyu Ma Signed-off-by: Sam Ravnborg Link: https://patchwork.freedesktop.org/patch/msgid/1627293835-17441-4-git-send-email-zheyuma97@gmail.com Signed-off-by: Sasha Levin --- drivers/video/fbdev/riva/fbdev.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/video/fbdev/riva/fbdev.c b/drivers/video/fbdev/riva/fbdev.c index f1ad2747064b..6e5e29fe13db 100644 --- a/drivers/video/fbdev/riva/fbdev.c +++ b/drivers/video/fbdev/riva/fbdev.c @@ -1088,6 +1088,9 @@ static int rivafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) int mode_valid = 0; NVTRACE_ENTER(); + if (!var->pixclock) + return -EINVAL; + switch (var->bits_per_pixel) { case 1 ... 8: var->red.offset = var->green.offset = var->blue.offset = 0; -- 2.30.2