Bug 2356306 - When compiling Python with systemtap support, the branch protections on aarch64 do not get applied
Summary: When compiling Python with systemtap support, the branch protections on aarch...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: python3.6
Version: rawhide
Hardware: aarch64
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Charalampos Stratakis
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2025-03-31 20:20 UTC by Charalampos Stratakis
Modified: 2025-04-13 01:38 UTC (History)
6 users (show)

Fixed In Version: python3.6-3.6.15-44.fc43 python3.6-3.6.15-44.fc40 python3.6-3.6.15-44.fc42 python3.6-3.6.15-44.fc41
Clone Of:
Environment:
Last Closed: 2025-04-11 18:27:54 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github python cpython issues 131865 0 None closed Systemtap on linux does not properly apply hardening CFLAGS when compiling using --with-dtrace 2025-03-31 20:20:51 UTC

Description Charalampos Stratakis 2025-03-31 20:20:11 UTC
This bug was initially created as a copy of Bug #2350935


When compiling Python with the --with-dtrace configure flag during RPM build on aarch64 with the -mbranch-protection=standard flag, for applying the Branch Target Identification(BTI) protections, the resulting object file (pydtrace.o) doesn't contain the protections and the associated elf note, resulting in the final shared library missing the note.

Using python3.11, as later versions contain assembly sources that interfere with the results.

Everything looks good when compiling on a non-rpmbuild environment:

./configure --with-dtrace && make -j

$ readelf -n libpython3.11.so.1.0
  Properties: AArch64 feature: BTI, PAC, GCS

$ objdump -d Python/pydtrace.o
  0000000000000000 <__dtrace>:
   0:	d503245f 	bti	c
   4:	d503201f 	nop
   8:	d65f03c0 	ret

However when building Python as an RPM the aarch64 protection flags are not there for libpython or pydtrace.o

$ objdump -d Python/pydtrace.o
0000000000000000 <__dtrace>:
   0:   d503201f        nop
   4:   d65f03c0        ret

I wasn't able to replicate the results by simulating the rpm build on the upstream sources, aka using all our configure options and CFLAGS.

The commands from the Makefile that initiate this:
/usr/bin/dtrace  -o Include/pydtrace_probes.h -h -s /builddir/build/BUILD/python3.11-3.11.11-build/Python-3.11.11/Include/pydtrace.d

sed 's/PYTHON_/PyDTrace_/' Include/pydtrace_probes.h > Include/pydtrace_probes.h.tmp

mv Include/pydtrace_probes.h.tmp Include/pydtrace_probes.h

/usr/bin/dtrace  -o Python/pydtrace.o -G -s /builddir/build/BUILD/python3.11-3.11.11-build/Python-3.11.11/Include/pydtrace.d Python/ceval.o Python/import.o Python/sysmodule.o Modules/gcmodule.o

At the same time the equivalent protection for x86_64 get applied properly for both rpm and non-rpm builds.

Filing for systemtap for now if folks have any insight on that.

Reproducible: Always

Comment 2 Fedora Update System 2025-04-03 04:22:09 UTC
FEDORA-2025-72d5f5db52 (python3.6-3.6.15-44.fc43) has been submitted as an update to Fedora 43.
https://bodhi.fedoraproject.org/updates/FEDORA-2025-72d5f5db52

Comment 3 Fedora Update System 2025-04-03 04:24:56 UTC
FEDORA-2025-72d5f5db52 (python3.6-3.6.15-44.fc43) has been pushed to the Fedora 43 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 4 Fedora Update System 2025-04-03 11:37:07 UTC
FEDORA-2025-ac3242de8d (python3.6-3.6.15-44.fc42) has been submitted as an update to Fedora 42.
https://bodhi.fedoraproject.org/updates/FEDORA-2025-ac3242de8d

Comment 5 Fedora Update System 2025-04-03 11:37:34 UTC
FEDORA-2025-31880f69c8 (python3.6-3.6.15-44.fc41) has been submitted as an update to Fedora 41.
https://bodhi.fedoraproject.org/updates/FEDORA-2025-31880f69c8

Comment 6 Fedora Update System 2025-04-03 11:37:54 UTC
FEDORA-2025-d4c74d9bd5 (python3.6-3.6.15-44.fc40) has been submitted as an update to Fedora 40.
https://bodhi.fedoraproject.org/updates/FEDORA-2025-d4c74d9bd5

Comment 7 Fedora Update System 2025-04-04 01:15:38 UTC
FEDORA-2025-d4c74d9bd5 has been pushed to the Fedora 40 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2025-d4c74d9bd5`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2025-d4c74d9bd5

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 8 Fedora Update System 2025-04-04 01:24:22 UTC
FEDORA-2025-ac3242de8d has been pushed to the Fedora 42 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2025-ac3242de8d`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2025-ac3242de8d

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 9 Fedora Update System 2025-04-04 02:21:28 UTC
FEDORA-2025-31880f69c8 has been pushed to the Fedora 41 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2025-31880f69c8`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2025-31880f69c8

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 10 Fedora Update System 2025-04-05 01:56:33 UTC
FEDORA-2025-d4c74d9bd5 (python3.6-3.6.15-44.fc40) has been pushed to the Fedora 40 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 11 Miro Hrončok 2025-04-09 12:26:36 UTC
We need to rebuild this again with the new redhat-rpm-config.

Also, we plan to skip test_ftplib to avoid the flakiness.

Comment 12 Fedora Update System 2025-04-11 18:27:54 UTC
FEDORA-2025-ac3242de8d (python3.6-3.6.15-44.fc42) has been pushed to the Fedora 42 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 13 Fedora Update System 2025-04-13 01:38:52 UTC
FEDORA-2025-31880f69c8 (python3.6-3.6.15-44.fc41) has been pushed to the Fedora 41 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.