From patchwork Thu Sep 29 22:29:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rick Edgecombe X-Patchwork-Id: 12994685 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1480C4332F for ; Thu, 29 Sep 2022 22:30:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 694708D0018; Thu, 29 Sep 2022 18:30:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5803B8D000C; Thu, 29 Sep 2022 18:30:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 35DF88D0018; Thu, 29 Sep 2022 18:30:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 251C08D000C for ; Thu, 29 Sep 2022 18:30:53 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id EB27D1C6E40 for ; Thu, 29 Sep 2022 22:30:52 +0000 (UTC) X-FDA: 79966569144.16.4EBC9EB Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by imf02.hostedemail.com (Postfix) with ESMTP id 42D3680015 for ; Thu, 29 Sep 2022 22:30:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664490652; x=1696026652; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=1ROr10PWtEQqZbu33f8bK3mcr7CnDfijyx9zzPA3SPo=; b=WamyQe9PhYdG9xJTug8E2N4IjJ6XCUHlTPqYAd3Z/Kc6t4e97y3k6nFO fQWwxEHEGCClT7QIafCkCsB4PyoaOJviscoE6fyOPxJaOtUTZ1sdFB70J cVHR8N5vy4E3N+d3Jafg5Qsft5fhOiDs78spZrUAebtRdgjo8Bn1f8lI7 lDdM4HhQk1xYw8G/5HpPNACzJdpP1FZ9KCEhnsxGT8qmn1t8M/3e92Pde u33NNBQFgA93rwsDz9HSXLlWsEgJa2GyLmtxFZ82mFoP6NDPOkqtokJVf 4WYtTfJn4dIMVnOTTmB8ERWl72cIpHIJoxIU3KY+N/9hUo5UtezHyc1J+ A==; X-IronPort-AV: E=McAfee;i="6500,9779,10485"; a="289207567" X-IronPort-AV: E=Sophos;i="5.93,356,1654585200"; d="scan'208";a="289207567" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2022 15:30:51 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10485"; a="691016353" X-IronPort-AV: E=Sophos;i="5.93,356,1654585200"; d="scan'208";a="691016353" Received: from sergungo-mobl.amr.corp.intel.com (HELO rpedgeco-desk.amr.corp.intel.com) ([10.251.25.88]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2022 15:30:49 -0700 From: Rick Edgecombe To: 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 , Kees Cook , 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 Cc: rick.p.edgecombe@intel.com Subject: [PATCH v2 31/39] x86/cet/shstk: Wire in CET interface Date: Thu, 29 Sep 2022 15:29:28 -0700 Message-Id: <20220929222936.14584-32-rick.p.edgecombe@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220929222936.14584-1-rick.p.edgecombe@intel.com> References: <20220929222936.14584-1-rick.p.edgecombe@intel.com> ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=WamyQe9P; spf=pass (imf02.hostedemail.com: domain of rick.p.edgecombe@intel.com designates 134.134.136.20 as permitted sender) smtp.mailfrom=rick.p.edgecombe@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664490652; a=rsa-sha256; cv=none; b=MGmAiG1IbpN6WZFOirMUXTQ2hWzcwMfEHuKi0U6Vd3wWbaUpdbmn1/t7jUGhsvbKo0zuXG ZH1FVryoRTGDYY3ynMJi5pVHKR3HPJzTw47ZzpHqV9j/zmjwIixenb00enRSqPOmK004v5 fqyaKkYnOv1obYZutWWT8RrqPmxfMvM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664490652; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references:dkim-signature; bh=pIU+MFYxIuSqjSIdCsgc/ltahySYgaVHA8pVv5d6kdw=; b=yKRjE1JjtJlW9n1RY/OFnvNqB7uFtQZgJCLdKSAvbr5fHWySQ2ZIlmQfDrV7fb2PqUXux1 HNdJaIFjMtfzhRfUILFk9cHiBe4DMV8X1j6eO/gDKeXkXPsBy1gbQ5i0+VafgxwPdy2wsu pNDCqwaW8fXItPpOA1+Igxk6oX/qpmE= Authentication-Results: imf02.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=WamyQe9P; spf=pass (imf02.hostedemail.com: domain of rick.p.edgecombe@intel.com designates 134.134.136.20 as permitted sender) smtp.mailfrom=rick.p.edgecombe@intel.com; dmarc=pass (policy=none) header.from=intel.com X-Rspam-User: X-Stat-Signature: 89qhc7w6krofczycjak4946gz16ouaxc X-Rspamd-Queue-Id: 42D3680015 X-Rspamd-Server: rspam05 X-HE-Tag: 1664490651-516687 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: The kernel now has the main CET functionality to support applications. Wire in the WRSS and shadow stack enable/disable functions into the existing CET API skeleton. Signed-off-by: Rick Edgecombe Reviewed-by: Kees Cook --- v2: - Split from other patches arch/x86/kernel/shstk.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/x86/kernel/shstk.c b/arch/x86/kernel/shstk.c index fc64a04366aa..0efec02dbe6b 100644 --- a/arch/x86/kernel/shstk.c +++ b/arch/x86/kernel/shstk.c @@ -477,9 +477,17 @@ long cet_prctl(struct task_struct *task, int option, unsigned long features) return -EINVAL; if (option == ARCH_CET_DISABLE) { + if (features & CET_WRSS) + return wrss_control(false); + if (features & CET_SHSTK) + return shstk_disable(); return -EINVAL; } /* Handle ARCH_CET_ENABLE */ + if (features & CET_SHSTK) + return shstk_setup(); + if (features & CET_WRSS) + return wrss_control(true); return -EINVAL; }