Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3204338iob; Fri, 6 May 2022 22:28:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzV/spbx1p7uuXfXyAub8VY0Mrgv3+embeLiZ+bRo2FIZfGcVcuWrNaoMYAeKOxXWdWtEnj X-Received: by 2002:a17:902:e842:b0:15e:d449:fd03 with SMTP id t2-20020a170902e84200b0015ed449fd03mr7379283plg.60.1651901309643; Fri, 06 May 2022 22:28:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651901309; cv=none; d=google.com; s=arc-20160816; b=BBdFT1ctl02G/Yr5hMfkcn5hd2s948OGnopbND/tousipnSBRSUba9Ku2wE6TeQqpO zbjSlOLU1j3MZVsrbRWqGAsNgwQIOhpDe/uXJ1Ffi5N6tapFyhHqYf4nKLf3Eo7rGxZ+ opp4Ri2MCA+ZE5xuDfkM2oVmSbiGE58V2pj22cMLPa3SXFD7A8QdfmrL6B+2QMb/33q9 +9ncDvRT73nKxSN2hukDcLlQgswWMnwnNPKPVdaG23aIHXaaHCXaVmJrbeQ3FBQVnQXy OIJ4c+CsXx3ejlbccu3v1ygJ8lYWOtyxb9eJLdnnrJxR/C1ZWlGJ0hofPcYVFXO94zFu Iulg== 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 :message-id:date:subject:cc:to:from; bh=Z5924QWmWBWchEyVdW6hYSDLxa2FwUQBu1FTwuQN5VY=; b=ttagt1Jz6wWTKMcWEKRVyqEQnolzCk6bg9Tz7FQDC3qhX14uYOmCjRJQ+aU3npZZn+ YLuUzkHRrCYFKU2asKdrZfiP9Qcrq1JFYDhf8QW2p+E6sANKysDIis6ttt+N8Go2xrld Dypb+1/ubiifqkAmrNaK9lKLLufMBzbLhnrTNUjT0OJkwTldq6hT9lOWroWaz84+JwwE ku8/TyJv9/8NCmjJO8y8lnhO+1HLP3Au08WVMMSuW4Y+Vwbc1hBKv+ZFng/+C1PXBuEx 1AnozsBb67ypVDjUtki57HVYwUulo3KcHZcDWIDt7Y+kXv8yZDDwr3axw4DxpOXuZU26 ZRag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lk18-20020a17090b33d200b001d7d1d49e93si14928132pjb.129.2022.05.06.22.28.13; Fri, 06 May 2022 22:28:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237291AbiEECNd (ORCPT + 99 others); Wed, 4 May 2022 22:13:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230027AbiEECNc (ORCPT ); Wed, 4 May 2022 22:13:32 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94C7821E13 for ; Wed, 4 May 2022 19:09:53 -0700 (PDT) Received: from dggpeml500021.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4KtxsS2DwRzGpY0; Thu, 5 May 2022 10:07:08 +0800 (CST) Received: from localhost.localdomain (10.157.217.52) by dggpeml500021.china.huawei.com (7.185.36.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 5 May 2022 10:09:51 +0800 From: taolan To: , , , CC: Subject: [PATCH] =?UTF-8?q?printk:=20fix=20kernel=20msg=20leakage=20in=20s?= =?UTF-8?q?yslog=5Fprint=5Fall=20function=EF=BC=9B?= Date: Thu, 5 May 2022 02:05:41 +0000 Message-ID: <20220505020541.1133-1-taolan@huawei.com> X-Mailer: git-send-email 2.18.0.huawei.25 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.157.217.52] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpeml500021.china.huawei.com (7.185.36.21) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: t00264981 This function applies for memory but does not initialize the memory,and then invokes copy_to_user to copy the memory to the user space, which causes kernel information leaks. [ 148.439660] kernel memory leak value 0xffffff80aed972bc at 0xffffffd37f00a000 to 0x704b883e74 Signed-off-by: t00264981 --- kernel/printk/printk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index da03c15ecc89..22d7d821909d 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -1591,7 +1591,7 @@ static int syslog_print_all(char __user *buf, int size, bool clear) u64 seq; bool time; - text = kmalloc(CONSOLE_LOG_MAX, GFP_KERNEL); + text = kzalloc(CONSOLE_LOG_MAX, GFP_KERNEL); if (!text) return -ENOMEM; -- 2.18.0.huawei.25