From patchwork Fri Mar 3 12:28:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thadeu Lima de Souza Cascardo X-Patchwork-Id: 1751449 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=WwC+H0JH; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PSnMZ604Tz246W for ; Fri, 3 Mar 2023 23:28:58 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1pY4Wr-0006gM-Dq; Fri, 03 Mar 2023 12:28:53 +0000 Received: from smtp-relay-canonical-1.internal ([10.131.114.174] helo=smtp-relay-canonical-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1pY4Wp-0006fZ-Vb for kernel-team@lists.ubuntu.com; Fri, 03 Mar 2023 12:28:51 +0000 Received: from quatroqueijos.. (unknown [179.93.189.89]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id F40FF41FBC for ; Fri, 3 Mar 2023 12:28:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1677846531; bh=BH6m+Ycpyo8EOaNSc330RlJRm1camWIjowf0+pjvz6c=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WwC+H0JHQhIw4gap7QpFFsSFDNDMdPG0yAp7/AGlqx4XC2IUL7fhCBsA7r6exCqD7 X0SM6vEUWDLH33SGcGPalRZ24Chx8KL483/GZ6A5dYMI2VWWBF/GtTqJyuFRwDYSJx GNpYGMolOAk7Dcs1FUfJXe50HKcA1rjNW8HCB2qXOsSCXsDPxZQtf7ydU34k/I+ohj dh8ciBdgsk3kv0YMoTamCEo4bYoOcr7FzEsBQQTFIX6b7XniWabDTECy/jLIn6y9PD 9VOrnfmzcXQA4ks0yKIaNvCgw7Wk0nYGTXhPEhFVLsU1edFsX0ZbypfK0pN+G1vh5y JuhLBM5FEFvKg== From: Thadeu Lima de Souza Cascardo To: kernel-team@lists.ubuntu.com Subject: [UBUNTU Focal 1/1] drm/amdkfd: Check for null pointer after calling kmemdup Date: Fri, 3 Mar 2023 09:28:39 -0300 Message-Id: <20230303122839.320821-2-cascardo@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303122839.320821-1-cascardo@canonical.com> References: <20230303122839.320821-1-cascardo@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Jiasheng Jiang As the possible failure of the allocation, kmemdup() may return NULL pointer. Therefore, it should be better to check the 'props2' in order to prevent the dereference of NULL pointer. Fixes: 3a87177eb141 ("drm/amdkfd: Add topology support for dGPUs") Signed-off-by: Jiasheng Jiang Reviewed-by: Felix Kuehling Signed-off-by: Felix Kuehling Signed-off-by: Alex Deucher (cherry picked from commit abfaf0eee97925905e742aa3b0b72e04a918fa9e) CVE-2022-3108 Signed-off-by: Thadeu Lima de Souza Cascardo Acked-by: Roxana Nicolescu --- drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c index 3685e89415d5..6066cd7a9d8c 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c @@ -407,6 +407,9 @@ static int kfd_parse_subtype_iolink(struct crat_subtype_iolink *iolink, return -ENODEV; /* same everything but the other direction */ props2 = kmemdup(props, sizeof(*props2), GFP_KERNEL); + if (!props2) + return -ENOMEM; + props2->node_from = id_to; props2->node_to = id_from; props2->kobj = NULL;