Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp1052492ybm; Wed, 27 May 2020 15:00:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzDymPEBaH2kJI2O/purfm71CvZBC8PuTlq1n8Jbf3kHj42kiW6KPUAbzBmGCIAeE7eZ9/ X-Received: by 2002:a17:906:48d8:: with SMTP id d24mr330100ejt.369.1590616846601; Wed, 27 May 2020 15:00:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590616846; cv=none; d=google.com; s=arc-20160816; b=gsbU91cnrPhpiex2xjjQFtT5ZpJMos5qixNcSet3UsZKNSSWvZw4LhWL+ddYZU+LdL SIvumvpfh1vcAjtJr/D93DU1VjywXs/DqtpjUWsubDo0985vo1rLbVbZ1JZR/lQDLWU3 7jP4wIW6CqNuVlWz1n4mNfaGouY7PNmTZ6t74CqhoOEPPDyfHsEVhjuR19t/cYLmg8Ts r9oY+Trhpt+DnON7nqYMWUSEIRssDkNhbC1kKsDBlub01Mfx2DUTUsRpASR6qrxNkkoF 5gg7SV5VXuvcmWZxkkLW+AUfWxaT9fcr/SwHXyXNUK+S/a1xxv9fBTwB+dzalQTXI4Uf Ppdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=XCGwhiQvKxhSZLsq2F1qp3/RU6AkenpE+aDBKVz2JUI=; b=GU56bAaZgr1jVNmOAem0mcEN0qA7m72v2Hry2PATLiJNez916Wmyel0ewP/B55ZoP/ OsTzKNTdePFe2MMqMocNLDq2aMBUUQC5hNN8b4dunSRhCExLWctsB5J2Uf70YWtnLAxP TwR8F7Stp9DJ9kcYvNgqIeSM/yX5X2nvnaXP1Aaoors7f6nLIcPGCDk+EQ21qBC6qJEs ErhyDAfUvtvqogetcAIpIhPBCl/n/HwyiGUBezwHAumyA6xbdTAbdcoYczW8IhSjy8pi Mkmiob65jAym636tRKFBwvynxuQoXAPooBYGHR1dpamYqO3dwvYi2PCbDujCwTncm3aB gPpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Ks6JOUSL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s3si2500227eds.446.2020.05.27.15.00.24; Wed, 27 May 2020 15:00:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Ks6JOUSL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726086AbgE0VzT (ORCPT + 99 others); Wed, 27 May 2020 17:55:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725320AbgE0VzT (ORCPT ); Wed, 27 May 2020 17:55:19 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4FE5C05BD1E for ; Wed, 27 May 2020 14:55:17 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id t8so2139108pju.3 for ; Wed, 27 May 2020 14:55:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=XCGwhiQvKxhSZLsq2F1qp3/RU6AkenpE+aDBKVz2JUI=; b=Ks6JOUSLY/44DDz35iht8qEtxDiNWKq/Vj83ZsfNnSv/HFvczafFgOcvm1HMHbvmnM a8gSogWiUro72/Cn+cG2ItfwGjxDMP7kRNhtBKhnZESKeps5msUc61BScjjznmCm0lsy f4E0dS+zGayB6t8ZjxaFoEEIpyVCvH5Ed7sxQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=XCGwhiQvKxhSZLsq2F1qp3/RU6AkenpE+aDBKVz2JUI=; b=QYB4p6PIU7goV8yuEupcRCoxRJGwNtPuXNIz2gDsLfz8RVMM4ewJkyzy/pKL62sTjY zMOO1Bhab9vTGPOJJ9qCCOj43YnIs8OqAf+DGJthzBG+HRazzPHlnTOwo7t9mQvdtOBO i4+thoBd3QUGjeRCyUXr5AuIMkWJOKPfZZB510CB/PnvkKBm5UBk4efHkIavFIti/Bp2 /GjN2gTuKu+cHulPZK91H/4jwWYAQ9VC9yNuUz+oKxoQaARCV1bUye5C1aXppLN3Kj9X a5/TG1ud2o3AFIj6FyCQtb6bKS36efCg7QvVhNW2Zn7UAoYjx637xNluCYl8qwQgBSwY y5RQ== X-Gm-Message-State: AOAM533P72Pm8iaMGILcQ3aMvh8keD+axbmOlng/mu99oBWuCWr8dnQf zllU6lgnZdNAxfP0IJT4s9WwchQPs30VXQ== X-Received: by 2002:a17:902:bc89:: with SMTP id bb9mr421513plb.101.1590616517453; Wed, 27 May 2020 14:55:17 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id d67sm2893403pfc.63.2020.05.27.14.55.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2020 14:55:16 -0700 (PDT) Date: Wed, 27 May 2020 14:55:15 -0700 From: Kees Cook To: Andrew Morton Cc: glider@google.com, adobriyan@gmail.com, linux-kernel@vger.kernel.org, sunhaoyl@outlook.com, Al Viro Subject: Re: [PATCH] fs/binfmt_elf.c: allocate initialized memory in fill_thread_core_info() Message-ID: <202005271450.7468AA95@keescook> References: <20200419100848.63472-1-glider@google.com> <20200420153352.6682533e794f591dae7aafbc@linux-foundation.org> <202004201540.01C8F82B@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202004201540.01C8F82B@keescook> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 20, 2020 at 03:41:40PM -0700, Kees Cook wrote: > On Mon, Apr 20, 2020 at 03:33:52PM -0700, Andrew Morton wrote: > > On Sun, 19 Apr 2020 12:08:48 +0200 glider@google.com wrote: > > > > > 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. > > Ewww. That's been there for 12 years. Did something change in > regset_size() or regset->get()? Do you know what leaves the hole? > > > > > > > ... > > > > > > --- a/fs/binfmt_elf.c > > > +++ b/fs/binfmt_elf.c > > > @@ -1733,7 +1733,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, > > > > This seems to be a quite easy way of exposing quite a large amount of > > kernel memory contents, so I think I'll add a cc:stable to this patch? > > Yes please. > > Acked-by: Kees Cook This has been in -next for a while, but we need to get this landed and into -stable. Can you please send this to Linus for the final release? I know Al is working on getting the complementary fixes landed too, but this fix is also sufficient, trivial to backport, and provides some future-proofing/defense in depth. -Kees -- Kees Cook