Received: by 2002:a05:6520:4d:b0:139:a872:a4c9 with SMTP id i13csp2565299lkm; Mon, 20 Sep 2021 18:51:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz896LJjewf/sjXDv8AcyW+HejMCtccG4BWkgAv7BfLilOHaWNYxRPJ2c6F3DLZ8MPgN+k8 X-Received: by 2002:a05:6e02:12e2:: with SMTP id l2mr17133716iln.153.1632188980786; Mon, 20 Sep 2021 18:49:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632188980; cv=none; d=google.com; s=arc-20160816; b=r27CPxgCdLe4L3UBdWYpjKTFoePZdui8nZEqIswBLyy/zUEb7110vfU+kV8lKIufw1 lUyAU9FLMvJmsMJAp5rxFHFxhaSVpidyLUvVIQMdUAo60c7YyfmtqOLWLBVXv3VpC21T fs+NGWnaRJtg8O8D/SY8ck/T4m9kcRGXhUM+pqKp95bPGkDlybG9IALkiFtQq7IwhFzJ YyPAMaW66QhIC5lAuI62FgNgz11iQ++ptTQLV+yuvG8mg03PFqaSkSndoYP3IXVEsxUm F5doevWPYbvJVYP5LngVHnFGXk2/QYCnCp5KsV8OCCb7IgiUyk5CuWIIDtVVHhNASVB+ Ypyw== 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=q6IfUFbe2kKHaP4cmphp/UnlkxiM1fW4tZH001Xp5hc=; b=L86xNaAwIOkn56eGjqVLe14cA8H1Q2zEqd9ws7TC2d32phDYYJroQZxsBFkomn4ZBC /pq3Dqt6BeHpKpQkjQYxqhoeGvfPIieIT9CCmnxN8HNXv29y2pfGfR3sFz33V8LxgQls J9AjLuchPlkRtNtHNzKTY/tRoUL+ZAH7U1Q7wpitTeBSrW6wIib5usKXIQXOHivK+Utk r4TwHWxJw+a3xemcGOT4NTnFMjXiH4pS16N2jE6bp5btOT7JQyJmIK+4uCw+5VhdB0Rc h7RDBhdwJVUe9CaAIMu5dsbrBzfKoG8hefCWWd5ZaTGZKZZO7ct8fx6UBEwAGIcJi0of yZuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WUqZiSkz; 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 v13si4488596ilj.176.2021.09.20.18.49.29; Mon, 20 Sep 2021 18:49:40 -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=WUqZiSkz; 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 S1354422AbhITRz6 (ORCPT + 99 others); Mon, 20 Sep 2021 13:55:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:54102 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354546AbhITRue (ORCPT ); Mon, 20 Sep 2021 13:50:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AC2FB61881; Mon, 20 Sep 2021 17:11:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632157914; bh=9sqIlj1TMlzStrSfKyBBB4xXAtrh/JOARt+Z0euvc/E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WUqZiSkzhHyCrmxMO01byc0M111ILWU/oJImm/eqgVffcvSSrg/hrevITR93JYCFP 4rDEGzhulVVOk/zB/x2nbQCiKqN1JzLe1QIQ7sSNtH+fvaasOS9MGomKlDaGTbaEjF PKg6ZTLxkgIRTprYJ8MJ5sOZA8u1UujkPa5mW+yA= 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.19 178/293] video: fbdev: kyro: fix a DoS bug by restricting user input Date: Mon, 20 Sep 2021 18:42:20 +0200 Message-Id: <20210920163939.367528971@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163933.258815435@linuxfoundation.org> References: <20210920163933.258815435@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 98a65439172dc69cb16834e62e852afc2adb83ed ] The user can pass in any value to the driver through the 'ioctl' interface. The driver dost not check, which may cause DoS bugs. The following log reveals it: divide error: 0000 [#1] PREEMPT SMP KASAN PTI RIP: 0010:SetOverlayViewPort+0x133/0x5f0 drivers/video/fbdev/kyro/STG4000OverlayDevice.c:476 Call Trace: kyro_dev_overlay_viewport_set drivers/video/fbdev/kyro/fbdev.c:378 [inline] kyrofb_ioctl+0x2eb/0x330 drivers/video/fbdev/kyro/fbdev.c:603 do_fb_ioctl+0x1f3/0x700 drivers/video/fbdev/core/fbmem.c:1171 fb_ioctl+0xeb/0x130 drivers/video/fbdev/core/fbmem.c:1185 vfs_ioctl fs/ioctl.c:48 [inline] __do_sys_ioctl fs/ioctl.c:753 [inline] __se_sys_ioctl fs/ioctl.c:739 [inline] __x64_sys_ioctl+0x19b/0x220 fs/ioctl.c:739 do_syscall_64+0x32/0x80 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xae Signed-off-by: Zheyu Ma Signed-off-by: Sam Ravnborg Link: https://patchwork.freedesktop.org/patch/msgid/1626235762-2590-1-git-send-email-zheyuma97@gmail.com Signed-off-by: Sasha Levin --- drivers/video/fbdev/kyro/fbdev.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/video/fbdev/kyro/fbdev.c b/drivers/video/fbdev/kyro/fbdev.c index a7bd9f25911b..d7aa431e6846 100644 --- a/drivers/video/fbdev/kyro/fbdev.c +++ b/drivers/video/fbdev/kyro/fbdev.c @@ -372,6 +372,11 @@ static int kyro_dev_overlay_viewport_set(u32 x, u32 y, u32 ulWidth, u32 ulHeight /* probably haven't called CreateOverlay yet */ return -EINVAL; + if (ulWidth == 0 || ulWidth == 0xffffffff || + ulHeight == 0 || ulHeight == 0xffffffff || + (x < 2 && ulWidth + 2 == 0)) + return -EINVAL; + /* Stop Ramdac Output */ DisableRamdacOutput(deviceInfo.pSTGReg); -- 2.30.2