package/haproxy: needs signed overflow handling
PATCH 1/2 package/haproxy: needs signed overflow handling
haproxy has a runtime test to verify that it is built with -fwrapv:
haproxy
FATAL ERROR: invalid code detected -- cannot go further, please recompile! The source code was miscompiled by the compiler, which usually indicates that some of the CFLAGS needed to work around overzealous compiler optimizations were overwritten at build time. Please do not force CFLAGS, and read Makefile and INSTALL files to decide on the best way to pass your local build options.
Build options :
TARGET = custom CPU = generic CC = /home/peko/source/buildroot/output-haproxy/host/bin/arm-linux-gcc CFLAGS = -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g0 -D_FORTIFY_SOURCE=1 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g0 -D_FORTIFY_SOURCE=1
OPTIONS = USE_THREAD=1 USE_DL=1
DEBUG = -DDEBUG_STRICT -DDEBUG_MEMORY_POOLS
Which comes from:
https://github.com/haproxy/haproxy/blob/v2.6.0/src/haproxy.c#L3008-L3037
So build it with -fwrapv to fix that.
Notice that this message also embeds the build path (through CC), breaking reproducible builds.
--- package/haproxy/haproxy.mk | 2 ++ 1 file changed, 2 insertions(+)
package/haproxy/haproxy.mk +2 -0
@@ -15,8 +15,10 @@ HAPROXY_CPE_ID_VENDOR = haproxy # https://git.haproxy.org/?p=haproxy-2.6.git;a=commit;h=832b672eee54866c7a42a1d46078cc9ae0d544d9 HAPROXY_IGNORE_CVES += CVE-2023-45539 +# haproxy relies on signed overflow, so MUST be built with -fwrapv HAPROXY_MAKE_OPTS = \ LD=$(TARGET_CC) \ + CFLAGS="$(TARGET_CFLAGS) -fwrapv" \ PREFIX=/usr \ TARGET=custom
Signature · 6 lines
2.47.3 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 2/2 support/testing: add haproxy test
Based on the lighttpd test case. Verify that we can download index.html from haproxy in front of lighttpd.
--- DEVELOPERS | 1 + support/testing/conf/haproxy.cfg | 13 +++++++ support/testing/tests/package/test_haproxy.py | 38 +++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 support/testing/conf/haproxy.cfg create mode 100644 support/testing/tests/package/test_haproxy.py
DEVELOPERS +1 -0
@@ -2715,6 +2715,7 @@ F: package/wireguard-linux-compat/ F: package/wireguard-tools/ F: support/testing/tests/package/test_agec.py F: support/testing/tests/package/test_docker_compose.py +F: support/testing/tests/package/test_haproxy.py F: support/testing/tests/package/test_python_hid.py N: Peter Seiderer <[email protected]>
support/testing/conf/haproxy.cfg new file +13 -0
@@ -0,0 +1,13 @@ +defaults + timeout connect 10s + timeout client 30s + timeout server 30s + +frontend myfrontend + mode http + bind :81 + default_backend web_servers + +backend web_servers + mode http + server s1 localhost:80 check
support/testing/tests/package/test_haproxy.py new file +38 -0
@@ -0,0 +1,38 @@ +import os + +import infra.basetest + + +class TestHaproxy(infra.basetest.BRTest): + config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \ + """ + BR2_ROOTFS_POST_BUILD_SCRIPT="{}" + BR2_ROOTFS_POST_SCRIPT_ARGS="{}" + BR2_PACKAGE_HAPROXY=y + BR2_PACKAGE_LIGHTTPD=y + BR2_TARGET_ROOTFS_CPIO=y + # BR2_TARGET_ROOTFS_TAR is not set + """.format( + infra.filepath("tests/package/copy-sample-script-to-target.sh"), + infra.filepath("conf/haproxy.cfg") + ) + + def test_run(self): + cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio") + self.emulator.boot(arch="armv5", + kernel="builtin", + options=["-initrd", cpio_file]) + self.emulator.login() + + msg = "Hello Buildroot!" + + # sanity check + self.assertRunOk("haproxy -v") + self.assertRunOk("haproxy -c -f .") + + # proxy to lighttpd + self.assertRunOk("haproxy -D -f .") + + self.assertRunOk(f"echo '{msg}' > /var/www/index.html") + self.assertRunOk("wget http://localhost:81/index.html") + self.assertRunOk(f"grep -F '{msg}' index.html")
Signature · 6 lines
2.47.3 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Thomas Perale via buildroot
AppliedRe: [Buildroot] [PATCH 2/2] support/testing: add haproxy test
In reply of:
Quoted 4 lines
Based on the lighttpd test case. Verify that we can download index.html from haproxy in front of lighttpd.
Signed-off-by Peter Korsgaard <[email protected]>
Applied to 2025.02.x & 2026.05.x. Thanks
Quoted 90 lines
--- DEVELOPERS | 1 + support/testing/conf/haproxy.cfg | 13 +++++++ support/testing/tests/package/test_haproxy.py | 38 +++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 support/testing/conf/haproxy.cfg create mode 100644 support/testing/tests/package/test_haproxy.pyDEVELOPERS +1
-0@@ -2715,6 +2715,7 @@ F: package/wireguard-linux-compat/ F: package/wireguard-tools/ F: support/testing/tests/package/test_agec.py F: support/testing/tests/package/test_docker_compose.py +F: support/testing/tests/package/test_haproxy.py F: support/testing/tests/package/test_python_hid.py N: Peter Seiderer <[email protected]>support/testing/conf/haproxy.cfg new file +13
-0@@ -0,0 +1,13 @@ +defaults + timeout connect 10s + timeout client 30s + timeout server 30s + +frontend myfrontend + mode http + bind :81 + default_backend web_servers + +backend web_servers + mode http + server s1 localhost:80 checksupport/testing/tests/package/test_haproxy.py new file +38
-0@@ -0,0 +1,38 @@ +import os + +import infra.basetest + + +class TestHaproxy(infra.basetest.BRTest): + config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \ + """ + BR2_ROOTFS_POST_BUILD_SCRIPT="{}" + BR2_ROOTFS_POST_SCRIPT_ARGS="{}" + BR2_PACKAGE_HAPROXY=y + BR2_PACKAGE_LIGHTTPD=y + BR2_TARGET_ROOTFS_CPIO=y + # BR2_TARGET_ROOTFS_TAR is not set + """.format( + infra.filepath("tests/package/copy-sample-script-to-target.sh"), + infra.filepath("conf/haproxy.cfg") + ) + + def test_run(self): + cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio") + self.emulator.boot(arch="armv5", + kernel="builtin", + options=["-initrd", cpio_file]) + self.emulator.login() + + msg = "Hello Buildroot!" + + # sanity check + self.assertRunOk("haproxy -v") + self.assertRunOk("haproxy -c -f .") + + # proxy to lighttpd + self.assertRunOk("haproxy -D -f .") + + self.assertRunOk(f"echo '{msg}' > /var/www/index.html") + self.assertRunOk("wget http://localhost:81/index.html") + self.assertRunOk(f"grep -F '{msg}' index.html")Signature · 6 lines
2.47.3 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 24 lines · Peter Korsgaard
haproxy has a runtime test to verify that it is built with -fwrapv:
haproxy
FATAL ERROR: invalid code detected -- cannot go further, please recompile! The source code was miscompiled by the compiler, which usually indicates that some of the CFLAGS needed to work around overzealous compiler optimizations were overwritten at build time. Please do not force CFLAGS, and readMakefileand INSTALL files to decide on the best way to pass your local build options.Build options :
TARGET = custom CPU = generic CC =
/home/peko/source/buildroot/output-haproxy/host/bin/arm-linux-gcc
CFLAGS = -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE(quoted diff) +0
-3-D_FILE_OFFSET_BITS=64 -O2 -g0 -D_FORTIFY_SOURCE=1 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g0 -D_FORTIFY_SOURCE=1 OPTIONS = USE_THREAD=1 USE_DL=1 DEBUG = -DDEBUG_STRICT -DDEBUG_MEMORY_POOLSWhich comes from:
https://github.com/haproxy/haproxy/blob/v2.6.0/src/haproxy.c#L3008-L3037
Quoted 6 lines
So build it with -fwrapv to fix that.
Notice that this message also embeds the build path (through CC), breaking reproducible builds.
Signed-off-by Peter Korsgaard <[email protected]>
Series applied to master, thanks.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Thomas Perale via buildroot
AppliedIn reply of:
Quoted 20 lines
haproxy has a runtime test to verify that it is built with -fwrapv:
haproxy
FATAL ERROR: invalid code detected -- cannot go further, please recompile! The source code was miscompiled by the compiler, which usually indicates that some of the CFLAGS needed to work around overzealous compiler optimizations were overwritten at build time. Please do not force CFLAGS, and readMakefileand INSTALL files to decide on the best way to pass your local build options.Build options :
TARGET = custom CPU = generic CC = /home/peko/source/buildroot/output-haproxy/host/bin/arm-linux-gcc CFLAGS = -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g0 -D_FORTIFY_SOURCE=1 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g0 -D_FORTIFY_SOURCE=1OPTIONS = USE_THREAD=1 USE_DL=1
DEBUG = -DDEBUG_STRICT -DDEBUG_MEMORY_POOLSWhich comes from:
https://github.com/haproxy/haproxy/blob/v2.6.0/src/haproxy.c#L3008-L3037
Quoted 6 lines
So build it with -fwrapv to fix that.
Notice that this message also embeds the build path (through CC), breaking reproducible builds.
Signed-off-by Peter Korsgaard <[email protected]>
Applied to 2025.02.x & 2026.05.x. Thanks
Quoted 26 lines
--- package/haproxy/haproxy.mk | 2 ++ 1 file changed, 2 insertions(+)package/haproxy/haproxy.mk +2
-0@@ -15,8 +15,10 @@ HAPROXY_CPE_ID_VENDOR = haproxy # https://git.haproxy.org/?p=haproxy-2.6.git;a=commit;h=832b672eee54866c7a42a1d46078cc9ae0d544d9 HAPROXY_IGNORE_CVES += CVE-2023-45539 +# haproxy relies on signed overflow, so MUST be built with -fwrapv HAPROXY_MAKE_OPTS = \ LD=$(TARGET_CC) \ + CFLAGS="$(TARGET_CFLAGS) -fwrapv" \ PREFIX=/usr \ TARGET=customSignature · 6 lines
2.47.3 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot