Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1692578pxb; Thu, 16 Sep 2021 13:08:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqP2cxZBtZsItNKfPSUvedOySsjgxsoS/GzAsRK8G0Urj3dvMwdShM12IJpsiQUmAawUL+ X-Received: by 2002:a05:6402:2810:: with SMTP id h16mr8400565ede.293.1631822888344; Thu, 16 Sep 2021 13:08:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631822888; cv=none; d=google.com; s=arc-20160816; b=Eau2+ltxpdK7b//va9ObZ9sixwCZDZt8VycuqKqjOYzJtfoVX2XwqROeN5R0pRu6Ri 97SQY9acaYS6qRJJ76y8IhWfe5CXuCV6eJ2I61sFj7Gd5NGYEfDtiNUgA9ko6Z0IiH/4 XsNCV/eJJhvM4aZmeX4xRJy+Ns/CzYOhFuDqehRAZ0Nmp4wADpXbd8os16ECcTH3xUks /Oxg8Cn08p5oNHNuSCRxUVUV4TTOx19Z8gLRUvNa1D6P/KK1YGZEvVqzgn6wBTUB0Tpv GBjHh02dnsDhZKwkBxMR3xWyDmTeOC94uVNBnlAyMir7NYIMof5R+vOl1NZmOVdFGYXu 86lQ== 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=hNN6Kw/0E0+Tznzij7ugY9fxI6c2+rFdfcUBBHamzII=; b=LPWR7iPNIMhVGCqg3xpU/cpsGIonUpFd/CEt1Dfi+SSEpQ5sEbGRweqHoFJ+Kod+/w 4JWk2BOjq9E2EBmvXqkX+6QkklS1MGoIKFoJ+SQwf3bdh/8FyAUdIDZgdjK/oCWe2BCT T23uzjXzBXK3IoQvIXjdRLMihMIw0zq5cRWOFcnjvJBc6tKf1pEiKGQQq6V5IOc2B/DB oGWm1pJqnm7jy1wsU2DfpQkPrbFl6sOVtW90uGpR5xXWpM5UzSWLUoOekZVMpYxwic+h A8mVSWdL/+UFkyDyk7b4IL0AoLxIR2wLmPuyoTyqar+kqorAUmKYaQfIWq4ayDuIPSR9 WqrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EEGuITG7; 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 ho11si4375739ejc.162.2021.09.16.13.07.04; Thu, 16 Sep 2021 13:08:08 -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=EEGuITG7; 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 S241689AbhIPQT7 (ORCPT + 99 others); Thu, 16 Sep 2021 12:19:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:48650 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238278AbhIPQLP (ORCPT ); Thu, 16 Sep 2021 12:11:15 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 913A96136A; Thu, 16 Sep 2021 16:08:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631808528; bh=35atDnHr5kKPvD7ZRVCpmrxJQhwkKsyZnBkWc0xcL9g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EEGuITG7Jxen2hdBhdfW+d0a0vujXLOJifdZDUEUqm/T/OriQWaFqd4EZhTKxUeno oBfG5IWMVTk4AP/t3EDqK3Ajs4SkWQJmORcoLdsElyjqNUbfJ25/jgOWAYNXVbmkZe mJM/Atq55Gb0/TZP2gYiNdV69OyGvFiDP+Gc8Ni8= 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 124/306] video: fbdev: kyro: fix a DoS bug by restricting user input Date: Thu, 16 Sep 2021 17:57:49 +0200 Message-Id: <20210916155758.294474070@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 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 8fbde92ae8b9..4b8c7c16b1df 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