Commit 71b2db9
committed
[PAC][libunwind][AArch64] Keep LR signed when stored in context struct
There are two ways of return address signing: pac-ret (enabled via
`-mbranch-protection=pac-ret`) and ptrauth-returns (enabled as part of
Apple's arm64e or experimental pauthtest ABI on Linux).
Previously, signed LR was handled in libunwind as follows:
1. For pac-ret, the signed LR value was authenticated, and the resulting
unsigned LR value was stored in the context structure.
2. For ptrauth-returns (which is assumed to be a part of a full-fledged
PAuth ABI like arm64e or pauthtest), the signed LR value was
re-signed using the same key (IB) and address of the `__pc` field in
the context structure as a modifier.
This patch unifies the signed LR handling logic by keeping LR signed
for pac-ret similarly to ptrauth-returns. It makes LR substitution in
the context structure harder.
Note that LR signed state or signing scheme for pac-ret might differ between
stack frames. The behavior differs from ptrauth-returns, which has a fixed
signing scheme and is enabled as a part of bigger PAuth ABI which is either
present everywhere or not. In order to handle different signing schemes
across stack frames, new subfields `__state`, `__second_modifier` and
`__use_b_key` of the field `__ra_sign` in the context structure are used.
When stored in the context structure, the pointer is resigned with
maintaining original key and using the address of the `__pc` field in
the structure as a modifier.1 parent 625d535 commit 71b2db9
File tree
9 files changed
+480
-171
lines changed- libunwind
- include
- src
9 files changed
+480
-171
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
642 | 642 | | |
643 | 643 | | |
644 | 644 | | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
645 | 651 | | |
646 | 652 | | |
647 | 653 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
| 78 | + | |
| 79 | + | |
82 | 80 | | |
83 | 81 | | |
84 | 82 | | |
| |||
176 | 174 | | |
177 | 175 | | |
178 | 176 | | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
199 | 180 | | |
200 | 181 | | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
| 182 | + | |
| 183 | + | |
207 | 184 | | |
208 | 185 | | |
209 | 186 | | |
| |||
302 | 279 | | |
303 | 280 | | |
304 | 281 | | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
| 282 | + | |
315 | 283 | | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
322 | 290 | | |
323 | 291 | | |
324 | 292 | | |
325 | 293 | | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
351 | 298 | | |
352 | | - | |
| 299 | + | |
| 300 | + | |
353 | 301 | | |
354 | 302 | | |
355 | 303 | | |
| |||
0 commit comments