Received: by 2002:a05:6520:4d:b0:139:a872:a4c9 with SMTP id i13csp2565976lkm; Mon, 20 Sep 2021 18:52:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXBQ/TYhM8XcmjxTtzC1NNEUMLHMjb0FzCLhvcxDViDAGYCTcvisdN5feW5U/9eculSjW3 X-Received: by 2002:a92:cd8d:: with SMTP id r13mr19419744ilb.244.1632189153201; Mon, 20 Sep 2021 18:52:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632189153; cv=none; d=google.com; s=arc-20160816; b=TMTER10Nh0xyNZXW9CnKAL+E2/yAViXtoWmHg0zSbuRYcMLq6fURq7No+l1J5BeyxC H0D7B5XM8Txu3Kxb4KUmKAznTL8fzBnzHCBL2TqbnXDVoUsO3J8/1HDDP2p6LkmHa5R2 aVRZA9EglzDJ6C8EhirXJT2HHjPkbQ9jLQkM/OAW7LyTiBtkKJ4+fM9otCegi0vH08sb X382t2wY2BXDZ3jMD5sLep+Tfs4XG63EUkzV/xs3eZxz+LM93eQ+rCQz5GW/tRMOenCH q4MVwxWQ07ytZriQhUVftDuX3hz6fuMPW4aWLWYA4hKj1O615O2+3D5awJ5/HiFJSGBh hGyA== 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=caAVOk36Lwk/TTASTkTqSelGKHw9tam/6KVikzov8gTlHdFlJDojTqra4on0KpSEDP 0VcqSBWS7ylGqcMz3wRXNDw0/DHGdTyZSsvoJOg1XoDKAWURZnKLyG6k0yQ+C6TNxOcJ pBnnZqTaEHj05Ogr4wKjREcawOe57AbgNvHvXjXpK24G5vOoOuLsEKAmpkAWLrb83XTh zHQEr7A1mkRmvwXUo6r+kXPclVRX+w3xOtEQoH57P3CI4+T0zkqDE9nKpxYw67WkAti9 TgRcDBQ5N6HtRzQr8ae1xg7cWPf4c8Tt+p39EbnOZi8VIC4g0V316Yqmyoe+l5lMCrGR qtsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CP0IYHvx; 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 13si16757018jan.43.2021.09.20.18.52.22; Mon, 20 Sep 2021 18:52:33 -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=CP0IYHvx; 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 S1376724AbhITSOU (ORCPT + 99 others); Mon, 20 Sep 2021 14:14:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:35778 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359293AbhITSJ1 (ORCPT ); Mon, 20 Sep 2021 14:09:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 782576326A; Mon, 20 Sep 2021 17:19:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632158366; bh=9sqIlj1TMlzStrSfKyBBB4xXAtrh/JOARt+Z0euvc/E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CP0IYHvxc+K4MHy2p4uA7wXP2ZMJZ4WII450iV7epLUhQIAFicXdQtYjsLsbNTK0U qJ/ngIoCIy9x237Iv4J4cgLAtvX4LTAXVGVYOue1fi3S5dOaJ19l76tzvO9UZggP4p LWq8/AWmYsUZuzRfoNGAOVGktIT2xZ19Le+wqPhE= 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.4 082/260] video: fbdev: kyro: fix a DoS bug by restricting user input Date: Mon, 20 Sep 2021 18:41:40 +0200 Message-Id: <20210920163933.927168578@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163931.123590023@linuxfoundation.org> References: <20210920163931.123590023@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