Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp55860pxy; Thu, 29 Apr 2021 23:47:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmpbV25GECrVrpQx42Sm6D6O1xq6U6bPDi5HrOxae3Wkk3xrLbMjp/3xNEDQzEOM4sasxd X-Received: by 2002:a17:90a:4811:: with SMTP id a17mr3902989pjh.74.1619765221216; Thu, 29 Apr 2021 23:47:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619765221; cv=none; d=google.com; s=arc-20160816; b=hv7tMmrf48dyq2Xn2KM3NdbBUeutEl+mGISi5IC4gH8g7q5TmPN6P1opffR+AtqPyI EiYAlsDfog6tZR4tVHuKwHcF+u2TBN7qkJVBUckKvNhuhd2MEQgz/0ep3wPU5QYEuJAS mk7yloszskVvgYpG8r2wROdNEM5jsYZ4ETErumROPeyIN5bzG6CfUZcCcVjBjTyzRQiE GSkdx3CxsW/TSm8VPbm3T0OVGXkoLEw8Jn3yRsZ3pMsXXasd3V/KjahJ6gAj/SOvLNyV uKbfsO2prpAuYunmHTIRpP2w9i92+obQWN7CMkuhNidESESFrN7ivG7mLInustejPZfT 6a8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=PFZmzCqPtD1TeQ1IgnxgwBuBBj2UfpUYGVhQ61V9gY0=; b=B56p0WLKQWHMWaqaF7NmEVNIFPEIVul5Ry10unfXJXtiYZ+nOhT7e4CZ5ONLCfaUzh cQ7N5sCuBETpO1KI+n1ORMaSScoJbugQdz3pR8a3clcNUFAcU3ghGfDV1+Zf0cogCPgl VygcPO36r0qMWmPyAXMxh66xeHsu6pUvm+mw7MD+s8VxUIYCbQfaECsenBvlIPnVknXz KIIftWcOrV8MT8aWio9kYLz2w93n50PYvCIPxLeYMAB+wjYS/KluzEY4C4M0L1D/Ic+k Vs6vhc9a2pJ811NSn5t9tEHqdMEp8LerLi8czwwdkdfImwP/slc1kYFOrPWP/80wfeEt eQdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CO1Ztfoc; 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 e2si2571768plo.6.2021.04.29.23.46.48; Thu, 29 Apr 2021 23:47:01 -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=CO1Ztfoc; 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 S230346AbhD3Gql (ORCPT + 99 others); Fri, 30 Apr 2021 02:46:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31409 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230334AbhD3Gqj (ORCPT ); Fri, 30 Apr 2021 02:46:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619765151; 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=PFZmzCqPtD1TeQ1IgnxgwBuBBj2UfpUYGVhQ61V9gY0=; b=CO1ZtfocqTxIz6aW0nd/4+5Y9Yz4QjnUh+TbPWjWzaTK7+XtPzCLTHUB9sBspp+qoA9r31 Lt6KUWv0GIPRF+EwGce5q45LOf/8sOfQQMuCOthTDWKdiym4vaK0bKSvVBnfVzUvwW0kk4 rxpPM0brZ8OkDEGQCoXHtIAcHgkpWP4= 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-147-bVvfBOJoOuGwtxj_hE5rSQ-1; Fri, 30 Apr 2021 02:45:46 -0400 X-MC-Unique: bVvfBOJoOuGwtxj_hE5rSQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B23AB802939; Fri, 30 Apr 2021 06:45:42 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-115-124.ams2.redhat.com [10.36.115.124]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2A74C5D9C6; Fri, 30 Apr 2021 06:45:27 +0000 (UTC) From: Florian Weimer To: Andy Lutomirski Cc: Yu-cheng Yu , linux-arch , X86 ML , "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , LKML , "open list:DOCUMENTATION" , Linux-MM , Linux API , Arnd Bergmann , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , "H.J. Lu" , Jann Horn , 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 , Pengfei Xu , Haitao Huang Subject: Re: extending ucontext (Re: [PATCH v26 25/30] x86/cet/shstk: Handle signals for shadow stack) References: <20210427204315.24153-1-yu-cheng.yu@intel.com> <20210427204315.24153-26-yu-cheng.yu@intel.com> Date: Fri, 30 Apr 2021 08:45:40 +0200 In-Reply-To: (Andy Lutomirski's message of "Wed, 28 Apr 2021 16:03:55 -0700") Message-ID: <87a6pgb78r.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Andy Lutomirski: > The kernel has: > > struct rt_sigframe { > char __user *pretcode; > struct ucontext uc; > struct siginfo info; > /* fp state follows here */ > }; > > This is roughly the actual signal frame. But userspace does not have > this struct declared, and user code does not know the sizes of the > fields. So it's accessed in a nonsensical way. The signal handler > function is passed a pointer to the whole sigframe implicitly in RSP, > a pointer to &frame->info in RSI, anda pointer to &frame->uc in RDX. > User code can *find* the fp state by following a pointer from > mcontext, which is, in turn, found via uc: > > struct ucontext { > unsigned long uc_flags; > struct ucontext *uc_link; > stack_t uc_stack; > struct sigcontext uc_mcontext; <-- fp pointer is in here > sigset_t uc_sigmask; /* mask last for extensibility */ > }; I must say that I haven't reviewed this in detail, but for historic reasons, glibc userspace has a differently-sized sigset_t. So the kernel ucontext (used in signals) and user ucontext (used for swapcontext et al.) are already fully decoupled? Thanks, Florian