From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS17314 8.43.84.0/22 X-Spam-Status: No, score=-4.2 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 214081F8C6 for ; Mon, 12 Jul 2021 21:42:23 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E87FB385742A for ; Mon, 12 Jul 2021 21:42:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E87FB385742A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1626126141; bh=7pVJ5zQQC5lXYA+jTVXdZxNfM4DBnGDi8+JgzeeSyaM=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=dqyy0b74fQYHgxEzfoWA0RvcCbjoZWMmJZfPKvDdXOc0n8OUug+uQhvgVSnsmlmv0 R2Bli1A+rDL+1NWb2Nc8SIEkdaWUrqHK3scltDXd+1gOSmWkFwrdIlrW+S2Rckwdgu w80ojPOYPh6dpDJvkwtQ7CKrSkbUj6Yhn944uTUM= Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by sourceware.org (Postfix) with ESMTPS id 94D02385742A; Mon, 12 Jul 2021 21:42:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 94D02385742A Received: by mail-pj1-x102a.google.com with SMTP id p4-20020a17090a9304b029016f3020d867so822260pjo.3; Mon, 12 Jul 2021 14:42:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=7pVJ5zQQC5lXYA+jTVXdZxNfM4DBnGDi8+JgzeeSyaM=; b=bTXQ+eUR6vYdkRHvQg3DBFyJsDAeha0GWxTaY2dnNH5VejyiMsqWKSC5MBKU2uuot7 rtGM9mTLtN1QPmZcjY4iuB/jK49cajBDdYqhKu4qyvd1ZEk7NGGmhxOlIhmVRgl9+57B Gp7cIUme8b73G2SBpom/LUDjuLqHJP1bkP97rEqQHutilSYzLt7/1n8ig5L6KorFWyj7 /KSD8gdakt+a5PfgwMG7MxDEyTlPYHU54Eqmbr8eCh2WIgI8jpFbR7yGXKwMIFcWhqfr CgZgRpQMOnpq9pFv42s59dKnIA6kIc+dVgdNdGWIE3SL0LVYKxzH0NjeEQoCZUqdFEX8 AOuw== X-Gm-Message-State: AOAM533LSSSMA9uy8mhHb7lySwuQhrMBTreriIgJGyrgCAdBsP5suT5u RiczbSXliVCxZ+iIgi5CkGx3Yvtjl00= X-Google-Smtp-Source: ABdhPJzMffl3AYhza2RdSOGdmJZ/PMktBnS4BztJ5iXm7giRdBF0jAIfMjh8KDz5uY66Hjb11NgFMA== X-Received: by 2002:a17:90a:65c8:: with SMTP id i8mr16154112pjs.207.1626126121545; Mon, 12 Jul 2021 14:42:01 -0700 (PDT) Received: from gnu-cfl-2.localdomain ([172.56.39.115]) by smtp.gmail.com with ESMTPSA id nl2sm5027954pjb.10.2021.07.12.14.42.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jul 2021 14:42:00 -0700 (PDT) Received: from gnu-tgl-2.localdomain (gnu-tgl-2 [192.168.1.34]) by gnu-cfl-2.localdomain (Postfix) with ESMTPS id 10096C02D6; Mon, 12 Jul 2021 14:41:59 -0700 (PDT) Received: from gnu-tgl-2.lan (localhost [IPv6:::1]) by gnu-tgl-2.localdomain (Postfix) with ESMTP id DD49E3004C5; Mon, 12 Jul 2021 14:41:48 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH] mcheck: Align struct hdr to MALLOC_ALIGNMENT bytes [BZ #28068] Date: Mon, 12 Jul 2021 14:41:48 -0700 Message-Id: <20210712214148.2461032-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: "H.J. Lu via Libc-alpha" Reply-To: "H.J. Lu" Cc: Siddhesh Poyarekar Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" 1. Align struct hdr to MALLOC_ALIGNMENT bytes so that malloc hooks in libmcheck align memory to MALLOC_ALIGNMENT bytes. 2. Remove tst-mallocalign1 from tests-exclude-mcheck for i386 and x32. 3. Add tst-pvalloc-fortify and tst-reallocarray to tests-exclude-mcheck since they use malloc_usable_size (see BZ #22057). This fixed BZ #28068. --- malloc/Makefile | 4 +++- malloc/mcheck.c | 3 ++- sysdeps/i386/Makefile | 4 ---- sysdeps/x86_64/x32/Makefile | 4 ---- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/malloc/Makefile b/malloc/Makefile index b685ed6d61..47369b6084 100644 --- a/malloc/Makefile +++ b/malloc/Makefile @@ -95,7 +95,9 @@ tests-exclude-mcheck = tst-mallocstate \ tst-malloc_info \ tst-memalign \ tst-posix_memalign \ - tst-realloc + tst-realloc \ + tst-pvalloc-fortify \ + tst-reallocarray tests-mcheck = $(filter-out $(tests-exclude-mcheck), $(tests)) diff --git a/malloc/mcheck.c b/malloc/mcheck.c index 2a1fc645d4..d2efcfb742 100644 --- a/malloc/mcheck.c +++ b/malloc/mcheck.c @@ -20,6 +20,7 @@ #ifndef _MALLOC_INTERNAL # define _MALLOC_INTERNAL # include +# include # include # include # include @@ -53,7 +54,7 @@ struct hdr struct hdr *next; void *block; /* Real block allocated, for memalign. */ unsigned long int magic2; /* Extra, keeps us doubleword aligned. */ -}; +} __attribute__ ((aligned (MALLOC_ALIGNMENT))); /* This is the beginning of the list of all memory blocks allocated. It is only constructed if the pedantic testing is requested. */ diff --git a/sysdeps/i386/Makefile b/sysdeps/i386/Makefile index 8fb65c0f17..a2e8c0b128 100644 --- a/sysdeps/i386/Makefile +++ b/sysdeps/i386/Makefile @@ -5,10 +5,6 @@ asm-CPPFLAGS += -DGAS_SYNTAX # The i386 `long double' is a distinct type we support. long-double-fcts = yes -ifeq ($(subdir),malloc) -tests-exclude-mcheck += tst-mallocalign1 -endif - ifeq ($(subdir),math) # These functions change the rounding mode internally and need to # update both the SSE2 rounding mode and the 387 rounding mode. See diff --git a/sysdeps/x86_64/x32/Makefile b/sysdeps/x86_64/x32/Makefile index 62919c79f1..8748956563 100644 --- a/sysdeps/x86_64/x32/Makefile +++ b/sysdeps/x86_64/x32/Makefile @@ -1,7 +1,3 @@ -ifeq ($(subdir),malloc) -tests-exclude-mcheck += tst-mallocalign1 -endif - ifeq ($(subdir),math) # Since x32 returns 32-bit long int and 64-bit long long int in the # same 64-bit register, we make the 32b-bit lround an alias of the -- 2.31.1