From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0960C3858D20; Sat, 30 Mar 2024 12:48:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0960C3858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1711802891; bh=Ai+ngLnvFGTRI3ITAqkpXAtU7uY1GOQIMLtPFzBELZE=; h=From:To:Subject:Date:From; b=ttXYpug24zJvfGu6zy/I/ZKnAL9UYIAeQOvRJ0v3XxKUGjnFwH9J5DiLGMCz4m//l 1Ke0g61q6os0e88bhBgcKs209LsA8N1Y8wdyCD9VaIsCEDtULXsFY5aqFEaQ3Dllef ZnX7/VJVUxRgbUTlnUs35Wwfh/xkgolGLf0dbf7o= From: "doko at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libquadmath/114533] New: libquadmath: printf: fix misaligned access on args Date: Sat, 30 Mar 2024 12:48:10 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libquadmath X-Bugzilla-Version: 13.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: doko at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114533 Bug ID: 114533 Summary: libquadmath: printf: fix misaligned access on args Product: gcc Version: 13.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libquadmath Assignee: unassigned at gcc dot gnu.org Reporter: doko at gcc dot gnu.org Target Milestone: --- reported at https://gcc.gnu.org/pipermail/gcc-patches/2024-March/647635.html On x86, this compiles into movdqa which segfaults on unaligned access. This kind of failure has been seen when running against glibc 2.39, which incidentally changed the printf implementation to move away from alloca() for this data to instead append it at the end of an existing "scratch buffer", with arbitrary alignment, whereas alloca() was probably more likely to be naturally aligned. Tested by adding the patch to the Ubuntu gcc-14 package in https://launchpad.net/~schopin/+archive/ubuntu/libquadmath Signed-off-by: Simon Chopin --- libquadmath/printf/printf_fp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libquadmath/printf/printf_fp.c b/libquadmath/printf/printf_fp.c index 8effcee88fa..d86aa650d38 100644 --- a/libquadmath/printf/printf_fp.c +++ b/libquadmath/printf/printf_fp.c @@ -363,7 +363,7 @@ __quadmath_printf_fp (struct __quadmath_printf_file *fp, /* Fetch the argument value. */ { - fpnum =3D **(const __float128 **) args[0]; + memcpy(&fpnum, *(void* const *) args[0], sizeof(fpnum)); /* Check for special values: not a number or infinity. */ if (isnanq (fpnum))=