Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3462653rwb; Mon, 3 Oct 2022 15:44:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6UFw2rXMetsPra3bVKPkZX69q90BAtKfzry0rlyOk6Z9tr3holWs45RXV1O+Ov/YQ6jsHB X-Received: by 2002:a63:1455:0:b0:438:e26b:ab1f with SMTP id 21-20020a631455000000b00438e26bab1fmr20267455pgu.183.1664837077979; Mon, 03 Oct 2022 15:44:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664837077; cv=none; d=google.com; s=arc-20160816; b=X5A3FrL0Qo62324ARWAWwVbpWF6RIknqerNqbXcYIk3I1trTk1SqXSMRNoknpEhfoL s1IQUPdJJGFQyrkz6kGeHsQd++k7MnirBxUcBM/g7TYXKDDiW+JOuLiIP0bJRQ7DiLm6 NLVMPzKuKwDYPmd+Eq65TFM2O/bEsJSDJPOD7NXLmfh2cogOWl01ExWAUZzkDOnxY4qy vast66wXUoViZ2Ds3WPSEKmpl0dJSidVhkAQ7SgvIMZSTGMj15Cy+73KpdA5QygyaBQ4 fR4gxJ2BeRKOqPGB6pg3VHqcePG5fi6ddxKloPZ9nTArpefjU3u6p9T41N39hWd/aqOZ ATBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=1aT8gZ8YBZYKdqdpocYzKcdp4QTwJIFBwIdyk+5hEXw=; b=LWLZARu7e1mdtA8xf9fMmUoH8nv4u5aUzmug//Nx+6lSzp5qPIPvSn3mNVdImcMrFa d5Ytj+7uyFEsneEs7egv2EaMaDUBieSX8f/6DGBWFI9RdDpK4Kx+XUPont6JtaIJhp+H kJ+4xBX+k/qYtaW0KO1DYCXpcJvLBKC2APW2J9dqroGa/LsYjqKYtYcQG6p1Dh9isxth kWmZcaTZozAs9O7nl8FRCzB0DUkCwNHkmLZ2uKO4/GblaNH4UcFxRVdcgw9JfrWIdmZb cGU7UbGgvRLm3MDePSeDyq8MhWQ50OqRaqwE73NrmhaoyIdPvcNa1Vz1tbdXU0kSBvO9 6Reg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=IaidlPUL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f16-20020a056a0022d000b00543bb97c41esi12715097pfj.30.2022.10.03.15.44.26; Mon, 03 Oct 2022 15:44:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=IaidlPUL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229660AbiJCWiF (ORCPT + 99 others); Mon, 3 Oct 2022 18:38:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229572AbiJCWiB (ORCPT ); Mon, 3 Oct 2022 18:38:01 -0400 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28FAB43622 for ; Mon, 3 Oct 2022 15:38:00 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id c24so10939417plo.3 for ; Mon, 03 Oct 2022 15:38:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=1aT8gZ8YBZYKdqdpocYzKcdp4QTwJIFBwIdyk+5hEXw=; b=IaidlPULvIyiGqDbE5G7hS3w3xKB26x3hcYRXrEqxDsI9zc++O1gmvMKq1f0bVzeds 8K3lX19RjkueqxRMkTMpp/Tft7xUjQyCx9JY8efa7Mdv7WHNvG66ggXMUtulLE/e4hZG DE2eXd2F1WQ0D9XVOFchXwKVBV6do3UTeiNMw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=1aT8gZ8YBZYKdqdpocYzKcdp4QTwJIFBwIdyk+5hEXw=; b=EFdUPyWvBboPVP6g+WSXvautvtRB8HfuiLVQEuDwRqJyZvabhiKyvV33KpKRVMeSDy 8n920LKOGGpngnS2QkWC+hm9MfCkm9UEZsd2DIMlI6kppdOOf0bR/x133cKWIZ0wQQWy XTr7pQIrB+NvArxJG+dViXwhWUlUfV4iLqjLod82NHgm1pJxfRfpXtMjCLvoYIMTP8gK W7z2XjaeAnQWhmGMV6IjOgtH4Yy7V3zsPihnLVSxh/JymKg0t7bYqXptbkPpegMYXOaT IKe6kAxIGzqHxkp6CXRMBNqYPt4gjZWhMao5ZcVHGTrxHHIzbD/iomazxpo0i6jp3tC9 pU1w== X-Gm-Message-State: ACrzQf1+hUZppI/N5yj58DpzAXF2ut6F34XlDGadFXEeDEtVIPqEFdM/ P6KxhZr4We5N7CJRKrcwvmJbQg== X-Received: by 2002:a17:902:a9c6:b0:178:b2d4:f8b2 with SMTP id b6-20020a170902a9c600b00178b2d4f8b2mr23901915plr.79.1664836679530; Mon, 03 Oct 2022 15:37:59 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id d4-20020a170902654400b001769206a766sm7624887pln.307.2022.10.03.15.37.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Oct 2022 15:37:58 -0700 (PDT) Date: Mon, 3 Oct 2022 15:37:57 -0700 From: Kees Cook To: Rick Edgecombe Cc: x86@kernel.org, "H . Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Andy Lutomirski , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H . J . Lu" , Jann Horn , Jonathan Corbet , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V . Shankar" , Weijiang Yang , "Kirill A . Shutemov" , joao.moreira@intel.com, John Allen , kcc@google.com, eranian@google.com, rppt@kernel.org, jamorris@linux.microsoft.com, dethoma@microsoft.com Subject: Re: [PATCH v2 30/39] x86: Expose thread features status in /proc/$PID/arch_status Message-ID: <202210031530.9CFB62B39F@keescook> References: <20220929222936.14584-1-rick.p.edgecombe@intel.com> <20220929222936.14584-31-rick.p.edgecombe@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220929222936.14584-31-rick.p.edgecombe@intel.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 29, 2022 at 03:29:27PM -0700, Rick Edgecombe wrote: > From: "Kirill A. Shutemov" > > Applications and loaders can have logic to decide whether to enable CET. > They usually don't report whether CET has been enabled or not, so there > is no way to verify whether an application actually is protected by CET > features. > > Add two lines in /proc/$PID/arch_status to report enabled and locked > features. > > Signed-off-by: Kirill A. Shutemov > [Switched to CET, added to commit log] > Signed-off-by: Rick Edgecombe > > --- > > v2: > - New patch > > arch/x86/kernel/Makefile | 2 ++ > arch/x86/kernel/fpu/xstate.c | 47 --------------------------- > arch/x86/kernel/proc.c | 63 ++++++++++++++++++++++++++++++++++++ > 3 files changed, 65 insertions(+), 47 deletions(-) > create mode 100644 arch/x86/kernel/proc.c This is two patches: one to create proc.c, the other to add CET support. I found where the "arch_status" conversation was: https://lore.kernel.org/all/CALCETrUjF9PBmkzH1J86vw4ZW785DP7FtcT+gcSrx29=BUnjoQ@mail.gmail.com/ Andy, what did you mean "make sure that everything in it is namespaced"? Everything already has a field name. And arch_status doesn't exactly solve having compat fields -- it still needs to be handled manually? Anyway... we have arch_status, so I guess it's fine. > [...] > +int proc_pid_arch_status(struct seq_file *m, struct pid_namespace *ns, > + struct pid *pid, struct task_struct *task) > +{ > + /* > + * Report AVX512 state if the processor and build option supported. > + */ > + if (cpu_feature_enabled(X86_FEATURE_AVX512F)) > + avx512_status(m, task); > + > + seq_puts(m, "Thread_features:\t"); > + dump_features(m, task->thread.features); > + seq_putc(m, '\n'); > + > + seq_puts(m, "Thread_features_locked:\t"); > + dump_features(m, task->thread.features_locked); > + seq_putc(m, '\n'); Why are these always present instead of ifdefed? -Kees -- Kees Cook