Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp175733imm; Thu, 21 Jun 2018 16:11:48 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJl3Hwh6LoCcCB0/tNdih9nOZxZL+D54LGg0Rh8vc0RxPWINOKu7PwBSD0fMCCMRKBsJwNM X-Received: by 2002:a62:86c3:: with SMTP id x186-v6mr29358380pfd.4.1529622708756; Thu, 21 Jun 2018 16:11:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529622708; cv=none; d=google.com; s=arc-20160816; b=dnMr39SqstP/cTEWBmfOUhjeMaui1gYU4rpNjC9XurFo9TppJrAfT35GMmI1S9F/wS p0KFDgc0mvP+/DYi1p7MQWhby+jKY7nVZauUbo4LT75Va1TyIwAQrLXqtLwZmY2+7pM0 YZbkWzYTb0KIzU5oB0s2UXTVcUmUaMEt5snSjDWVjjN0QpLRrgOWbYyX9E2nFqi49/lz KUYAPOV66VCX4kC9pvxgVI0JhuBHOOW/O0Ky81ogvw1gHmtHQfDXEixDG4BIf+DqKeck leeeH989Ygz5NMqzbjbgDNe/KQvYDaIkbM1XT8lhLhe5AVFXbGOafw6OZfHsEyzWS0lz AdKA== 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:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=rAJZfiVgrKFmUt5dLqzfYMpXeZAHGZnBnZKWnyyfj2Y=; b=uVdDBx19xRVJGtxD1SOnQQ3Nc+2U9QnYlSb0a8Lzjz4+rZDem1YlrNYFRmRTOjSta7 RaLUyYr8ydgMr6ck/uD5HjPTV9vKGEG8ScGTVzNMvUvInqNVQJ7wviIarRu5vkFQanmz 8/AJW11JTIzBVAPqg0MddbbOa6UEmSHhzfG4DCuuq8ko21X9Qe2e8dTepGLi0ypL4wmN zbHUmG12irLivthsnE5Gw/VOiOWBFQ/x3nnaXeAQmjaOdbyWFG6CQIaj8sOxCX1cKdWM YCzz55g87mpW69G1JvNZeYkN0wIAqPBY/LpiB7tQDSNw08kV9Ngk0QdK7rCBAcn0VK9a PdcA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z13-v6si6019621pfm.330.2018.06.21.16.11.34; Thu, 21 Jun 2018 16:11:48 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934007AbeFUXKy (ORCPT + 99 others); Thu, 21 Jun 2018 19:10:54 -0400 Received: from mga02.intel.com ([134.134.136.20]:35440 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933654AbeFUXKw (ORCPT ); Thu, 21 Jun 2018 19:10:52 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Jun 2018 16:10:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,253,1526367600"; d="scan'208";a="59225642" Received: from 2b52.sc.intel.com ([143.183.136.147]) by FMSMGA003.fm.intel.com with ESMTP; 21 Jun 2018 16:10:51 -0700 Message-ID: <1529622448.30393.22.camel@intel.com> Subject: Re: [PATCH 06/10] x86/cet: Add arch_prctl functions for shadow stack From: Yu-cheng Yu To: Andy Lutomirski Cc: Kees Cook , Andy Lutomirski , "H. J. Lu" , Thomas Gleixner , LKML , linux-doc@vger.kernel.org, Linux-MM , linux-arch , X86 ML , "H. Peter Anvin" , Ingo Molnar , "Shanbhogue, Vedvyas" , "Ravi V. Shankar" , Dave Hansen , Jonathan Corbet , Oleg Nesterov , Arnd Bergmann , mike.kravetz@oracle.com, Florian Weimer Date: Thu, 21 Jun 2018 16:07:28 -0700 In-Reply-To: <13E3C29A-3295-4A7F-90EC-A84CF34F3E1A@amacapital.net> References: <20180607143807.3611-1-yu-cheng.yu@intel.com> <20180607143807.3611-7-yu-cheng.yu@intel.com> <1528403417.5265.35.camel@2b52.sc.intel.com> <569B4719-6283-4575-A16E-D0A78D280F4E@amacapital.net> <1529427588.23068.7.camel@intel.com> <0AF8B71E-B6CC-42DE-B95C-93896196C3D7@amacapital.net> <446EB18D-EF06-4A04-AF62-E72C68D96A84@amacapital.net> <1529447937.27370.33.camel@intel.com> <13E3C29A-3295-4A7F-90EC-A84CF34F3E1A@amacapital.net> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.18.5.2-0ubuntu3.2 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2018-06-19 at 17:50 -0700, Andy Lutomirski wrote: > > > > > On Jun 19, 2018, at 3:38 PM, Yu-cheng Yu > > wrote: > > > > On Tue, 2018-06-19 at 13:47 -0700, Andy Lutomirski wrote: > > > > > > > > > > > > > > > On Jun 19, 2018, at 1:12 PM, Kees Cook > > > > wrote: > > > > > > > > > > > > > > > > > > > On Tue, Jun 19, 2018 at 10:20 AM, Andy Lutomirski > > > > pita > > > > > l.net> wrote: > > > > > > > > > > > > > > > > > > > > > > > On Jun 19, 2018, at 10:07 AM, Kees Cook > > > > > org> > > > > > > wrote: > > > > > > > > > > > > Does it provide anything beyond what PR_DUMPABLE does? > > > > > What do you mean? > > > > I was just going by the name of it. I wasn't sure what "ptrace > > > > CET > > > > lock" meant, so I was trying to understand if it was another > > > > "you > > > > can't ptrace me" toggle, and if so, wouldn't it be redundant > > > > with > > > > PR_SET_DUMPABLE = 0, etc. > > > > > > > No, other way around. The valid CET states are on/unlocked, > > > off/unlocked, on/locked, off/locked. arch_prctl can freely the > > > state > > > unless locked. ptrace can change it no matter what.  The lock is > > > to > > > prevent the existence of a gadget to disable CET (unless the > > > gadget > > > involves ptrace, but I don’t think that’s a real concern). > > We have the arch_prctl now and only need to add ptrace lock/unlock. > > > > Back to the dlopen() "relaxed" mode. Would the following work? > > > > If the lib being loaded does not use setjmp/getcontext families > > (the > > loader knows?), then the loader leaves shstk on.   > Will that actually work?  Are there libs that do something like > longjmp without actually using the glibc longjmp routine?  What about > compilers that statically match a throw to a catch and try to return > through several frames at once? > The compiler throw/catch is already handled similarly to how longjmp is handled. To summarize the dlopen() situation, ---- (1) We don't want to fall back like the following.  One reason is turning off SHSTK for threads is tricky. if ((dlopen() a legacy library) && (cet_policy==relaxed)) { /*  * We don't care if the library will actually fault;  * just turn off CET protection now.  */ Turn off CET; } (2) We cannot predict what version of a library will be dlopen'ed, and cannot turn off CET reliably from the beginning of an application. ---- Can we mandate a signal handler (to turn off CET) when ((dlopen is used ) && (cet_policy==relaxed))? > > > > Otherwise, if the > > system-wide setting is "relaxed", the loader turns off shstk and > > issues > > a warning.  In addition, if (dlopen == relaxed), then cet is not > > locked > > in any time. > > > > The system-wide setting (somewhere in /etc?) can be: > > > >    dlopen=force|relaxed /* controls dlopen of non-cet libs */ > >    exec=force|relaxed /* controls exec of non-cet apps */ > > > > > Why do we need a whole new mechanism here?  Can’t all this use > regular glibc tunables? Ok, got it. Yu-cheng