Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752163AbdGYOBD (ORCPT ); Tue, 25 Jul 2017 10:01:03 -0400 Received: from mail-db5eur01on0056.outbound.protection.outlook.com ([104.47.2.56]:56842 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751127AbdGYOA6 (ORCPT ); Tue, 25 Jul 2017 10:00:58 -0400 From: Jiong Wang To: Dave P Martin CC: "linux-arm-kernel@lists.infradead.org" , "linux-arch@vger.kernel.org" , "arnd@arndb.de" , Marc Zyngier , Catalin Marinas , Yao Qi , Suzuki Poulose , Will Deacon , "linux-kernel@vger.kernel.org" , "kernel-hardening@lists.openwall.com" , "kvmarm@lists.cs.columbia.edu" , "christoffer.dall@linaro.org" , Mark Rutland Subject: Re: [PATCH 00/11] ARMv8.3 pointer authentication userspace support Thread-Topic: [PATCH 00/11] ARMv8.3 pointer authentication userspace support Thread-Index: AQHTAKhxNpEnr1s4xEyVOGBsMN/MFqJehbOAgAX18YCAABxnEQ== Date: Tue, 25 Jul 2017 14:00:56 +0000 Message-ID: References: <1500480092-28480-1-git-send-email-mark.rutland@arm.com> <20170721170509.GC1538@e103592.cambridge.arm.com>,<20170725120630.GA8116@leverpostej> In-Reply-To: <20170725120630.GA8116@leverpostej> Accept-Language: en-GB, en-US Content-Language: en-GB X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Jiong.Wang@arm.com; x-originating-ip: [217.140.96.140] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DB6PR0802MB2392;7:F+gx9LKkvVZdQHzPy1yAkOZ2PcFZDTJgPF2J/xWmo6CCKH3L/jnQCq1+wiQkJWxmqg3l2cIwf+r4bUdpmhSbM+z8YywCvolSDoaa8kHnf+3smkFRzNbbcu8ykVf1zwWtfrI1BvJS0PPxbiwMpaY1mtGXsBUulBPp/sUcZbpgqHbP/IZSNLfiPu9UhvGFsIe5VxIuF1NzZbuYpLMg+YcE53hzAh1chtZ5eV+l8lOI2f3RrG+NT9C0olAiiTtzY5ZDtt1g6Y3Sk7mCIOtLqbcIipUPQAH/41hNkcwXlTepqhMP9v564bLtmqVNlZocARNTSiVyUWoid0umkzTTxOQihk4pyDQGhX6kKRIfI7Y4uf11GWJUKEvVaGNHihXRu7gU0vpxtTUtX8/4TM5HOzna5ocyWhcdmz/dgp6el4Z2RrIPzjRt5DY6y672q6zhRhtml1bHAchFJXOAPiHj3DSGSuGj3JHcgKrKITIudjcRpETUE3v0rtRfgUT48IZtgluH1ATJdgOnHkPCr0Qspsl9TDEsRW49vhdmX/x94B4DPVPAGLbO14DQX1toHYgtiXsnb5vqautn0zGzKhpBM44MS+FfsmqPyhpTBdK9KH5ltXUfq6zQ+fWzYerOMOQZLjD2b5BWKdPbtGnxADwoX1gSEeLMg48gNrvKsyhNyIJHegojOX7PBWUavUqOB9Ef3nM9z9SDsaiCHAEZR0s8ntRqwEKMvVilRaRwyJG1zjBSRv0q1TMvN58aZt99CI6mmE18ZuL7h24GwNd3gXXHES97/d1Ho1HRJQMOY273dprduJI= x-ms-office365-filtering-correlation-id: 48dbf1fb-a271-42ac-46e6-08d4d3659232 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254075)(300000503095)(300135400095)(48565401081)(2017052603031)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:DB6PR0802MB2392; x-ms-traffictypediagnostic: DB6PR0802MB2392: x-exchange-antispam-report-test: UriScan:(22074186197030)(183786458502308); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123555025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123564025)(20161123560025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:DB6PR0802MB2392;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:DB6PR0802MB2392; x-forefront-prvs: 03793408BA x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(39840400002)(39450400003)(39400400002)(39850400002)(39410400002)(39860400002)(199003)(40434004)(189002)(51444003)(110136004)(81156014)(99286003)(8936002)(53936002)(81166006)(86362001)(68736007)(6862004)(66066001)(2950100002)(38730400002)(6246003)(966005)(6636002)(2906002)(33656002)(55016002)(6436002)(54906002)(6306002)(4326008)(9686003)(14454004)(478600001)(72206003)(7736002)(3280700002)(25786009)(3660700001)(5890100001)(105586002)(5250100002)(97736004)(74316002)(2900100001)(106356001)(6506006)(305945005)(5660300001)(101416001)(8676002)(189998001)(102836003)(50986999)(76176999)(229853002)(54356999)(3846002)(7696004)(6116002);DIR:OUT;SFP:1101;SCL:1;SRVR:DB6PR0802MB2392;H:DB6PR0802MB2405.eurprd08.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Jul 2017 14:00:56.2758 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0802MB2392 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by nfs id v6PE19g9004276 Content-Length: 2817 Lines: 54 > > * Should the kernel remove PACs when unwinding user stacks? > > > > This is simple to do, but it's arguably placing a policy in the kernel as to > > what we expect user stacks to look like. Regardless, userspace will have to > > perform this when unwinding with DWARF. >> >> Not sure. This is arguably not more gross than related things the >> kernel already does, and may be inefficient for userspace to do e.g., >> when capturing perf backtraces. Still gross though. >> >> Side question: do you know whether there will be DWARF / ELF annotations >> for this? Since ptr auth is a compile-time option, it is plausible that >> an attribute could be added to indicate that an image uses it. > Jiong, Yao, can you answer this? > > I think that there's DWARF metadata for unwinding, but I'm not sure > there's an ELF annotation on an image. > > Note that you may link with libraries which may or may not use pointer > auth, so a single process can have a mixture of code using pointer auth, > and code which does not. Yes, there is new DWARF frame information for pointer authentication to describe the signing status at instruction level. There is no ELF annotation on an image. As the use cases of pointer authentication extension in GCC are about return address signing. The DWARF extension is mostly around describing signed LR so the unwinder could have a way to figure out the original value of it to continue unwinding. In general, whenever return address, i.e. LR register, is mangled or restored by hardware instruction, compiler (or assembly writer) is expected to generate a DW_CFA_AARCH64_negate_ra_state CFA instruction. For DWARF unwinder, during unwinding, whenever a DW_CFA_AARCH64_negate_ra_state is hit, the unwinder toggle the LR signing status and kept it in bit zero (lsb) of a new DWARF register AARCH64_DWARF_PAUTH_RA_STATE whose value must be honored later when unwinding the value of LR. If the lsb of AARCH64_DWARF_PAUTH_RA_STATE is set, it means the return address is mangled, then the unwinder needs to restore LR by either masking off the signature (userspace unwinders need ptrace interface to get this) or executing signature strip instruction (can only be done by native unwinder) or executing authentication instruction (can only be done by native unwinder). Please see the following links for more details: https://gcc.gnu.org/ml/gcc-patches/2017-01/msg00376.html https://gcc.gnu.org/ml/gcc-patches/2016-11/msg03010.html Regards, Jiong IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.