Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp943833pxb; Thu, 5 Nov 2020 18:13:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJyFXVICj/W8jdCpPqRM5RHLRBA4jcvogck2Wnz2opBERkW3a6NgAy55cQFHZDctmIp1hsaS X-Received: by 2002:a17:906:a090:: with SMTP id q16mr5213236ejy.220.1604628822158; Thu, 05 Nov 2020 18:13:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604628822; cv=none; d=google.com; s=arc-20160816; b=zRBbZ413G3H2l+NO30odfYlW/4hma2wEuXCgR1mse4vXIsJwTLiLQG/UydZprr7V0g 1RaoQFkLW2fOc/qM8oDiwJcw4AroLoGU1mqHBRW2bqsIS1WDTEz1ADIex0SoATxXl2eF VZG9qMSaek5XdMPWu0Qt2VnLPLKCQkZsP1Re5NeuSoexnEC5T2WMFBVIuJK9XivPC9ew EKrQMoPthfBr0wm1aRg/sSqPjgTN3J//q42TSErgvsJdcBz+tTEv0P8n2vWAmbfd0YJE njPUpKpO39/H6fP88nzaD97qKgxsslB6RHh66EmGSY8dY1inlopQXc1CBFEo0wIXMDj5 GMxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :sender:dkim-signature; bh=T1ssYQnlZfXYg4a9CrE5sQuW0tqmDafqmdVBZ8OGyYk=; b=SjALBQwO0QoTuJAdS3suuytFNEZkq0EB6E5RvSOK8ovlRnuG5UOF3HXHa0IF7i+QL6 UhplM8JkEZcX75risogi28nh6DzRANflRGqZ89IaJ8+oyhFlG4Xq/vqNtYTJoxa4EYFU WAPJEA/x8IbrY2WX8H+wT+7JRwFz53nboD2Cq+/oB2EIZKASAP7MUUuozyCXswV/1ivI FtPh6f0ez08gGnsLUjILDntYR5U7Guiw4n3VKODq0rw0EReKcP0gBbtI2uB98tIn74bI vgtVkEmXLS+NicKT5Rz/xyr5DPB993IXi6TBiczDlZja9uzLxZrgMCcAx0B+pJBIFXCv kquA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=TcY9DZhY; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s11si2704546edj.7.2020.11.05.18.13.19; Thu, 05 Nov 2020 18:13:42 -0800 (PST) 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=@google.com header.s=20161025 header.b=TcY9DZhY; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726276AbgKFCLa (ORCPT + 99 others); Thu, 5 Nov 2020 21:11:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726126AbgKFCLa (ORCPT ); Thu, 5 Nov 2020 21:11:30 -0500 Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F58DC0613D2 for ; Thu, 5 Nov 2020 18:11:30 -0800 (PST) Received: by mail-qt1-x849.google.com with SMTP id l67so2169326qte.6 for ; Thu, 05 Nov 2020 18:11:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=T1ssYQnlZfXYg4a9CrE5sQuW0tqmDafqmdVBZ8OGyYk=; b=TcY9DZhY0raayijWagcNzm4ZuafclgG6HVA/Sz1qQnQJQOIfbQHvvL7RNmX+9P4UtB oU5bGzkYPf4vBagfhZ2H/5dyyrnXt2KXH8nnnG2AAxOAKVFlIPmODwO7U/oeJDRH6+p2 2hsqKwA3RN+85OY3avD3vLPbAHTg8vq3LucXtnw688M7egI3PZ/CkuxKILVTw58owe1l MSo5HTPx4dp7XvFGzTLI2u4EM2xDdWyBkvnLzI1lar1APXh0aZ2ah+upKTkO85OeywV3 g1Medy/bw7NowmvGMbavBgzcDTJ7aBszMcbHGS8Ho/CWoztR11RpNPqQ+yW6AJJvdKBO 8mYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=T1ssYQnlZfXYg4a9CrE5sQuW0tqmDafqmdVBZ8OGyYk=; b=WWQmCaPcnBgyGDkdsk+4K3ZrD5aTUGPngrnuhTPXmWOtUNA/ME8E1bfrupEM4dMFE0 sV+KDXGBmdSPqW5s6usvaWhmS3I4m7LY6MwkTItlCXdGEaIcUz+4PvT8gz1TH7+PO9t8 fFDXVFmEhCNxPDypy0IvSy8lohRolp1PXjs8DH6TnpQgFpJsCfj6CbYtyx8G8CHCl58z tKBXSGa9ca2vwIktG8vtwPsw/5peFXV4cJoNimnAN/Kq2vBf3BrLVPBU2XvsGRw7DSNL sRwxBVgzanSNo9EMqNAWFLERrTAhKDdPeQw/b+lj5Nj167moS/jO7uxG4Qhp99HCWqta DTnA== X-Gm-Message-State: AOAM533UE4mWiL+PV1lGMU9aiEirwdI9swuyGYSN+MC7A95UxK0UCISr Y4wdDeR5U2YT5lWJhuAEC81aIgED3KBT Sender: "amistry via sendgmr" X-Received: from nandos.syd.corp.google.com ([2401:fa00:9:14:725a:fff:fe46:72ab]) (user=amistry job=sendgmr) by 2002:a0c:8e4f:: with SMTP id w15mr665237qvb.42.1604628689164; Thu, 05 Nov 2020 18:11:29 -0800 (PST) Date: Fri, 6 Nov 2020 13:10:43 +1100 Message-Id: <20201106131015.v2.1.I7782b0cedb705384a634cfd8898eb7523562da99@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog Subject: [PATCH v2] proc: Provide details on indirect branch speculation From: Anand K Mistry To: linux-fsdevel@vger.kernel.org Cc: asteinhauser@google.com, sfr@canb.auug.org.au, rppt@kernel.org, joelaf@google.com, tglx@linutronix.de, Anand K Mistry , Alexey Dobriyan , Alexey Gladkov , Andrew Morton , Jonathan Corbet , Kees Cook , Mauro Carvalho Chehab , Michal Hocko , Peter Zijlstra , Randy Dunlap , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Similar to speculation store bypass, show information about the indirect branch speculation mode of a task in /proc/$pid/status. Signed-off-by: Anand K Mistry --- Changes in v2: - Remove underscores from field name to workaround documentation issue Documentation/filesystems/proc.rst | 2 ++ fs/proc/array.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst index 533c79e8d2cd..531edaf07924 100644 --- a/Documentation/filesystems/proc.rst +++ b/Documentation/filesystems/proc.rst @@ -210,6 +210,7 @@ read the file /proc/PID/status:: NoNewPrivs: 0 Seccomp: 0 Speculation_Store_Bypass: thread vulnerable + SpeculationIndirectBranch: conditional enabled voluntary_ctxt_switches: 0 nonvoluntary_ctxt_switches: 1 @@ -292,6 +293,7 @@ It's slow but very precise. NoNewPrivs no_new_privs, like prctl(PR_GET_NO_NEW_PRIV, ...) Seccomp seccomp mode, like prctl(PR_GET_SECCOMP, ...) Speculation_Store_Bypass speculative store bypass mitigation status + SpeculationIndirectBranch indirect branch speculation mode Cpus_allowed mask of CPUs on which this process may run Cpus_allowed_list Same as previous, but in "list format" Mems_allowed mask of memory nodes allowed to this process diff --git a/fs/proc/array.c b/fs/proc/array.c index 65ec2029fa80..014c1859554d 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c @@ -368,6 +368,34 @@ static inline void task_seccomp(struct seq_file *m, struct task_struct *p) seq_puts(m, "vulnerable"); break; } + + seq_puts(m, "\nSpeculationIndirectBranch:\t"); + switch (arch_prctl_spec_ctrl_get(p, PR_SPEC_INDIRECT_BRANCH)) { + case -EINVAL: + seq_puts(m, "unsupported"); + break; + case PR_SPEC_NOT_AFFECTED: + seq_puts(m, "not affected"); + break; + case PR_SPEC_PRCTL | PR_SPEC_FORCE_DISABLE: + seq_puts(m, "conditional force disabled"); + break; + case PR_SPEC_PRCTL | PR_SPEC_DISABLE: + seq_puts(m, "conditional disabled"); + break; + case PR_SPEC_PRCTL | PR_SPEC_ENABLE: + seq_puts(m, "conditional enabled"); + break; + case PR_SPEC_ENABLE: + seq_puts(m, "always enabled"); + break; + case PR_SPEC_DISABLE: + seq_puts(m, "always disabled"); + break; + default: + seq_puts(m, "unknown"); + break; + } seq_putc(m, '\n'); } -- 2.29.1.341.ge80a0c044ae-goog