From patchwork Tue Sep 1 15:11:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 264523 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1CEFFC433E6 for ; Tue, 1 Sep 2020 16:53:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E292C206C0 for ; Tue, 1 Sep 2020 16:53:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598979187; bh=UbfcBS2F40l2Ri3VjuXityfFN0aeN7ciV4mX6RdhXyE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=RxMuVx6Mk0wTn9Y9Q7Z1LfB3OApfGF6TOuJbb9FCHcgwJYtznqtIlV9gpFxy290m9 eHJTPjrjZ29usdh0AgttXuh4IWOYqEo99zcwSd2iG5pfKgxYG0XwSOJzGWlVf5KGC8 x71KLXBNM7bw6X4NCLDy89N6Vpv5021TRu5mF9XM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730487AbgIAQwv (ORCPT ); Tue, 1 Sep 2020 12:52:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:50146 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729741AbgIAPZc (ORCPT ); Tue, 1 Sep 2020 11:25:32 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E9D7820684; Tue, 1 Sep 2020 15:25:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598973932; bh=UbfcBS2F40l2Ri3VjuXityfFN0aeN7ciV4mX6RdhXyE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hQuO+5rcsRVAPsrJEbGlSnO8cL29V+DS7qvMLf8GkhsYDFKruDB3/h1NmFL2aiK3R Xgyzomwxc45PXLJVYmcJjgidItQcta1+ymGiD9Ca1eruPyIkRzZcZzlPrvLq88mDtQ PuCh2/++193f9Kqmmg38tnVe6OLidbpkC4uE3/6c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Alex Deucher Subject: [PATCH 4.19 105/125] drm/amdgpu: Fix buffer overflow in INFO ioctl Date: Tue, 1 Sep 2020 17:11:00 +0200 Message-Id: <20200901150939.757773885@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901150934.576210879@linuxfoundation.org> References: <20200901150934.576210879@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Alex Deucher commit b5b97cab55eb71daba3283c8b1d2cce456d511a1 upstream. The values for "se_num" and "sh_num" come from the user in the ioctl. They can be in the 0-255 range but if they're more than AMDGPU_GFX_MAX_SE (4) or AMDGPU_GFX_MAX_SH_PER_SE (2) then it results in an out of bounds read. Reported-by: Dan Carpenter Acked-by: Dan Carpenter Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c @@ -524,8 +524,12 @@ static int amdgpu_info_ioctl(struct drm_ * in the bitfields */ if (se_num == AMDGPU_INFO_MMR_SE_INDEX_MASK) se_num = 0xffffffff; + else if (se_num >= AMDGPU_GFX_MAX_SE) + return -EINVAL; if (sh_num == AMDGPU_INFO_MMR_SH_INDEX_MASK) sh_num = 0xffffffff; + else if (sh_num >= AMDGPU_GFX_MAX_SH_PER_SE) + return -EINVAL; if (info->read_mmr_reg.count > 128) return -EINVAL;