Message ID | 20190426001143.4983-24-namit@vmware.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EFAC815E9 for <patchwork-linux-mm@patchwork.kernel.org>; Fri, 26 Apr 2019 07:32:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF22B28DA2 for <patchwork-linux-mm@patchwork.kernel.org>; Fri, 26 Apr 2019 07:32:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D336428DA7; Fri, 26 Apr 2019 07:32:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.4 required=2.0 tests=BAYES_00,DATE_IN_PAST_06_12, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=no version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D65E28DA2 for <patchwork-linux-mm@patchwork.kernel.org>; Fri, 26 Apr 2019 07:32:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 956EF6B0270; Fri, 26 Apr 2019 03:31:51 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 637CB6B0274; Fri, 26 Apr 2019 03:31:51 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2D6B06B026D; Fri, 26 Apr 2019 03:31:51 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by kanga.kvack.org (Postfix) with ESMTP id E43BF6B0007 for <linux-mm@kvack.org>; Fri, 26 Apr 2019 03:31:50 -0400 (EDT) Received: by mail-pl1-f200.google.com with SMTP id d10so1438209plo.12 for <linux-mm@kvack.org>; Fri, 26 Apr 2019 00:31:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version; bh=64HAp1aiSsnJ+6SwHGBfPAaWomfs1X7LEUQ04wa1/ZY=; b=qLMtvlIF8QiRmEHMUS97VypPqUP2v444LE+I5rwEkUVy1+vw1Hp2F2sLMBsxkO9F7v 0KnJ+2BpAZwTWYudT7m3XTx3Mgu//O7VvNFh+gUexi5bek/jU80qlkVoF/Odr6R8alam EDZ9hJZRY7AAYbKjK/u75RiCA0in7OZRI9njl9ZRtlP/pQvA6F9cJ/bKGxgW6k5yp6cp pvaQsv2RAlkwM771nm5MzNbgaEihP5mTMoz1xXQq1ut+wuLoyBC3vNZulSpY/ZOtWKNM NRjm9i8nHOFlaSzphTX9QpHjxgnIyT5jtMSb4WKAH3OCKE6lEN92S6GwmdZaRzJUhphZ EDFA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of namit@vmware.com designates 208.91.0.190 as permitted sender) smtp.mailfrom=namit@vmware.com; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=vmware.com X-Gm-Message-State: APjAAAWHlIzXZ+c3CTmne0010LsbLVIo61F2ZoE5C6HS40bCxHfuY+zD ZHSdmxPeBx5KEYH1HoI/9Ywgjc5zsiFDCUg/TR0s8eQ8EziybFDQGhBF0KhvI+eJ6VXfODTzfNp zr7hkaR6Q6oZyv1lWeI4drIvi1cA2sZUHvnORj8mceAMcIkfUFiF2AHdsWDaQMU4myw== X-Received: by 2002:a62:5795:: with SMTP id i21mr16806404pfj.194.1556263910592; Fri, 26 Apr 2019 00:31:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqwWH0t2lD8SJ7EkhKEPHEGLzJJYN3l7Q7NVVVBogB6TDePfI3NsPkmf6t95aH5LQdx8Bmwz X-Received: by 2002:a62:5795:: with SMTP id i21mr16806318pfj.194.1556263909468; Fri, 26 Apr 2019 00:31:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556263909; cv=none; d=google.com; s=arc-20160816; b=ui3b8z+dFWiGS78CYJ2vM6gyUuQMi8XwRLYQTDqFALe2GwTWHKACF9IfbKMJQjSHM9 n0gn5CB/XerE4A3CRUWB15rsOYYMIxoUjTP3nB7arV48FVRzKnpN9SKv99AEwFqxzcmm 6wEMd9U/zcUB2/p3jDsV8D0CiLTPnMpJAPJJ7U22dIFsPzOEYEVKTxCBh570KRMK8uFI 002GUzPqZims0j9XUGKcWVwXvDn5F1FpTKljJJCA0Qq2hLSxCrSVTj0j16tlx7zlKNSi DPEUhPfDg2aqcrltZOIUy2EJj+nYov95e/L/H+isuFN4rHnkcu675a+i42cbeVnK+vHJ 4QZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=64HAp1aiSsnJ+6SwHGBfPAaWomfs1X7LEUQ04wa1/ZY=; b=Ab8BruFXUGNliAQZmJyqotoBe8ha4jOrYZIZxQqVODzN/qVSIOfABSwKtKGMHHrbjB oX60sAuCY6ba9zwTjx0va+oWG/D6GoFyIicq09oydri7rbD8zV0OoKl1fhHQWAjttTgI XfiD1Z4OejZQMGn0ggFEd5ogsi4aUZG+mIZ3Jdp9OPv+bb5UA18RMahF44baUhnfxpO0 dNawx5/ZFfNIK3+XnpDoURkl253iovBwBTZ97dWyR9f56Pkwi4LGEIZt1Hk+4rY9KPqz PaADorcJjQyeMnn0ohZuBRll6KLVIR1Q7gSt46eL/fOCFZiTgaWypdaQNd/R1HEsmKfU u5Og== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of namit@vmware.com designates 208.91.0.190 as permitted sender) smtp.mailfrom=namit@vmware.com; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=vmware.com Received: from EX13-EDG-OU-002.vmware.com (ex13-edg-ou-002.vmware.com. [208.91.0.190]) by mx.google.com with ESMTPS id f9si22844507pgq.347.2019.04.26.00.31.49 for <linux-mm@kvack.org> (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Apr 2019 00:31:49 -0700 (PDT) Received-SPF: pass (google.com: domain of namit@vmware.com designates 208.91.0.190 as permitted sender) client-ip=208.91.0.190; Authentication-Results: mx.google.com; spf=pass (google.com: domain of namit@vmware.com designates 208.91.0.190 as permitted sender) smtp.mailfrom=namit@vmware.com; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=vmware.com Received: from sc9-mailhost3.vmware.com (10.113.161.73) by EX13-EDG-OU-002.vmware.com (10.113.208.156) with Microsoft SMTP Server id 15.0.1156.6; Fri, 26 Apr 2019 00:31:45 -0700 Received: from sc2-haas01-esx0118.eng.vmware.com (sc2-haas01-esx0118.eng.vmware.com [10.172.44.118]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id 32C2B4129A; Fri, 26 Apr 2019 00:31:46 -0700 (PDT) From: Nadav Amit <namit@vmware.com> To: Peter Zijlstra <peterz@infradead.org>, Borislav Petkov <bp@alien8.de>, Andy Lutomirski <luto@kernel.org>, Ingo Molnar <mingo@redhat.com> CC: <linux-kernel@vger.kernel.org>, <x86@kernel.org>, <hpa@zytor.com>, Thomas Gleixner <tglx@linutronix.de>, Nadav Amit <nadav.amit@gmail.com>, Dave Hansen <dave.hansen@linux.intel.com>, <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 <rick.p.edgecombe@intel.com>, Nadav Amit <namit@vmware.com>, Daniel Borkmann <daniel@iogearbox.net>, Alexei Starovoitov <ast@kernel.org> Subject: [PATCH v5 23/23] bpf: Fail bpf_probe_write_user() while mm is switched Date: Thu, 25 Apr 2019 17:11:43 -0700 Message-ID: <20190426001143.4983-24-namit@vmware.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190426001143.4983-1-namit@vmware.com> References: <20190426001143.4983-1-namit@vmware.com> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: None (EX13-EDG-OU-002.vmware.com: namit@vmware.com does not designate permitted sender hosts) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> X-Virus-Scanned: ClamAV using ClamSMTP |
Series |
x86: text_poke() fixes and executable lockdowns
|
expand
|
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index d64c00afceb5..94b0e37d90ef 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c @@ -14,6 +14,8 @@ #include <linux/syscalls.h> #include <linux/error-injection.h> +#include <asm/tlb.h> + #include "trace_probe.h" #include "trace.h" @@ -163,6 +165,10 @@ BPF_CALL_3(bpf_probe_write_user, void *, unsafe_ptr, const void *, src, * access_ok() should prevent writing to non-user memory, but in * some situations (nommu, temporary switch, etc) access_ok() does * not provide enough validation, hence the check on KERNEL_DS. + * + * nmi_uaccess_okay() ensures the probe is not run in an interim + * state, when the task or mm are switched. This is specifically + * required to prevent the use of temporary mm. */ if (unlikely(in_interrupt() || @@ -170,6 +176,8 @@ BPF_CALL_3(bpf_probe_write_user, void *, unsafe_ptr, const void *, src, return -EPERM; if (unlikely(uaccess_kernel())) return -EPERM; + if (unlikely(!nmi_uaccess_okay())) + return -EPERM; if (!access_ok(unsafe_ptr, size)) return -EPERM;