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=-14.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,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 C1CE1C433E0 for ; Mon, 1 Jun 2020 18:45:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 974AE206A4 for ; Mon, 1 Jun 2020 18:45:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591037113; bh=PiFQg7pPmhc7HgkT58PSucyAyYM65EXKVRcjGMPYxeg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ycL5ea7Ap1/MdQkWz9iH9W5grgf/ke4bNNTAilETo3DOuCioefcZQTjOBGKZ0VSEC T7oW6RWzi71+B0bSYHmGWTmOpJg4q9UyTk91+YTsgUDqXwI4ZhDjt6auqP3XO3ndJ2 QSz/NUjOy6z2E25IPTTEocOEFY7l9sEbjA2qSlfI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731013AbgFASpN (ORCPT ); Mon, 1 Jun 2020 14:45:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:56364 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730459AbgFASJv (ORCPT ); Mon, 1 Jun 2020 14:09:51 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 538A42068D; Mon, 1 Jun 2020 18:09:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591034990; bh=PiFQg7pPmhc7HgkT58PSucyAyYM65EXKVRcjGMPYxeg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n2nUqx0g+C00L95c/kall3IsOd7wRluH8XhfXvMCEcGs3o/yP5tHNTq/liXZfLueX BjgNJk+fweksQc5CTZX6rRSOMZ2ldlsHFaFmeTq923gvfDRen4WOCWqTo6rLPT9YJ2 3cJrNW/SMhq/s6/owmle3BisNO2uid2VIAwZTvDc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, sam , Alexander Potapenko , Andrew Morton , Kees Cook , Al Viro , Alexey Dobriyan , Linus Torvalds , Sasha Levin Subject: [PATCH 5.4 101/142] fs/binfmt_elf.c: allocate initialized memory in fill_thread_core_info() Date: Mon, 1 Jun 2020 19:54:19 +0200 Message-Id: <20200601174048.446359312@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200601174037.904070960@linuxfoundation.org> References: <20200601174037.904070960@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 From: Alexander Potapenko [ Upstream commit 1d605416fb7175e1adf094251466caa52093b413 ] KMSAN reported uninitialized data being written to disk when dumping core. As a result, several kilobytes of kmalloc memory may be written to the core file and then read by a non-privileged user. Reported-by: sam Signed-off-by: Alexander Potapenko Signed-off-by: Andrew Morton Acked-by: Kees Cook Cc: Al Viro Cc: Alexey Dobriyan Cc: Link: http://lkml.kernel.org/r/20200419100848.63472-1-glider@google.com Link: https://github.com/google/kmsan/issues/76 Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/binfmt_elf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index c5642bcb6b46..7ce3cfd965d2 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -1731,7 +1731,7 @@ static int fill_thread_core_info(struct elf_thread_core_info *t, (!regset->active || regset->active(t->task, regset) > 0)) { int ret; size_t size = regset_size(t->task, regset); - void *data = kmalloc(size, GFP_KERNEL); + void *data = kzalloc(size, GFP_KERNEL); if (unlikely(!data)) return 0; ret = regset->get(t->task, regset, -- 2.25.1