Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp105700ybz; Thu, 30 Apr 2020 17:25:33 -0700 (PDT) X-Google-Smtp-Source: APiQypIoEY/XFvpY0oGvoy27qqwdQEWnTblLtqg365oL6ea7ZfwMGAgNoLD2+CU1uaqHgctp8h1o X-Received: by 2002:a50:b961:: with SMTP id m88mr1513177ede.4.1588292733340; Thu, 30 Apr 2020 17:25:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588292733; cv=none; d=google.com; s=arc-20160816; b=WbrzHV4QUrYo34NlNl5J9qVEqXeIL76jFDy5qLVgOjPorVeDEPp8+TBgP8Mo0d+ZKF pXm9bHjGbjVqvGeeW+Oi6sIDiDuBfZfY9kSGdvfkjAmMXsPQNiaUXSsF5jjv3N4Thmpq tLkcmQ7P1jLxTQTmUmi2dbkxiRej7SYVjUP6/3MCj+nPYyF5KgEWe3uK3ATODGSHQ3ZN pgASuEQbYm58ogJ542NpFDn4y7IC7pBzTWQF9gEagxTegq9M71zjzGB6kJyu6Pm1IoBm jMgid2i+3luncmFKp8tvNbnQ5cF1cwcxYqllCwH4K8Fj6Y7mMdUUgSfvfKn5XfU5wZrT MQ1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:in-reply-to:cc:references:message-id :date:subject:mime-version:from:content-transfer-encoding :dkim-signature; bh=q6XSSbORtzdGM5wsbVVdblLZLp4drz8TDfwttIDJ1z4=; b=EHuDc6xx2UfbAK76+zgWCak6JdksR7HZYLRAvTW4gRs2qSEspCql/lDu+rWPyb1pBi ZNpOvwbxZMUncCU7DtJq9GY0ZiLUAb3mmZ7qSWXcCH9UyB5FUSpSUbgf61yLpITUWYD4 X6LjZUQJ2BkZ3HvkgnIcgx2i3W5MEzUpRYa9TihGyhd1prEJYjob3gvtgcJPk5/sZQs4 E5qz0cgNufiepotBU7hpltcEgv6sLUyd1LW4s0vb4uyAOXWWwTDuG/BvYZnAfwQ/hD1k QYTaJ2+V3D6YL2YUg+wCW1fmriO+42IilmMH8SFdOjy+Pc1TADDiUdvpJ4i1a6CTxauE veNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=r4d1DSiL; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oq22si746926ejb.213.2020.04.30.17.25.09; Thu, 30 Apr 2020 17:25:33 -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=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=r4d1DSiL; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727891AbgEAAXf (ORCPT + 99 others); Thu, 30 Apr 2020 20:23:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726545AbgEAAXf (ORCPT ); Thu, 30 Apr 2020 20:23:35 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04863C035495 for ; Thu, 30 Apr 2020 17:23:35 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id f8so3048558plt.2 for ; Thu, 30 Apr 2020 17:23:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=content-transfer-encoding:from:mime-version:subject:date:message-id :references:cc:in-reply-to:to; bh=q6XSSbORtzdGM5wsbVVdblLZLp4drz8TDfwttIDJ1z4=; b=r4d1DSiLI7OzhNnrgDQYPizLp5Uolgf7Mc7ZMXQsfzXIivOBc1mAMesjCUhkWWIi2y yex588qrp8KlVr1SuLZUCj9OssMwY+aaAfCKjy+x9+JfSDfBS1Y/gdhgJEH3q8iiqNex iDvrz7IM41lpzKYWJEv4iBMdnX7oCb0T30GM+GIC5l5Y9epnFFE69w6a4yfNUb5zdep1 faAEeWjW4wlEC6m2J+TuNWxWVWiWbHwVnhwmwehvckJUO9vNL5ReuvTC8nMM66+/SQYe QSm0RTZ8YdH0IZK2Jqm+j2sNapESRzuwTfkfqlKsYv8m5cvyFuWu8KPZsccCLJzeSRtV DVLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=q6XSSbORtzdGM5wsbVVdblLZLp4drz8TDfwttIDJ1z4=; b=Z0uwW+1dKDuT7elBP5lex7OvOc5xA1k+0L5GKawWSUY//tR1RQpj6NH6OfJloy2fhU CtOTwOU8qY6hTbl9svZQ/36R0001Ey7MzCW57ccV9XRDUbdVFU0Eb1ybp4b5gD0qTEiC /sUYLCooaYni1BX/ipi6vp8k77p7sMyey6KAxbatHS3HSIEHABHEUmx1xMPpEnz3Keh8 uEYtE53gXaO2ATXdyVrcAOjKVo2LqdOE9chNgH5juhiVpG7nMDuD372BA0uXe2xmtc+F nihxS1YSFRsTuEvSyatMsNhlNG3yFFa+UiLlevWGLTq+1wy+KYC9VK69cQoUnUZBsAnE GMFA== X-Gm-Message-State: AGi0PuaRkeeHXBPgwRIdRH2BKm0TXIkTjvPXMZVB780kQEc2jsoeqXf5 ZtKwQQlsRq9AKV0LcH87HSCdhQ== X-Received: by 2002:a17:90a:fe06:: with SMTP id ck6mr1694160pjb.4.1588292614361; Thu, 30 Apr 2020 17:23:34 -0700 (PDT) Received: from ?IPv6:2601:646:c200:1ef2:d495:581b:d692:e814? ([2601:646:c200:1ef2:d495:581b:d692:e814]) by smtp.gmail.com with ESMTPSA id c2sm781538pfp.118.2020.04.30.17.23.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 30 Apr 2020 17:23:33 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Andy Lutomirski Mime-Version: 1.0 (1.0) Subject: Re: [PATCH v2 0/2] Replace and improve "mcsafe" with copy_safe() Date: Thu, 30 Apr 2020 17:23:31 -0700 Message-Id: <1962EE67-8AD1-409D-963A-4F1E1AB3B865@amacapital.net> References: Cc: Dan Williams , "Luck, Tony" , Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Borislav Petkov , stable , the arch/x86 maintainers , "H. Peter Anvin" , Paul Mackerras , Benjamin Herrenschmidt , Erwin Tsaur , Michael Ellerman , Arnaldo Carvalho de Melo , linux-nvdimm , Linux Kernel Mailing List In-Reply-To: To: Linus Torvalds X-Mailer: iPhone Mail (17E262) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Apr 30, 2020, at 5:10 PM, Linus Torvalds wrote: >=20 > =EF=BB=BFOn Thu, Apr 30, 2020 at 4:52 PM Dan Williams wrote: >>=20 >> You had me until here. Up to this point I was grokking that Andy's >> "_fallible" suggestion does help explain better than "_safe", because >> the copy is doing extra safety checks. copy_to_user() and >> copy_to_user_fallible() mean *something* where copy_to_user_safe() >> does not. >=20 > It's a horrible word, btw. The word doesn't actually mean what Andy > means it to mean. "fallible" means "can make mistakes", not "can > fault". >=20 > So "fallible" is a horrible name. What I was trying to get at was not =E2=80=9Ccan fault=E2=80=9D but =E2=80=9C= can malfunction=E2=80=9D. Maybe =E2=80=9Cunreliable=E2=80=9D? Better words= welcome. >=20 > But anyway, I don't hate something like "copy_to_user_fallible()" > conceptually. The naming needs to be fixed, in that "user" can always > take a fault, so it's the _source_ that can fault, not the "user" > part. I don=E2=80=99t like this. =E2=80=9Cuser=E2=80=9D already implied that basi= cally anything can be wrong with the memory =E2=80=94 it can be unmapped ent= irely, it can have the wrong permissions, it can have the wrong protection k= ey, it can have an ECC error, etc. If the operation you want is =E2=80=9Cco= py from unreliable kernel memory (but with a definitely valid pointer) to us= er memory=E2=80=9D, you want copy_unreliable_to_user(). Now maybe copy_to_user() should *always* work this way, but I=E2=80=99m not c= onvinced. Certainly put_user() shouldn=E2=80=99t =E2=80=94 the result wouldn= =E2=80=99t even be well defined. And I=E2=80=99m unconvinced that it makes m= uch sense for the majority of copy_to_user() callers that are also directly a= ccessing the source structure. I also tend to think that the probe_kernel stuff should just stay separate. T= hose are really for two totally separate types of use: either the kernel is t= rying its best to print an errr message without exploding worse, or it=E2=80= =99s involved in eBPF or trading hacks in which address is arbitrary and ess= entially untrusted.