Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1474913yba; Fri, 26 Apr 2019 23:45:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqxmD6LrfNUOMNuYJFvCwXLKn6sTp5v8BhYGQvbvFyGDMTbqVWouNNur6YZ+1thIRQunGTsc X-Received: by 2002:a17:902:e58e:: with SMTP id cl14mr9386575plb.85.1556347517410; Fri, 26 Apr 2019 23:45:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556347517; cv=none; d=google.com; s=arc-20160816; b=q6Dq/Y/oMRR/gMuW4sf8hgqD2LesOyGxIqVowDPaqRKUk2XX43ai/+Dx1dOnrhTMdb zvuC+CCKZvfrMrRFeiX2ahfBsvEMbqq+dHpY3uMprvIQdpCEmfvZyBe+ofjg2J7ZvY49 frB4/zPiT2F0iTL+AOhRx8DL1qKPqBoS7K+N9Ut0l/Ms1hTqtGfKZt55m/DZf0ZZJR/z SqHxjLUiTN8bEOVBIBtYsCr0fvbWCrJnMnDgXKXzaPv7s+ySJjG3l8/pfsz2u6sVW6Xc a8GiMVt+C6FHPbDXP1w8GIxx59+I6/rPwdYiBFfW3bf3eM2Sw9J9YC6+JOFi7WjXiRO4 FJCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=p6XVxxmeId6Fyrw7m3B0ifgQzW6nhwdk5H1SAhfRKS0=; b=AEOOfP2goDflDPzlmCcJ2JjrSexGBj0w2H3R9Ys2Z+WYU5se1p9UQwkuxda3ITPS2Q W42tpNA0R2c9Xfog37B0UxVd1S4P0nORHxOzD7DU2qBUDT7AP/ubsZJwrtkxHf1Nul/h Snkz59iJXWUR2emao8Kdx8ezHzeqGQZb6Bg2Ikc4H+le8zt/teGFoX5JXb1mCCB8tAUz S8ftoa3m/NURgbGmHlQAP2uhV4kuAB8sQ5wQ88kBU3/zFXHQb7XFvE5A8HdVXpMi3iUI 6MQwyRiGIUzKy+s4WphX9Mp2cKvAc3lmaA6v4JAB7y1Ta4TzxWKki2if2aX/SK+dDya5 PglA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JScJif31; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o15si5483795pgb.393.2019.04.26.23.45.02; Fri, 26 Apr 2019 23:45:17 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=JScJif31; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726977AbfD0Gns (ORCPT + 99 others); Sat, 27 Apr 2019 02:43:48 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:45685 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726824AbfD0Gnh (ORCPT ); Sat, 27 Apr 2019 02:43:37 -0400 Received: by mail-pl1-f193.google.com with SMTP id o5so2559510pls.12; Fri, 26 Apr 2019 23:43:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=p6XVxxmeId6Fyrw7m3B0ifgQzW6nhwdk5H1SAhfRKS0=; b=JScJif310IMh72ZohwOauSCAwdoUkuEv8bR6xdhJcKtk1RynLwO3Yk/O8uL4tZE53n NrQxpNK4N1uzjciA1sdkWWtPp8ycpHXFn7qqLzJr7tYIRLsxhiosMqxmPVmHzIChx8+N dySb7k6fhrhmrpcilrlJoW9blvaY3Q+PCSiONh6FBKvoxbL7qSMy7/IzPS7lXjYYk3R/ KYc3BtX2zUuYUpbQToVTJQ3xLcXFtZGa0gKnazTNuB9oRgES+e5Dt6lyOMWvmuEim8L6 0oOzDDk8SIoEGUBtvVZ7G2upgHOvvdwFGoH6Y4DMveFflSyOioLkC8F7etEF6M59+eVc h1Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=p6XVxxmeId6Fyrw7m3B0ifgQzW6nhwdk5H1SAhfRKS0=; b=LyWYEmbBpNVVbvN9h2qTIWyJbVDxaHuKUcymYtgVieDWwAn4sRTR8C1KMHYF75e7ZL y4DA7keD9mModIuM3Bc5+r7jYMJqW5nPDmR44ReLh5QvRhCk7YNysu5AjQea8oPdRvnn E7OT7KacbPAhPpz2w47+dtYZSeo95unBtLpoxVh3I3+fK2AgBItnUG+aUBDAPkX9H/N8 21wHuPAeYxC7lVj9CFIRRmYkfKCCr77xjMBuO3+EGZiQxzZE/VWdzmx6zLyTZoNe+piD SPWRwxEn9f77YvGhzWtAH7d90pwPXGuP28jItHvDd48WqGo3SoRog5D8tkKBEgXYZuxl 23yQ== X-Gm-Message-State: APjAAAUIvQtvDYpD9Au0UShuWf5YI8brh8QNWzm9xHzyIFxlOhB96IuM C8LGFYGZIdxIMi43EX75C5E= X-Received: by 2002:a17:902:d83:: with SMTP id 3mr52113119plv.125.1556347416975; Fri, 26 Apr 2019 23:43:36 -0700 (PDT) Received: from sc2-haas01-esx0118.eng.vmware.com ([66.170.99.1]) by smtp.gmail.com with ESMTPSA id j22sm36460145pfn.129.2019.04.26.23.43.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Apr 2019 23:43:36 -0700 (PDT) From: nadav.amit@gmail.com To: Peter Zijlstra , Borislav Petkov , Andy Lutomirski , Ingo Molnar Cc: linux-kernel@vger.kernel.org, x86@kernel.org, hpa@zytor.com, Thomas Gleixner , Nadav Amit , Dave Hansen , linux_dti@icloud.com, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, akpm@linux-foundation.org, kernel-hardening@lists.openwall.com, linux-mm@kvack.org, will.deacon@arm.com, ard.biesheuvel@linaro.org, kristen@linux.intel.com, deneen.t.dock@intel.com, Rick Edgecombe , Nadav Amit Subject: [PATCH v6 23/24] mm/tlb: Provide default nmi_uaccess_okay() Date: Fri, 26 Apr 2019 16:23:02 -0700 Message-Id: <20190426232303.28381-24-nadav.amit@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190426232303.28381-1-nadav.amit@gmail.com> References: <20190426232303.28381-1-nadav.amit@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nadav Amit x86 has an nmi_uaccess_okay(), but other architectures do not. Arch-independent code might need to know whether access to user addresses is ok in an NMI context or in other code whose execution context is unknown. Specifically, this function is needed for bpf_probe_write_user(). Add a default implementation of nmi_uaccess_okay() for architectures that do not have such a function. Signed-off-by: Nadav Amit Signed-off-by: Rick Edgecombe --- arch/x86/include/asm/tlbflush.h | 2 ++ include/asm-generic/tlb.h | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h index 90926e8dd1f8..dee375831962 100644 --- a/arch/x86/include/asm/tlbflush.h +++ b/arch/x86/include/asm/tlbflush.h @@ -274,6 +274,8 @@ static inline bool nmi_uaccess_okay(void) return true; } +#define nmi_uaccess_okay nmi_uaccess_okay + /* Initialize cr4 shadow for this CPU. */ static inline void cr4_init_shadow(void) { diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h index b9edc7608d90..480e5b2a5748 100644 --- a/include/asm-generic/tlb.h +++ b/include/asm-generic/tlb.h @@ -21,6 +21,15 @@ #include #include +/* + * Blindly accessing user memory from NMI context can be dangerous + * if we're in the middle of switching the current user task or switching + * the loaded mm. + */ +#ifndef nmi_uaccess_okay +# define nmi_uaccess_okay() true +#endif + #ifdef CONFIG_MMU /* -- 2.17.1