Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5764759imm; Mon, 23 Jul 2018 05:48:37 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfjW5AcE4f9NSyk++xQayB5faflWYrTXY0Ia8u2c9fQAzA2Cfz5T64UEgLLV8zneONUZGUi X-Received: by 2002:a63:571d:: with SMTP id l29-v6mr11761825pgb.296.1532350117048; Mon, 23 Jul 2018 05:48:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532350117; cv=none; d=google.com; s=arc-20160816; b=Fwo6tQPrWSPCKTJh/IWlIU7M4Unq02Wd5ZZypg9AWy1Pm/1WGmNzvg9yXeyzuZKCNb Z4EdaYWUkkBYnl0E1okrBqpPz+WKBX383Uziy8h62BGW0IJV6+MHnmSRLneDnfC3Zg9F g9ZDN5eyNv8PDUq695XA82Kxk3o19H5z4PQ4v0Q2Yya4/JVrVKNGYNI3u6+elT2FW6n+ S2Qcu3ZeY6zfX9G0cXKr7MZxA+luU5CnEP4Y/ZeifSilGJiIUa5zVRmP/xXUXC5kAjv1 0hPRimrCVTJWvcubmWQzOlEmz07SsgICfshMoY05Osd50ByMJkOjbvSoVIdS53aBCZrk yy0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=rPhDTY4DLzPICG3c8uFEGINwTpfJJ+jU1yh8Qx61iQ8=; b=KuOIrHKI8FV/v1Dng1bgo9CJ53H6cV3/JdqjS4fJ41iVSIDUqv4kmRUpYejAdbNDJi JIF7Qy/PBuhgyyNJo6iyOV+ueJCARVMIbLzPkaUwZQuCEy6okhqtGB1hk1bEbIoBm2Jm mPhmuZvSzJ/bDMlXrK7WhkW9oCvAJl68rDck4Wy1lHn8ZIJamPd85kTav+8uhrcXDyQl I8egTXR/ewG6bq95/6JFhUgWpSXX2LFdEQKcbOUTarGbsXuyTOg/Iwm2gpTkpCwX7iIm MBxWxHeFg+yStQMsGa2bs2HPzt5bh4et8wbYjbk5Ub0HrPAY7IF9ORpWX24dmKF4Z8WR dxgA== 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 u3-v6si8646480pgq.354.2018.07.23.05.48.22; Mon, 23 Jul 2018 05:48:37 -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; 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 S2389829AbeGWNsi (ORCPT + 99 others); Mon, 23 Jul 2018 09:48:38 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:51994 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389813AbeGWNsh (ORCPT ); Mon, 23 Jul 2018 09:48:37 -0400 Received: from localhost (LFbn-1-12238-233.w90-92.abo.wanadoo.fr [90.92.53.233]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 42D5BBB3; Mon, 23 Jul 2018 12:47:33 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kees Cook , Thomas Gleixner , David Woodhouse , "Srivatsa S. Bhat" , "Matt Helsley (VMware)" , Alexey Makhalov , Bo Gan Subject: [PATCH 4.4 070/107] seccomp: Enable speculation flaw mitigations Date: Mon, 23 Jul 2018 14:42:04 +0200 Message-Id: <20180723122416.895662079@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180723122413.003644357@linuxfoundation.org> References: <20180723122413.003644357@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 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 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kees Cook commit 5c3070890d06ff82eecb808d02d2ca39169533ef upstream When speculation flaw mitigations are opt-in (via prctl), using seccomp will automatically opt-in to these protections, since using seccomp indicates at least some level of sandboxing is desired. Signed-off-by: Kees Cook Signed-off-by: Thomas Gleixner Signed-off-by: David Woodhouse Signed-off-by: Greg Kroah-Hartman Signed-off-by: Srivatsa S. Bhat Reviewed-by: Matt Helsley (VMware) Reviewed-by: Alexey Makhalov Reviewed-by: Bo Gan Signed-off-by: Greg Kroah-Hartman --- kernel/seccomp.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) --- a/kernel/seccomp.c +++ b/kernel/seccomp.c @@ -16,6 +16,8 @@ #include #include #include +#include +#include #include #include #include @@ -214,6 +216,19 @@ static inline bool seccomp_may_assign_mo return true; } +/* + * If a given speculation mitigation is opt-in (prctl()-controlled), + * select it, by disabling speculation (enabling mitigation). + */ +static inline void spec_mitigate(struct task_struct *task, + unsigned long which) +{ + int state = arch_prctl_spec_ctrl_get(task, which); + + if (state > 0 && (state & PR_SPEC_PRCTL)) + arch_prctl_spec_ctrl_set(task, which, PR_SPEC_DISABLE); +} + static inline void seccomp_assign_mode(struct task_struct *task, unsigned long seccomp_mode) { @@ -225,6 +240,8 @@ static inline void seccomp_assign_mode(s * filter) is set. */ smp_mb__before_atomic(); + /* Assume seccomp processes want speculation flaw mitigation. */ + spec_mitigate(task, PR_SPEC_STORE_BYPASS); set_tsk_thread_flag(task, TIF_SECCOMP); }