Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp6337699ybf; Thu, 5 Mar 2020 18:30:29 -0800 (PST) X-Google-Smtp-Source: ADFU+vvlrzHDRbhIllh9wDz1/4FUHPlfrsx5LUckiXRj6UnBOYFRnXL+wf9FYtJHchgBiRAsBgr0 X-Received: by 2002:a05:6830:120c:: with SMTP id r12mr707841otp.333.1583461828943; Thu, 05 Mar 2020 18:30:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583461828; cv=none; d=google.com; s=arc-20160816; b=zOl6katgSPHNq4fqnEnBd1Py4qHuSMvu6kZZdFdRNjSHpb6fl5u0ZmNaq/2OajmYn7 Ra/o7aBZ+7TiSPUmiLWr85GB44RcdAKucStW1td0nKiejXzu5z/27Ti8p0V2UCYNHA1k boRxlLmDsNWFXwYuORSxc2zjRSrTZFJedWpzLQeqsjZi6OBUiLL0RdQHvntb/ftoJHzX JHJ1UdEwH7ArjSVA821gXnAK11mKuV7XnQwoxVvwthf+WByj6oMpzyts3Ss+faQGT0wS nRjKHkA8bFcgbOJAfGuaRoVLVIAJtJUsJsxWdYZJfoT3kboa8klXtxrW3pdyXZAP93nA bWHg== 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; bh=gpNI66uevM5aMHBrueGkLAAHG0uK//JIcxaNFMNeQ+8=; b=NF8mruxO2mt/s9KjnsmSAIbx3n+JnC7opK/muljHUaMTjJ8t7lfmXaMMWAzjecwCUD XknC4wE/7hgLiXVrydcryrQXgzG4jxnxoDAOuoiaRQ98QdqpnF44Zi/KFpqKv3RaETAh UPMRvJNABwevlZItVIrX4Wez9Y/o3SIckTAYKmf7GTt4CczucaEjangUJmTa1WuCdhaJ /ZX3bKafpYi5py3nXO3xQkDbbfSSxhv3i7DCRRRtLMijsyf0ABW/rZ12XuYeN65cAk+e gwdlKobVuZrfPgSbX2VS0ab+sJOzmdELYqLlI7KuJPKx7N6f0+yciIt5KN1WAK+G/24t 4jNA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 65si530812oif.14.2020.03.05.18.30.16; Thu, 05 Mar 2020 18:30:28 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726300AbgCFC32 (ORCPT + 99 others); Thu, 5 Mar 2020 21:29:28 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:53664 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726191AbgCFC32 (ORCPT ); Thu, 5 Mar 2020 21:29:28 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jA2jk-0062dm-0g; Fri, 06 Mar 2020 02:29:16 +0000 Date: Fri, 6 Mar 2020 02:29:15 +0000 From: Al Viro To: Rasmus Villemoes Cc: Jann Horn , Alexander Potapenko , Joe Perches , Todd Kjos , Kees Cook , Greg Kroah-Hartman , Arve =?iso-8859-1?B?SGr4bm5lduVn?= , Ingo Molnar , Dmitriy Vyukov , "open list:ANDROID DRIVERS" , Peter Zijlstra , LKML Subject: Re: [PATCH v2 2/3] binder: do not initialize locals passed to copy_from_user() Message-ID: <20200306022915.GW23230@ZenIV.linux.org.uk> References: <20200302130430.201037-1-glider@google.com> <20200302130430.201037-2-glider@google.com> <0eaac427354844a4fcfb0d9843cf3024c6af21df.camel@perches.com> <4cac10d3e2c03e4f21f1104405a0a62a853efb4e.camel@perches.com> <205aa3d8-7d18-1b73-4650-5ef534fe55da@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <205aa3d8-7d18-1b73-4650-5ef534fe55da@rasmusvillemoes.dk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 05, 2020 at 10:03:25AM +0100, Rasmus Villemoes wrote: > Does copy_from_user guarantee to zero-initialize the remaining buffer if > copying fails partway through? That's guaranteed, short of raw_copy_from_user() being completely broken. What raw_copy_from_user() implementation must guarantee is that if raw_copy_from_user(to, from, N) returns N - n, then * 0 <= n <= N * all attempted reads had been within the range [from .. from + N - 1] * all stores had been to the range [to .. to + n - 1] and every byte within that range had been overwritten * for all k in [0 .. n - 1], the value stored at to[k] by the end of the call is equal to the value that would've been possible to read from from[k] at some point during the call. In particular, for all bytes in range [from .. from + n - 1] there had been a successful read of some object containing that byte. * if everything in [from .. from + N - 1] is readable, the call will copy the entire range into [to .. to + N - 1] and return 0. Provided that, copy_from_user() will leave no uninitialized data in destination object in any case, success or no success.