From mboxrd@z Thu Jan 1 00:00:00 1970 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=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,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 F2FDBC3A5A1 for ; Thu, 22 Aug 2019 17:27:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BD7132341A for ; Thu, 22 Aug 2019 17:27:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566494827; bh=fgkm7WAJnjMm0e9zjgQqZSf3/wt/5O1q3IEJNndBPfE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=OvrrcYi6isxAHwE8FU0UHE2NkHoULY6gYCyaQKUVYIwCE5VBp2pMI61vTxM91sW0o HmrZKlh4DHFmXejtTUBD3pD7nY4wuD/zymuOdEUZwnqxeZqc+6463667wae3+BvcXU dWzSKZOOfpFZ6thR57M4H5GqisplxfmPxY2EM/lY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391954AbfHVR1G (ORCPT ); Thu, 22 Aug 2019 13:27:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:49862 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404488AbfHVRZp (ORCPT ); Thu, 22 Aug 2019 13:25:45 -0400 Received: from localhost (wsip-184-188-36-2.sd.sd.cox.net [184.188.36.2]) (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 E44FC2341E; Thu, 22 Aug 2019 17:25:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566494745; bh=fgkm7WAJnjMm0e9zjgQqZSf3/wt/5O1q3IEJNndBPfE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tmbg3ZNHqawmIogiU6UY04D3j3H4A/az1J79zbySAq5jtuVj/koeb32izdOyQYHHJ GWEfAFVJMMQEitjdSwSDXKvgEyY9Uo34X83YoAHj2xvIh6Mrg59zQJF92VKKZ7sN9Q HGs7q25DfOLw2QQVF1kswFVBAwrfFzziLeGUIjrw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wang Xiayang , Chunming Zhou , =?UTF-8?q?Christian=20K=C3=B6nig?= , Alex Deucher , Sasha Levin Subject: [PATCH 4.19 39/85] drm/amdgpu: fix a potential information leaking bug Date: Thu, 22 Aug 2019 10:19:12 -0700 Message-Id: <20190822171733.010185705@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190822171731.012687054@linuxfoundation.org> References: <20190822171731.012687054@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 929e571c04c285861e0bb049a396a2bdaea63282 ] Coccinelle reports a path that the array "data" is never initialized. The path skips the checks in the conditional branches when either of callback functions, read_wave_vgprs and read_wave_sgprs, is not registered. Later, the uninitialized "data" array is read in the while-loop below and passed to put_user(). Fix the path by allocating the array with kcalloc(). The patch is simplier than adding a fall-back branch that explicitly calls memset(data, 0, ...). Also it does not need the multiplication 1024*sizeof(*data) as the size parameter for memset() though there is no risk of integer overflow. Signed-off-by: Wang Xiayang Reviewed-by: Chunming Zhou Reviewed-by: Christian König Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c index f5fb93795a69a..65cecfdd9b454 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c @@ -707,7 +707,7 @@ static ssize_t amdgpu_debugfs_gpr_read(struct file *f, char __user *buf, thread = (*pos & GENMASK_ULL(59, 52)) >> 52; bank = (*pos & GENMASK_ULL(61, 60)) >> 60; - data = kmalloc_array(1024, sizeof(*data), GFP_KERNEL); + data = kcalloc(1024, sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; -- 2.20.1