Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp794996imm; Mon, 21 May 2018 14:36:38 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp6e8ZKJDN/hwlBvuvc2wUDzzSEI9TIzCINmOcYoguRvkkCWgsdtS3JgS2CgTD5Xct3ygcZ X-Received: by 2002:a62:c050:: with SMTP id x77-v6mr21546724pff.67.1526938598796; Mon, 21 May 2018 14:36:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526938598; cv=none; d=google.com; s=arc-20160816; b=aMxkTFxSLaj3dFKaXvlvUOQ5UAH8i271ef4pOe5JFETQXPbasAyS9poocGHUHpoCsc nesyV0mKfVEDjYpS8yKQivsA4ftKuywEPAM3GVuOVurKa45abuEyJls4R/iTKBoGw5Y/ XKaaIRqQESyqp80ZSDGoueVtiVlagJk5U6US6ePw3EcC9i0/13eHF9eH0OWmpgcxEUef Czbsfx0nIKhlPscixAM/2gn82JDADj57lcXkb68Aqq+dyQEbK7cTe4MJK2Vr10hjLapz uUmRVdO0uWsQA2DsTXd23M13ikvfiOa+P1B7t/lxqU6Pon96jM+MFIsqWV+8UVviRsyX 59gg== 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:dkim-signature :arc-authentication-results; bh=5k+jCXeZElESmgCEwhvukMfLEhRQ2C92YTXoktUu6ho=; b=Cbqtk+6eMMrDkQe4k3UFbM5JqeyFgCEbOUExLSmwrdypF5DK2kulBI6hmvQQkSFLbT D0i1r5ep8X2uJ424tT9lE7rxlFveMd3uPoBdvDn8uy27OCk8p6fJpvpYNvizt+uWfSZY tge3NIc4PSa9MzBWKmEeQjtpQoUCGDVjA+sN9a2ZN1RypikDH7rvZAh4D1YPhKtsjgoL W7xEfO/BtSuTS4kZKZFTIP1zVpwcsw0suwfxehY8HbPxyg7YpKVyaQYpTuo9Qs2s1rIT 4G8w8GF3JgAt6RfytDIK8aW3p0lE+d/wIbLrUXp6ZQ9uI8kQ+9TQpbN8m5aLMpQ2/W8J glkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mKWhYW+1; 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 33-v6si15216490plf.308.2018.05.21.14.36.24; Mon, 21 May 2018 14:36:38 -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=@kernel.org header.s=default header.b=mKWhYW+1; 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 S1754519AbeEUVgQ (ORCPT + 99 others); Mon, 21 May 2018 17:36:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:40420 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932457AbeEUVZe (ORCPT ); Mon, 21 May 2018 17:25:34 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EBA5420853; Mon, 21 May 2018 21:25:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1526937934; bh=2jR+GXUbm+fz1uSSe5+3ddsJL3U/ttkxtcncow1cbeo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mKWhYW+1oqwJ11t+Rd0U3vNUrI9oyCfC8ISmbR1lItbEQSAXuD81YJFwRlG1mpK7I uq2q4xScEHCuSi0gqUwtuGXgyH/Zpg3cucEVRW8ZqlNUgCD4XW/CMyljnNsZofWv/Z hqDz5q4+qxc9I1H/GVE10EWWusiAmJMhPH7B6/1I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kees Cook , Thomas Gleixner Subject: [PATCH 4.16 080/110] seccomp: Enable speculation flaw mitigations Date: Mon, 21 May 2018 23:12:17 +0200 Message-Id: <20180521210513.359362358@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180521210503.823249477@linuxfoundation.org> References: <20180521210503.823249477@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.16-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: Greg Kroah-Hartman --- kernel/seccomp.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) --- a/kernel/seccomp.c +++ b/kernel/seccomp.c @@ -19,6 +19,8 @@ #include #include #include +#include +#include #include #include #include @@ -227,6 +229,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) { @@ -238,6 +253,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); }