From patchwork Tue Sep 1 15:11:02 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: 310347 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=ham 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 B2507C433E6 for ; Tue, 1 Sep 2020 16:16:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 812B821556 for ; Tue, 1 Sep 2020 16:16:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598976991; bh=KHsjzeFClu/PBCpyLqSj+E24Yre95oeen+xA2tfS3Tw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=2UXlBF1vDIwMHxLPeBAvYB2s4I+aK4nuR/vW6URcfL5FolLZEwOPhby7TPAXl7RIo 5U2MXcd7rJ8tUGFKhN19gHJ71Jcvse17wX0W2lOP5nTzMtY/vCqfvtZm0hH4MghEOX vUFpNr8sSGOStubG8hU+UpaSLGI1CyFXsdGRRUTM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731946AbgIAQQa (ORCPT ); Tue, 1 Sep 2020 12:16:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:39056 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728415AbgIAPeP (ORCPT ); Tue, 1 Sep 2020 11:34:15 -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 E2A4520E65; Tue, 1 Sep 2020 15:34:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598974455; bh=KHsjzeFClu/PBCpyLqSj+E24Yre95oeen+xA2tfS3Tw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O0hl3Puk9e8axvxWqjT71pNmmVmSPNmbylNWE0t1Bb+Iv4uslDU2/0OwqabAS21G0 EVH757Ki4JnX2T8yBLWBBUycyd+ZnOppAKV2WymraXw3c159eDCxjPOAUSnwFrGkSK wsV/rWzyKjkNaihrQtD7G7Iz0Q6GSJYklg8JvegI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Alex Deucher Subject: [PATCH 5.4 182/214] drm/amdgpu: Fix buffer overflow in INFO ioctl Date: Tue, 1 Sep 2020 17:11:02 +0200 Message-Id: <20200901151001.680976580@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901150952.963606936@linuxfoundation.org> References: <20200901150952.963606936@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 @@ -638,8 +638,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;