Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp445600pxb; Thu, 9 Sep 2021 04:46:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYUQxGMMnYYwKUCH2BErAT7u5halYBpU6La0Z5HwkeJaUbwMLXUAfkdEjHMpB3rv7YXU4o X-Received: by 2002:a02:c48c:: with SMTP id t12mr2427870jam.82.1631187996718; Thu, 09 Sep 2021 04:46:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631187996; cv=none; d=google.com; s=arc-20160816; b=bAS8ZkDboPiuZcgogfE10gxFGwgvyc2Hg0cfrsMjHzW4C8Rse/1SO6IdUrerP5lA/z 0eBZxE23HtFf/Ue7cSgR+Fo2nvqttPrvPooch6I6jJcJ0czEdpbE93f9zE2dQQnUPQS5 o6xChcQBff8NErw4gFzRzA4u/xpABy7UjXD5TkBCPR1mhWOHyVCr2EiNJXc1i8oa5Wjr ewFhPx03i/M8O2S5dchUrNVh65w190OGSuVCVIKK65al46mPSpr7XROvlvqWFd/pkcll xvgnLyzQq512nMHFWB8W+ZjgvI7l1vamV4p0dP14wl/fPT5qLIYaqggq7KnkyrPRnMb5 uI4g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hNN6Kw/0E0+Tznzij7ugY9fxI6c2+rFdfcUBBHamzII=; b=sP2gacltteptDDecvo5fr2F4N4tMmCMkYud9v0Tw6akVqbl+wfe5xYHL4J0HeH8TTj F3X3Oix7yyHO18qic7vafzsZfmW30Nykyg60dcndbuYGsFktbNcyCbyKKQrHuAcRqhFC nnkiG5dxi86AIh2pKXcigftlZ8Xv+j+CYJWzNcKLQspN6Fl4JrcXIdQblTZuQm66cXC/ dGCB5eHzpYyVVuCVPo5f5TorWfu+h94mMnsDgU495q4XAjSEXy/nx8ajT7yR46oNpPjh CvhQ32nZ+ObdZ1kcZSOZiFwRkWu67wC7is43L7f8Dum3DeMeXFP+DcvW8CMrrAxhZcmX Fhcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VrpCArfM; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x6si1826122ilv.42.2021.09.09.04.46.25; Thu, 09 Sep 2021 04:46:36 -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=@kernel.org header.s=k20201202 header.b=VrpCArfM; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239637AbhIILoR (ORCPT + 99 others); Thu, 9 Sep 2021 07:44:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:46516 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237179AbhIILmw (ORCPT ); Thu, 9 Sep 2021 07:42:52 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BAFE5611ED; Thu, 9 Sep 2021 11:41:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631187703; bh=35atDnHr5kKPvD7ZRVCpmrxJQhwkKsyZnBkWc0xcL9g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VrpCArfMUVdLkRmeiFkXMk3WK7EXRot/42pj4T6na8OeubQNnXIbg6pLwWtv8V7kp 3+6Hf7+ef057UwLnZOb5UXmV+oJ2f2lv27q6c9oXa3nYagrUEQSrmPiyMMZH0fz09g KUyJNmOqeEKHBY8WQj/pI0gOG2Ef/W6bfgjmhOY+mmgK2zAXRDJcIHp3E1Bw0Zv3vS bgnGhgYfFj+CyTeaOnFaYUveCIfXOSsWaqf+TRlY15NtiKV+Dp4ppKBsnrt1uHP5sR /Z0sQui+vy6j8wHcI6FZuIHHWlzD0X6w1dmtQBu8TTpk4Q9canMSld8fqwU2vZfSll 0TOezxI6sE99g== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Zheyu Ma , Sam Ravnborg , Sasha Levin , dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.14 028/252] video: fbdev: kyro: fix a DoS bug by restricting user input Date: Thu, 9 Sep 2021 07:37:22 -0400 Message-Id: <20210909114106.141462-28-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909114106.141462-1-sashal@kernel.org> References: <20210909114106.141462-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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