Received: by 2002:a17:90a:728b:0:0:0:0 with SMTP id e11csp2439394pjg; Thu, 30 Apr 2020 11:44:53 -0700 (PDT) X-Google-Smtp-Source: APiQypJ1e8JyJ1ECWnauDw5Aixfz1L95X/cnDV6k8c11t3pyUkfvFmiAFXhQBGmKCa+yeelGRjZ7 X-Received: by 2002:a17:906:391:: with SMTP id b17mr4000563eja.91.1588272293318; Thu, 30 Apr 2020 11:44:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588272293; cv=none; d=google.com; s=arc-20160816; b=VAgyjAvMNSIWoLJylrl2w24vsIjVaQi2+wqG5DOtvJQYTUNKnetbGY/HGWcnIa1OcS N7PnoXjkYT2VujzPqTK3kYj+ElANrirIWX/GWVYlow7irau4QQQ9FpKwh7kOPYO+QcpB R36+FfEwvhLHwCxOwpK7wa9io2FoN+NXkzGXP4Rota3p9BAFVA/VQPRG1ui7D95utRfb w6xv94O2ntcSx9F9DVG7sMQtoXcieNHqGbjyXUYmUbIYG2Vdv7BRCg9A9tQhkAKHzwRW nbSq1l2vd+dM4JxJSTAzaugImFD/IVimHW2ltBjXAXqjUGY5DpqUchMGA46xSlM0F6KB ty1Q== 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=7q6ZT1uM1pI0at0muygJaCUdQPIibQhLmtOmgVauVUw=; b=sOJXu0pUpqjeePLQsX+Qn/B10jwyID06/Ujrsu4YPKhTsjvJtBLstCfB+lG+HJsq1O 5oFHKSOUFu4jYbmAcXloT09RONWPYh6UDCBKgaP9fOxUgktMik6ImWqzkO0O9Dp5p4xf VLhFLJbxmbHvhfjnpCflIM8Anpg6lIdhqNG34Zl365n8fGFXfSZ2SHH3K88mRnS4FaGk b2dbJ07m+LvUXvqzNKlyjGw18ETN9Mas++IkoTU/iCNo1/tbwrEzU6bh7WF4DyuNsdD+ ofKCTwPRIMwWUnfiCmyRszKsUbB8OlugNW/Z9sKvOzK0X603Y3Y6/CwwsUF218KFFQrQ g7UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SKIj3ofh; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i20si244875edx.314.2020.04.30.11.44.27; Thu, 30 Apr 2020 11:44:53 -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=@kernel.org header.s=default header.b=SKIj3ofh; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726420AbgD3Smf (ORCPT + 99 others); Thu, 30 Apr 2020 14:42:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:57906 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726272AbgD3Sme (ORCPT ); Thu, 30 Apr 2020 14:42:34 -0400 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 197E124955 for ; Thu, 30 Apr 2020 18:42:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588272154; bh=R81KA1exG6QyWEvvM1/QecUU8WMGFHG/k/cxKcdkfnc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=SKIj3ofhpyqALEnbxq/Qwt9I+q8xqgFA+l6wnFR3a2eTeE5nVt5QfYHFAwjC/y+Ja s8uytIm5fXDttDTtpNCgxSD0+3yT34ulwtIpiC/VwDctbm4BV5uOySFOyHPHNganWE ftAE+TPkYBb4X9BD4lyjCgOpqW23VPFKogllHC+c= Received: by mail-wr1-f45.google.com with SMTP id b11so8325185wrs.6 for ; Thu, 30 Apr 2020 11:42:34 -0700 (PDT) X-Gm-Message-State: AGi0PuaIfWq+adl0MoIjX21DhQ/3FXnW67N+C1zJWKoVnkYmEo7mMZJz kQASHwFMxHFTKaf0h8EcekpOMkzj5atc1aHCU4zFDQ== X-Received: by 2002:a5d:42c8:: with SMTP id t8mr3902056wrr.70.1588272152368; Thu, 30 Apr 2020 11:42:32 -0700 (PDT) MIME-Version: 1.0 References: <158823509800.2094061.9683997333958344535.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: From: Andy Lutomirski Date: Thu, 30 Apr 2020 11:42:20 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 0/2] Replace and improve "mcsafe" with copy_safe() To: Linus Torvalds Cc: Andy Lutomirski , Dan Williams , Thomas Gleixner , Ingo Molnar , Tony Luck , 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 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, Apr 30, 2020 at 10:17 AM Linus Torvalds wrote: > > On Thu, Apr 30, 2020 at 9:52 AM Andy Lutomirski wrote: > > > > If I'm going to copy from memory that might be bad but is at least a > > valid pointer, I want a function to do this. If I'm going to copy > > from memory that might be entirely bogus, that's a different > > operation. In other words, if I'm writing e.g. filesystem that is > > touching get_user_pages()'d persistent memory, I don't want to panic > > if the memory fails, but I do want at least a very loud warning if I > > follow a wild pointer. > > > > So I think that probe_kernel_copy() is not a valid replacement for > > memcpy_mcsafe(). > > Fair enough. > > That said, the part I do like about probe_kernel_read/write() is that > it does indicate which part we think is possibly the one that needs > more care. > > Sure, it _might_ be both sides, but honestly, that's likely the much > less common case. Kind of like "copy_{to,from}_user()" vs > "copy_in_user()". > > Yes, the "copy_in_user()" case exists, but it's the odd and unusual case. I suppose there could be a consistent naming like this: copy_from_user() copy_to_user() copy_from_unchecked_kernel_address() [what probe_kernel_read() is] copy_to_unchecked_kernel_address() [what probe_kernel_write() is] copy_from_fallible() [from a kernel address that can fail to a kernel address that can't fail] copy_to_fallible() [the opposite, but hopefully identical to memcpy() on x86] copy_from_fallible_to_user() copy_from_user_to_fallible() These names are fairly verbose and could probably be improved.