Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2319243pxb; Mon, 20 Sep 2021 18:42:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwB4M1wGWa63ws23krDKjEFNPxRgbzbc9xVG/+BqYUFJAzZHlaSfjIgFnRPqNTUQpfoAdKc X-Received: by 2002:a05:6602:4a:: with SMTP id z10mr10726471ioz.16.1632188532794; Mon, 20 Sep 2021 18:42:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632188532; cv=none; d=google.com; s=arc-20160816; b=s4no9grz/mZaQ40KesZH1qsrgC1E6olT08ZbXlm0qjgvE8499OXOOb/FjEs7uGzKLQ XfcLC7jazzCp7+PFfnNt9u+8cHsT9aXDUebcM/vqFVj6iLBaJUU7acHUgFJf6s5e6ffb sEX/2UoOjq4y7Mo4W3keIcIzNiyY7P3mNlCPuiH7chBb3cuY8+4b0dg2JpxAj6rlYrQJ 5hNx5XUHuYSsED8TLrKDzvACokwH+RyRQxZqleUusgw+6cqw37j5m6PheerozRCUo2iR znepiUorPESwVGglQQ1u/Mrb1LIDgrLyGxCN/3yq+Cfb2KiQaZ8zkgbOVUeC+nWb5otF nIsg== 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=96WffO9u1DBwf9IyrVvU82tr3vz2pKDG6jKAoHzL6cY=; b=Bngbhj652VErncJAZuZQQJi1ERBFFsouHdRBW0LNmXy9ZDE88FbBjuTl3hcWgowkdE 0k/y7h4cN5DmTeexpaKiBZ1UCkk0aGdwx4Tc3Qwkz/RVB0OUlWW5blmTaZk/Q+zRVFyM I77BU2M1I1fm+STglffXkqQhXnFA3O6NIjxsY4W/c2XZwu/BYAF0iypVPyzwhHCvphzl 1T6H/j29MG4g87WibWhlOiv0rOCvShvEUbDTdQjz4n5yPPizCvmC4R5fFoCNDLiQXwH7 7+Jgxc0wLJFDFc4bpPUDkG+EUGtjsDjK8KS4bXlrpWqL0sE7lC5b0XJ9thXzigQfU+He aOQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KG3KLPHV; 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 k26si7877722ioh.55.2021.09.20.18.42.01; Mon, 20 Sep 2021 18:42:12 -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=KG3KLPHV; 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 S245195AbhITQwi (ORCPT + 99 others); Mon, 20 Sep 2021 12:52:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:36076 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229900AbhITQtv (ORCPT ); Mon, 20 Sep 2021 12:49:51 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DE22761242; Mon, 20 Sep 2021 16:48:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632156504; bh=tVvaw6HlpLk74LVq/wGIqdRnM0lfG0tiM0yTIJlP9E0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KG3KLPHVTdVBfQiSOMPYMRySW5bIGvWXURo2U+Desk/ZNA+xrwZKezS1+T5RDPEAr kxFUnaMQSnPZHenCKA3Bm/gC1bzCjYRxXW10NBqaF/dHv/6xFVa1oj8/Jmi/TanUp6 8MW28/H5Y2ZRrok8Douk7uqzAfIJwekzlg3UC3kM= 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 088/133] video: fbdev: kyro: fix a DoS bug by restricting user input Date: Mon, 20 Sep 2021 18:42:46 +0200 Message-Id: <20210920163915.523376772@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 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 5bb01533271e..8482444259ce 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