Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1901672pxb; Thu, 16 Sep 2021 19:38:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+nYgwbzHEdmCDziTG+KFzUGO0b/qcVqPwYtztbA/48tM9c5xAu6Rs6sJX+pzAIZ5pTPAO X-Received: by 2002:a92:d2ca:: with SMTP id w10mr6070966ilg.222.1631846325967; Thu, 16 Sep 2021 19:38:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631846325; cv=none; d=google.com; s=arc-20160816; b=b+LZcsUoHnzgORdOnScR9qCj3t9dKpntUmyIwS/Rg0AGq8x8mSoW5TvawFjJM08fQI CZ0nyDCmGdESNphGTGEgYN0o1lT4G6ymLwkraIvIYBjtVSeHrGZaj1FAScgGWD2YcxXr 9ef14+BO2YAl+3/yrcQBtGJaCKfbg9bweQOb5dMFk9nfPohHfjUUmmGyRJ+2c38GmeQT 63yMzBEtC3ye2aAXjhNqEXKdbNn/n4A/98W+tWB3yEFTl2AqGjWNXMikkXOWqwRoyw4+ pi+Gq7BTHGLHOI9qDcO3mvxvvzJakZHnmnMhLRcUrtVFhIBC6EthSJjot1lMDZBweXOd 8TBA== 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=ot8b7ppWMy1DJFTOHh33O3t7PbtSQ564DPQHpGlb53yJfggAYCsDSUTwb27h2hUtQY Xl1HBnDfyXfhwUSHZupFVjnZZsQZITCimzp/jTjZ6wz3WBQjQ1SNQ3qWiesP63Rh7JLf tMW2ecmEgE1YiTgZNpJ4PdGv1YjXV3Y4bv+HCzc1q4ZSOkyJy2Z9Te0X6xDh04z5iRja U1dhvPVw2VjceViT3m4MEDQ4JnA4SgrBldPoAaSnjh1RQi+UZZMZUMpnwyWCLNmOWD4K Sl2M/idyLEDugulFx3v1tZNHxBFSYPgQRgQUUbofa81Q9i7a0cavOU9Srlx9JoQEuLDJ WwtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=K02YOYNU; 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 a4si3996853ilm.69.2021.09.16.19.38.34; Thu, 16 Sep 2021 19:38:45 -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=K02YOYNU; 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 S245122AbhIPRbC (ORCPT + 99 others); Thu, 16 Sep 2021 13:31:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:43518 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245649AbhIPRV5 (ORCPT ); Thu, 16 Sep 2021 13:21:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C70FB61440; Thu, 16 Sep 2021 16:42:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631810553; bh=35atDnHr5kKPvD7ZRVCpmrxJQhwkKsyZnBkWc0xcL9g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K02YOYNUXht4vFC5AG0sKgUUrwNCf+A762aUy/ffds0gULIP1fGVzyPYuGql4r4i0 A1rBRbhNEDL1k44i4CwuX+XzYEpBD5shXIHtyMMjgrH5SwBdqPIu/+JVop+PWqydl0 3cRxUfvSQ75JkdwMuUJ4jU5uRjYheBerBakKe/yU= 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.14 183/432] video: fbdev: kyro: fix a DoS bug by restricting user input Date: Thu, 16 Sep 2021 17:58:52 +0200 Message-Id: <20210916155816.933160894@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155810.813340753@linuxfoundation.org> References: <20210916155810.813340753@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