From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.4 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF6ADC433DF for ; Fri, 22 May 2020 17:29:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D1F02206D5 for ; Fri, 22 May 2020 17:29:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UAuT8Yn0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730751AbgEVR3z (ORCPT ); Fri, 22 May 2020 13:29:55 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:34030 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730554AbgEVR3z (ORCPT ); Fri, 22 May 2020 13:29:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590168593; 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=UAuT8Yn0UoomkErKG4p+0Hhu6F7F3Hx9RUc6+EhrOB6k1c+R6G/iu1TOXaDBP39rikh4g1 gL/9TYz/yU15PEWZVbg//INvZ/nWqiQdhZtYi+lAB+6bGZ+K74vIJLvaMgNpOEc9nrdgB9 5j2EwBPweCi7+A8pzx51boxSqD5eP5M= 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-api-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-api@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/