Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp67415imm; Thu, 7 Jun 2018 13:58:49 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIcAy8Wg11Oidxp6uKgr347EgkBK6wIdz/j59TfoD34w6a9zdAiWWe3ta57Tgk0Yj/xUB6q X-Received: by 2002:a65:45c2:: with SMTP id m2-v6mr2793396pgr.189.1528405129252; Thu, 07 Jun 2018 13:58:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528405129; cv=none; d=google.com; s=arc-20160816; b=PBozBgaDpjAVk5a7HkfSrUnxRkOnLbBg57bMoPAbwT2hH5AwNTfTtQRLEyPMNnP6O6 3dnL58eGMmVLZrClKsjUid1SlLJnflsl6ZG/L48a4RRaxeZRkxGdRSxx43j7jz3OWzfp 6kkNmbOXEOhumqV9MmcobcJVWbTv0H+q+zHSlgIZu57jHboU+PqQlnkoUpgWpW5SFT0G PVZH/so2Rd8EOTKnZWbJ7zBgW8BzErCa8D0znJjBz0ScjUE2+1L5vgmCsBgVcbseBHuJ f+4NbqKt10TtNqBqPJuGjEoZD8d6p6JuLX7cV869UJbnufImZX9NxDYg5gHtz2eS0X5b JMmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=nsmWuprJ7lXjth3PP41tdUhZcW4hpAhE1Mt+RMAJDVo=; b=CUMF+wstDAam2FZlxuEhTq7Qr/ZS91ok6QSbqGYKn9EXSUdGXrKBoEQ8pai/IxLKYh rTZai0NaEJiKSHYzRR3N+wZYRw2mH1zRlG94evqiqoIl2vDZVl4RtVCUAfzZYLZyDh5f da00VgThf+xT+nNhHN+SsAs8oOe8UYHxMh8moeI3V46EDzsT9hHEnIapNpBo81m8T4NO aw0sT1FTsCCw67rMeiL9CeAwUJPkRi29dRNIvU9k1hfu09sMc3kZUWxk/QcQ2SijuZ3g c8VOtJ6w2q2k1Nt96fdXD+cOGXSlLnQz+vxoK4LCYKDtBBWVvKC62pqA4Cxsfn/9C8xa zjbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nh9WlCmN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e14-v6si11157918pgt.185.2018.06.07.13.58.34; Thu, 07 Jun 2018 13:58:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nh9WlCmN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933068AbeFGU5a (ORCPT + 99 others); Thu, 7 Jun 2018 16:57:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:41456 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933175AbeFGU5W (ORCPT ); Thu, 7 Jun 2018 16:57:22 -0400 Received: from mail-wr0-f173.google.com (mail-wr0-f173.google.com [209.85.128.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 56C20208AC for ; Thu, 7 Jun 2018 20:57:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1528405036; bh=wQ17FDLYtNka0RhI4z8H8Sf+ZZ7xe/5gI0D7GKp659M=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=nh9WlCmNEEeRNt0Z61dRG4ibhoHXhfgKUh/eLdxMar9q0q8CQfkPLoC01v5bl0Ato 7EV2uYQAoUEt59pqcsDow94ID1IhBd57/7g81wNbCtpGwQGUAHtpTM6c47WhCWAzQ3 FKBaMig67nD776ylOLCvMpH3PoWmuBReNnDoM3KI= Received: by mail-wr0-f173.google.com with SMTP id v13-v6so11199942wrp.13 for ; Thu, 07 Jun 2018 13:57:16 -0700 (PDT) X-Gm-Message-State: APt69E2jjNdbtZeKrbE2Nt7RMzmMPzFX7LcaAteDdPNiMsv+PCa3mJce y64ZIfBWwIEEWPUlhD62FHLNYbIER+37MFI8C899iw== X-Received: by 2002:adf:85ec:: with SMTP id 41-v6mr2909360wru.120.1528405034780; Thu, 07 Jun 2018 13:57:14 -0700 (PDT) MIME-Version: 1.0 References: <20180607143807.3611-1-yu-cheng.yu@intel.com> <20180607143807.3611-4-yu-cheng.yu@intel.com> <20180607200714.GA2525@uranus> In-Reply-To: <20180607200714.GA2525@uranus> From: Andy Lutomirski Date: Thu, 7 Jun 2018 13:57:03 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 03/10] x86/cet: Signal handling for shadow stack To: Cyrill Gorcunov Cc: Yu-cheng Yu , Florian Weimer , Dmitry Safonov , LKML , linux-doc@vger.kernel.org, Linux-MM , linux-arch , X86 ML , "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , "H. J. Lu" , "Shanbhogue, Vedvyas" , "Ravi V. Shankar" , Dave Hansen , Jonathan Corbet , Oleg Nesterov , Arnd Bergmann , mike.kravetz@oracle.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 7, 2018 at 1:07 PM Cyrill Gorcunov wrote: > > On Thu, Jun 07, 2018 at 11:30:34AM -0700, Andy Lutomirski wrote: > > On Thu, Jun 7, 2018 at 7:41 AM Yu-cheng Yu wrote: > > > > > > Set and restore shadow stack pointer for signals. > > > > How does this interact with siglongjmp()? > > > > This patch makes me extremely nervous due to the possibility of ABI > > issues and CRIU breakage. > > > > > diff --git a/arch/x86/include/uapi/asm/sigcontext.h b/arch/x86/include/uapi/asm/sigcontext.h > > > index 844d60eb1882..6c8997a0156a 100644 > > > --- a/arch/x86/include/uapi/asm/sigcontext.h > > > +++ b/arch/x86/include/uapi/asm/sigcontext.h > > > @@ -230,6 +230,7 @@ struct sigcontext_32 { > > > __u32 fpstate; /* Zero when no FPU/extended context */ > > > __u32 oldmask; > > > __u32 cr2; > > > + __u32 ssp; > > > }; > > > > > > /* > > > @@ -262,6 +263,7 @@ struct sigcontext_64 { > > > __u64 trapno; > > > __u64 oldmask; > > > __u64 cr2; > > > + __u64 ssp; > > > > > > /* > > > * fpstate is really (struct _fpstate *) or (struct _xstate *) > > > @@ -320,6 +322,7 @@ struct sigcontext { > > > struct _fpstate __user *fpstate; > > > __u32 oldmask; > > > __u32 cr2; > > > + __u32 ssp; > > > > Is it actually okay to modify these structures like this? They're > > part of the user ABI, and I don't know whether any user code relies on > > the size being constant. > > For sure it might cause problems for CRIU since we have > similar definitions for this structure inside our code. > That said if kernel is about to modify the structures it > should keep backward compatibility at least if a user > passes previous version of a structure @ssp should be > set to something safe by the kernel itself. > > I didn't read the whole series of patches in details > yet, hopefully will be able tomorrow. Thanks Andy for > CC'ing! We have uc_flags. It might be useful to carve out some of the flag space (24 bits?) to indicate something like the *size* of sigcontext and teach the kernel that new sigcontext fields should only be parsed on sigreturn() if the size is large enough.