Received: by 2002:a25:1104:0:0:0:0:0 with SMTP id 4csp457948ybr; Fri, 22 May 2020 10:34:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfd7bWMW4PvMPTpUfG2jMlihC67/kN8dz811XaXg99IwCF3vq1VLhhu4f2Qgq30h8eXX2q X-Received: by 2002:a17:906:2b8a:: with SMTP id m10mr9497544ejg.183.1590168847720; Fri, 22 May 2020 10:34:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590168847; cv=none; d=google.com; s=arc-20160816; b=TE8qSojDzMi8RhVa1L9v4OFTijOug8kC8IJFbTPKjsCELHbYjbqnPdIUSF5Bqc3m0n NeXA9ubNcIfZ/d4qK3De6GoNG67Ztqw0ewRjJQdLmWEw53f7j1U/tgXaq2cFnsBemMlW PwQGZzOIZFTDnhTghgHAmrQaOmWwgnQTICXXHAf3j7EKV7Ng2i8tIcJB7Xo8A7+sd6TG iivtO6uVluz57Oq0DPs3UrFzhuZmkhCu7TkzS5A/AuoyB/3zYEZf+JH0pdAin6gu8r5h OQKqb5PdfB/DdslbM6cCD9yeJ1/PiDVyP3Tej6h/9BeL00n3W5yGjZRb+jgPVKDV/3Vc W+7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=15giI7Twfyx23sQ419l43txLDRcgrhknS5eEDxlCs+4=; b=jyU8Lq95e+YIQ5uRTPP+ORIa+sfzUdOTvvLdZAHC8YJhSCw+IxEfj6mYDoE8EWbvQm z5BwqIsn55Kljg6Vyd/qFcRW1yl/Lohch0whmFfQqZ+REjFLf89TeP+VtMYkMNDEjxjt ZKt9Nxo+OgfLNwKdhOwwnGaWToDIW3iNQRgDSZ6pmCtKU/NlDp69Z3OqqK7zVauigrx9 OmOSenR8OXu7mzzdVMxZOlaa7vNspNbEVHt/ck1GgvxqAiWTO8FDgQ3ptSZCPSiz8Lfy e3wcPSQYOG2enkzC8rjRuNyLKfoin8Bqpn59C3V1HmR6ZSHKbaLkhhnMVMlRQg8d4Pup 3rJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Z+CAw6eA; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t22si5017285edi.249.2020.05.22.10.33.44; Fri, 22 May 2020 10:34:07 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Z+CAw6eA; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730572AbgEVR35 (ORCPT + 99 others); Fri, 22 May 2020 13:29:57 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:48907 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730762AbgEVR34 (ORCPT ); Fri, 22 May 2020 13:29:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590168595; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=15giI7Twfyx23sQ419l43txLDRcgrhknS5eEDxlCs+4=; b=Z+CAw6eAZh88LC2ZGa2pc83KNjAjl7tSp4ifykksF/PTYj9lVj5USHgvLRpPlLSiw8G4AK JQ1EVCi3Z+qLXz7Cp3v7hjVN5u3/RTlNCrE5hCnaKmNwfVK/GHXFcUX53s/vz0M5A+pQwy DRHUvqShfghGRjAsTNLAI/E5upbHHjs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-385-6A89GSQQPGGX5UbHzh4Dqg-1; Fri, 22 May 2020 13:29:51 -0400 X-MC-Unique: 6A89GSQQPGGX5UbHzh4Dqg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8D890460; Fri, 22 May 2020 17:29:47 +0000 (UTC) Received: from asgard.redhat.com (unknown [10.36.110.11]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7219E75262; Fri, 22 May 2020 17:29:36 +0000 (UTC) Date: Fri, 22 May 2020 19:29:34 +0200 From: Eugene Syromiatnikov To: Yu-cheng Yu Cc: Kees Cook , 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 , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin , Weijiang Yang , mtk.manpages@gmail.com Subject: Re: [PATCH v10 26/26] x86/cet/shstk: Add arch_prctl functions for shadow stack Message-ID: <20200522172934.GI12341@asgard.redhat.com> References: <20200429220732.31602-1-yu-cheng.yu@intel.com> <20200429220732.31602-27-yu-cheng.yu@intel.com> <202005211528.A12B4AD@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 22, 2020 at 10:17:43AM -0700, Yu-cheng Yu wrote: > On Thu, 2020-05-21 at 15:42 -0700, Kees Cook wrote: > > On Wed, Apr 29, 2020 at 03:07:32PM -0700, Yu-cheng Yu wrote: > [...] > > > + > > > +int prctl_cet(int option, u64 arg2) > > > +{ > > > + struct cet_status *cet; > > > + > > > + if (!IS_ENABLED(CONFIG_X86_INTEL_CET)) > > > + return -EINVAL; > > > > Using -EINVAL here means userspace can't tell the difference between an > > old kernel and a kernel not built with CONFIG_X86_INTEL_CET. Perhaps > > -ENOTSUPP? > > Looked into this. The kernel and GLIBC are not in sync. So maybe we still use > EINVAL here? > > Yu-cheng > > > > In kernel: > ---------- > > #define EOPNOTSUPP 95 > #define ENOTSUPP 524 > > In GLIBC: > --------- > > printf("ENOTSUP=%d\n", ENOTSUP); > printf("EOPNOTSUPP=%d\n", EOPNOTSUPP); > printf("%s=524\n", strerror(524)); > > ENOTSUP=95 > EOPNOTSUPP=95 > Unknown error 524=524 EOPNOTSUPP/ENOTSUP/ENOTSUPP is actually a mess, it's summarized recently by Michael Kerrisk[1]. From the kernel's point of view, I think it would be reasonable to return EOPNOTSUPP, and expect that the userspace would use ENOTSUP to match against it. [1] https://lore.kernel.org/linux-man/cb4c685b-6c5d-9c16-aade-0c95e57de4b9@gmail.com/