Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp5432823ybf; Thu, 5 Mar 2020 00:33:54 -0800 (PST) X-Google-Smtp-Source: ADFU+vvk8FH7/tZVWiKTwADwxi+BRgLk3SNChG6FEr3/gdyJ0I4ikuwkyzzJixr/hiE5Lon51SOO X-Received: by 2002:a9d:2264:: with SMTP id o91mr5869142ota.328.1583397234020; Thu, 05 Mar 2020 00:33:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583397234; cv=none; d=google.com; s=arc-20160816; b=0yM17/R3h7l3Fd9DnWhpcvE2wEnuFfNNcB0kekUWxuysyuqbJzxLZkCZ0xDKz+YWN0 gk1C2LjiaMTSH2u11Z/26UXou11O+o9FSL6V0uiVTcSzh1Qnlf+ehwxwyYjNlPn44b2W zcmGhfbrjc2VH1Y7HTtb4GKa9QFg0BmICLsfcw2dlQaGPI8Jx3Tp/TSTIjTGWm05VLXI +KoV3NY5CGv+C0jcBPjdd1Ulx1/Wh/27zfGXQZfpQQRgTj6zFD9hvhha96oiBC9oxSoJ iK02Ojb5cPM/xyZDUXhQB+4yNJD6AqT7Cu+svT8TO5KzFe8fsdIzfqvedGZE5PXwX/zV 01Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=SYxbC9qPC4/N8la63J08DdmEKfQjapCeK8070Jjm4tE=; b=YtJ4tXYQouCFQIAJrR2kZc82l+igeN0qKou8DsjzbXMomQR6iNIuT9oMus1twnD8qB iQxhXqfgn1QTEPJdJGT5OGtstbYyD3lZnenubRw4ZEerSCH3Acb6U8c5FW9TrSCaMoaT qGa1SvmwgD95hhHyoUD6Bnn94e89V0sUYgkIX0j1vncGPE1D6xKP+yZAvRzsqd9Rey/B n8P7rY+E+hPzCYrstk0G22nGgf3hlJYph+BTgCunOBekDSWB3eNXRpu3fLP5Uoi75xap trjkp/FejmK/MNXfNyrqB/YumJcQj1psdkUvfqic4awLl5sz32kYcZ35M4OH4Jlokkvk emsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=pnDwBpEx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z6si3273385oto.204.2020.03.05.00.33.42; Thu, 05 Mar 2020 00:33:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=pnDwBpEx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726145AbgCEIdV (ORCPT + 99 others); Thu, 5 Mar 2020 03:33:21 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:50293 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725924AbgCEIdV (ORCPT ); Thu, 5 Mar 2020 03:33:21 -0500 Received: by mail-wm1-f67.google.com with SMTP id a5so5190964wmb.0 for ; Thu, 05 Mar 2020 00:33:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=SYxbC9qPC4/N8la63J08DdmEKfQjapCeK8070Jjm4tE=; b=pnDwBpExPbjgZWp+2ubL9D0tUj9nEaKK3jT6M7Fn/TH0G3Lbjyut3g6DzXdhjjvMzZ +GwXPkburw2SlIZECET8JCrPSWp08OG9VmI97nCqbT/gCRUWZtZ13dQ+1v1cDc5MGctH 7UqV3uyIM+74eOfjbH888lQp7DrypwbfNMUIJ5VMeU09Y8O8PAL9V2ObNjEhNB2yUN12 IzctO8945uQQ9pj1cnw+4xUjZf4j2N9fKfRQF0mL/yN+nq+k+q3ItDifWlfgVRQB2jKu BzSPkUZ8qbCcAgghnmBJHDgpjV0TZaCPM4kZFXu3JpPW11jebQ1OELOrmpI1tybI/zQB PdiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=SYxbC9qPC4/N8la63J08DdmEKfQjapCeK8070Jjm4tE=; b=IIol7jo+4wxhYnxXS+4mFyvbX87TZRYj6WZDYiqtp1hhIkfXWrHjG81X6Xa072XTIs 0JGqwjeOBgVE3TVKalDbepsqrehdAvQsKGGPqbQyOd8kHKFKqerUGWZY7OyECqQek+vO gqjuOkULajueq/2IyN3/D82JlUMdichNwrYEJ6Pp+K+wFicDppl7/w9GxWDJ1e25dAkU +1J7Fek0MT1iHdbVMUvitaqQrZ9d/5EaERKD1IhgGh+qjui9dvOQcJkYpe1rJkRZxwrR 9VXLeszoQdGPleQ8VUuCKv6dZHpWA+vJTx9vIurxpQzWOcLHNPmvNBwyiWWQcRbb6nJF PVWA== X-Gm-Message-State: ANhLgQ3TYrW94jXXyy5SBTcvp5/4miKVONZEod/mzQwtqMbQVY+igQ6j sClz8htwbNyA0LW4ZkRxEZLFWCO0PLFY0x52KavT1A== X-Received: by 2002:a7b:c254:: with SMTP id b20mr4315045wmj.165.1583397199527; Thu, 05 Mar 2020 00:33:19 -0800 (PST) MIME-Version: 1.0 References: <20200302130430.201037-2-glider@google.com> <0eaac427354844a4fcfb0d9843cf3024c6af21df.camel@perches.com> <4cac10d3e2c03e4f21f1104405a0a62a853efb4e.camel@perches.com> <18b0d6ea5619c34ca4120a6151103dbe9bfa0cbe.camel@perches.com> <20200303093832.GD24372@kadam> <202003040951.7857DFD936@keescook> <20200305080756.GB19839@kadam> <202003050010.A1A965BF37@keescook> In-Reply-To: <202003050010.A1A965BF37@keescook> From: Alexander Potapenko Date: Thu, 5 Mar 2020 09:33:07 +0100 Message-ID: Subject: Re: [PATCH v2 2/3] binder: do not initialize locals passed to copy_from_user() To: Kees Cook Cc: Dan Carpenter , "open list:ANDROID DRIVERS" , Jann Horn , Peter Zijlstra , Greg Kroah-Hartman , LKML , =?UTF-8?B?QXJ2ZSBIasO4bm5ldsOlZw==?= , Ingo Molnar , Joe Perches , Dmitriy Vyukov , Todd Kjos Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 5, 2020 at 9:26 AM Kees Cook wrote: > > On Thu, Mar 05, 2020 at 11:07:56AM +0300, Dan Carpenter wrote: > > On Wed, Mar 04, 2020 at 10:13:40AM -0800, Kees Cook wrote: > > > On Tue, Mar 03, 2020 at 12:38:32PM +0300, Dan Carpenter wrote: > > > > The real fix is to initialize everything manually, the automated > > > > initialization is a hardenning feature which many people will disable. > > > > > > I cannot disagree more with this sentiment. Linus has specifically said he > > > wants this initialization on by default[1], > > > > Fine, but as long as it's a configurable thing then we need to manually > > initialize as well or it's still a CVE etc. It will take a while before > > we drop support for old versions of GCC as well. > > Yes, I agree; that's totally true. We need to continue to fix all the > uninitialized flaws we encounter unless this is on by default for all > supported compiler versions (which will be a looong time). (But it's > not relevant to this patch because copy_from_user() does already do > the initialization.) > > This set of patches was about dealing with the pathological cases of > auto-init colliding with functions that do, in fact, fully init. Though > I must say, I remain concerned about inventing such markings for fear > they'll be used in places where the "trust me, it's fully initialized" > state does not actually hold[1] but the author thinks it does. > > -Kees Right now I'm trying to make Clang understand that output arguments of inline assembly initialize the memory. Then it would be possible to write something like: struct binder_transaction_data tr; asm("": "=m"(tr)); if (copy_from_user(&tr, ptr, sizeof(tr))) ... , and the asm directive can be hidden into copy_from_user().