-
Notifications
You must be signed in to change notification settings - Fork 637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SECURITY: disable build of filter_neon.S on arm #563
Conversation
No aarch64 only. I'll test this later today and report back, looks right. Thanks. |
I'll make it so that nothing happens on 32-bit (i.e. the behavior in both cmake and configure builds with 32-bit won't change, only the 64-bit will drop the files.) That means there's less chance of someone being disrupted. BTW, does filter_neon.S even assemble with a 64-bit target? The code says ".arch armv7-a". |
No only works for aarch64. Ill keep an eye out for the updated patch. |
This fixes the bug #505 "libpng does not support PAC/BTI on aarch64 targets" which arises because the build mechanisms (both cmake and configure) assemble arm/filter_neon.S even though it ends up completely empty. The empty file effectively poisons the so that the PAC/BTI support gets disabled. The fix is minimal; it simply removes arm/filter_neon.S from the list of sources included in the 64-bit ARM builds build. Note that this was already done in cmake for MSVC - it's not clear whether this change was a partial fix for the same issue. This version of the fix ONLY affects aarch64 (arm64) builds; 32-bit ARM systems can still invoke the assembler if required and, indeed, there should be no change whatsover to those builds. The assembler code could not be used on 64-bit systems in any case so in practice there is no material change to 64-bit builds either. TESTING: pull the changes then type "autoreconf" if using configure (not required for cmake). TESTS: cmake has not been tested because cross-builds with cmake currently fail to find the zlib installation from the cmake system root path. The following has been tested with configure cross builds: armv7-linux-gnueabi [no neon support] armv7a-linux-gnueabi [no neon support] armv7a-hardfloat-linux-gnueabi [neon support not enabled] armv7a-hardfloat-linux-gnueabi -mfpu=neon [uses intrinics] armv7a-hardfloat-linux-gnueabi -mfpu=neon -DPNG_ARM_NEON_IMPLEMENTATION=2 [uses assembler] aarch64-linux-gnu [uses intrinsics] aarch64-linux-gnu -DPNG_ARM_NEON_OPT=0 [neon support disabled] Signed-off-by: John Bowler <jbowler@acm.org>
@billatarm here it is. The commit message has been updated with the information about the 32-bit support. So far as I can see this fix is minimal - all it does is remove filter_neon.S from the ARM 64-bit build and that file was always empty anyway!
[1] The CMakeLists.txt does not permit the intended and default way of enabling hardware optimisations by letting the compiler decide work, at least on ARM. It always sets [2] Attempting to turn the NEON optimisations on with armv7a-hardfloat causes a build failure because filter_neon.S is not being passed -mfpu=neon, or at least it is failing to set either |
Works for me: autoreconf
export CFLAGS='-mbranch-protection=standard'
export LDFLAGS='-Wl,-zforce-bti -Wl,--fatal-warnings'
./configure
make -j4
readelf -n ./.libs/libpng16.so
Displaying notes found in: .note.gnu.property
Owner Data size Description
GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
Properties: AArch64 feature: BTI, PAC The Fedora package uses the autotools build system, so I did not look at the cmake side at all. |
I didn't know about Note that I did not explicitly switch the features on; the only flags I'm setting are those in the table, the only relevant one is Likewise on the On the configure builds various non-ARM code is compiled/assembled; this is because of some obvious errors in Testing on So to test I reverted this - back to @ctruta this is good to go; other issues have shown up but this provides a minimal fix to the security issue without breaking anything. |
Tested successfully on openSUSE Tumbleweed (with configure):
|
This fixes the bug #505
"libpng does not support PAC/BTI on aarch64 targets" which arises
because the build mechanisms (both cmake and configure) assemble
arm/filter_neon.S even though it ends up completely empty. The empty
file effectively poisons the so that the PAC/BTI support gets disabled.
The fix is minimal; it simply removes arm/filter_neon.S from the list of
sources included in the build. Note that this was already done in cmake
for MSVC - it's not clear whether this change was a partial fix for the
same issue.
The fix will cause attempts to use the assembler implementation to fail
at build time. As described in PR506:
#506
This should only cause problems with certain older GCC compilers and
only then if someone tries to build with the assembler optimization
enabled in which case the build probably had a security problem.
QUESTION: does the PAC/BTI security issue affect 32-bit ARM? If not
this change may might be an issue for someone given that filter_neon.S
would apparently be safe on 32-bit. Nevertheless this PR is safe
because it fails in a noisy way and is easy to undo.
TESTING: pull the changes then type "autoreconf" if using configure (not
required for cmake).
Signed-off-by: John Bowler jbowler@acm.org