Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp215041pxk; Wed, 2 Sep 2020 19:57:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxv+nLUM7ZMt56CWZ2Ydz5yw5NKNtpPsPyO3n5ZOPxLMg2COQdrNYziu3Phj/kpjdIBQ5m5 X-Received: by 2002:a05:6402:a46:: with SMTP id bt6mr895323edb.269.1599101828847; Wed, 02 Sep 2020 19:57:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599101828; cv=none; d=google.com; s=arc-20160816; b=V1f+8JJcKpeTPkk2dBtH+A8ohipTvl/JnDtavrN3uEeR8MbLE2lxTkrOVijM0KMz83 80ElfCLCIXnU8SsUT6u179uA5vdoK5LAPzSREZoBqxD/jZu0b6dFMoqFDn/M56N3eqBD v6D89DIxnYWKUlV+IduW0ezUxsAwRrZvL9k07YQSTQWKb5FPAsNTYQkfh93SaT6ghpI8 IEI8mOtFl7MU+H1mHsxI9qTpuRs4QFZLRuUDdc9fAyDMHWHzg65YHS+IkUIsBGAjxgBV 1YvKbH26PbF86cguOvD7gScELmvyQVNlEs4cfFYyLV+aSlkrM3Q+WWdDnH2hxrmjnMqJ 3Vdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:ironport-sdr:ironport-sdr; bh=9BHyEbTPVFdfHEZ4rlKAuq/2tO/UyA0gYvJ/WXfqfG8=; b=xtOLND9vf64yKhp7bomp7kr/fAXetrmVWK+bJcTmwChQHBNyF7VV7LjMj6vLml1Z+O Vb41hyaR8ybC6O3avLXbRHYOx/ROxGPcEYYJwd0MNjdx3rQbKaEX86wkyfLXUqRBGska tk8Uoy+H/UwmL+tcreGgIazRJ5H+oowSn3B/FfP+dgXkMcNEgzLcXLodFENej7qS8rfh saWPnY9vMvKbCc6+1V3IssZf5SAYwSE0DTfSYnQMRs7bNpg8PSm+gEZwCm35wNeCJf2s laOGOkh37bRDZXyEiE/HuAV7pS1FB+hOFAnx9Dn3Shr8YDbICMmktYtUgiwACfLeN1JC kBiQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id eb8si983351edb.246.2020.09.02.19.56.45; Wed, 02 Sep 2020 19:57:08 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728150AbgICCyB (ORCPT + 99 others); Wed, 2 Sep 2020 22:54:01 -0400 Received: from mga09.intel.com ([134.134.136.24]:36512 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726177AbgICCx6 (ORCPT ); Wed, 2 Sep 2020 22:53:58 -0400 IronPort-SDR: XQWA3DQBk98GF3ACSAadTWXp96zAAP1DM3NGiJ+wP1rBH/UzP9MqlRCd3twdGLT0ljniCtJJJ3 mE9qblWcfo1A== X-IronPort-AV: E=McAfee;i="6000,8403,9732"; a="158496325" X-IronPort-AV: E=Sophos;i="5.76,384,1592895600"; d="scan'208";a="158496325" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Sep 2020 19:53:58 -0700 IronPort-SDR: kuo7JgczJbT83sHrpVfgqJG/Jqc0ewkrsV3LhjRM7Af8/qwMoGAWfgBC17ng+934Hve0sPN83A 64xElWOhzhng== X-IronPort-AV: E=Sophos;i="5.76,384,1592895600"; d="scan'208";a="446740813" Received: from yyu32-mobl1.amr.corp.intel.com (HELO [10.209.147.104]) ([10.209.147.104]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Sep 2020 19:53:56 -0700 Subject: Re: [PATCH v11 6/9] x86/cet: Add PTRACE interface for CET To: Jann Horn Cc: the arch/x86 maintainers , "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , kernel list , linux-doc@vger.kernel.org, Linux-MM , linux-arch , Linux API , Arnd Bergmann , Andy Lutomirski , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin , Weijiang Yang References: <20200825002645.3658-1-yu-cheng.yu@intel.com> <20200825002645.3658-7-yu-cheng.yu@intel.com> <9be5356c-ec51-4541-89e5-05a1727a09a8@intel.com> From: "Yu, Yu-cheng" Message-ID: <1d00a4ed-6f2e-bafd-3540-292e31f1685b@intel.com> Date: Wed, 2 Sep 2020 19:53:55 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/2/2020 5:33 PM, Jann Horn wrote: > On Thu, Sep 3, 2020 at 12:13 AM Yu, Yu-cheng wrote: >> On 9/2/2020 1:03 PM, Jann Horn wrote: >>> On Tue, Aug 25, 2020 at 2:30 AM Yu-cheng Yu wrote: >>>> Add REGSET_CET64/REGSET_CET32 to get/set CET MSRs: >>>> >>>> IA32_U_CET (user-mode CET settings) and >>>> IA32_PL3_SSP (user-mode Shadow Stack) >>> [...] >>>> diff --git a/arch/x86/kernel/fpu/regset.c b/arch/x86/kernel/fpu/regset.c >>> [...] >>>> +int cetregs_get(struct task_struct *target, const struct user_regset *regset, >>>> + struct membuf to) >>>> +{ >>>> + struct fpu *fpu = &target->thread.fpu; >>>> + struct cet_user_state *cetregs; >>>> + >>>> + if (!boot_cpu_has(X86_FEATURE_SHSTK)) >>>> + return -ENODEV; >>>> + >>>> + fpu__prepare_read(fpu); >>>> + cetregs = get_xsave_addr(&fpu->state.xsave, XFEATURE_CET_USER); >>>> + if (!cetregs) >>>> + return -EFAULT; >>> >>> Can this branch ever be hit without a kernel bug? If yes, I think >>> -EFAULT is probably a weird error code to choose here. If no, this >>> should probably use WARN_ON(). Same thing in cetregs_set(). >>> >> >> When a thread is not CET-enabled, its CET state does not exist. I >> looked at EFAULT, and it means "Bad address". Maybe this can be ENODEV, >> which means "No such device"? > > Yeah, I guess ENODEV might fit reasonably well. > I will update it. Thanks!