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: AS3215 2.6.0.0/16 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,NICE_REPLY_A, 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 [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 51B5B1F5AE for ; Sat, 17 Jul 2021 22:12:20 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8DBEC3835C1F for ; Sat, 17 Jul 2021 22:12:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8DBEC3835C1F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1626559939; bh=WffW7UL2cHRKGHgIebziKMqXH4iiYbX0Hhdq2FRVDhc=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=LTWpznLkUyWUmGy4ZA6JfCtzq72PEYFJY9AhqA750tuM+CAsA/jjZZJP9065dq7Y7 KGQnzEjVOvgYz4lSreMo3ahUU681lZnTgTZuY8igJ4MIY6MR/kR4lOjRGqAy22MFEz kGulWFrcVl8PIK632Rys0tn1PRrmBf52qGvPh6Ok= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 6AA963838037 for ; Sat, 17 Jul 2021 22:04:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6AA963838037 Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-498-XCU0oNpiMRqE1UXkWdHK0Q-1; Sat, 17 Jul 2021 18:04:45 -0400 X-MC-Unique: XCU0oNpiMRqE1UXkWdHK0Q-1 Received: by mail-qk1-f197.google.com with SMTP id 8-20020a3704080000b02903b914d9e335so3506738qke.17 for ; Sat, 17 Jul 2021 15:04:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=WffW7UL2cHRKGHgIebziKMqXH4iiYbX0Hhdq2FRVDhc=; b=kf3ypMlRJnzAfUCiF4id9XCwr2fJDbYGtHrk84lUiNXk0MClNw8kMFkhF/iijqSPmz j7xw3uXAORjCAopJmXso62ASSvIsP6FqnVBbCEn/4h2b3JUpJThxMW3tD3popLs/tArf FoLA4K2uK7spAGlJ39FFWNcbaz6KsEwM8kc9W1wi/UkT9hGkPc3/05LKNdU1y5111PV4 iYLGDW05KpGhYV7JkO8m4jo0vLN8YbMFaGQSC/9RpTY3imPZJiEKm99bOD395lF540Co XFl3muLmtdPIocBPcWISFIJY5todakbf3qXTbv0q6B4cz/QU+GzlvbDCrKDCNVFhRbRo pm7w== X-Gm-Message-State: AOAM533JpbQoKoSM9qjiV7H2cqrXQchKKRy8+E/GZ2tys9ePYF7T1Vps mW/HUvSxXcI1lrbYd/A8phpQcLxUqj3aHNUVYCAzCVN9Q+YHJMlpCVy/ctaVz2lhOWs5iRbFi8m 6sFT2gM+tasRHonDgYbTS X-Received: by 2002:a05:620a:13a1:: with SMTP id m1mr16418618qki.91.1626559485507; Sat, 17 Jul 2021 15:04:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLAeUZ4fO5NJDBpbNiuyvYXEVLY4Rwrf15NXyfKPZVAPSgyZ0YbZAmZDvcxsF3/R0MOvWjsA== X-Received: by 2002:a05:620a:13a1:: with SMTP id m1mr16418607qki.91.1626559485385; Sat, 17 Jul 2021 15:04:45 -0700 (PDT) Received: from [192.168.1.16] (198-84-214-74.cpe.teksavvy.com. [198.84.214.74]) by smtp.gmail.com with ESMTPSA id c11sm4753461qth.29.2021.07.17.15.04.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 17 Jul 2021 15:04:44 -0700 (PDT) Subject: Re: [PATCH v8 10/10] mcheck Fix malloc_usable_size [BZ #22057] To: Siddhesh Poyarekar , libc-alpha@sourceware.org References: <20210713073845.504356-1-siddhesh@sourceware.org> <20210713073845.504356-11-siddhesh@sourceware.org> Organization: Red Hat Message-ID: <0b33dcfc-2b55-200a-d429-99d16863ed4d@redhat.com> Date: Sat, 17 Jul 2021 18:04:43 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210713073845.504356-11-siddhesh@sourceware.org> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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: Carlos O'Donell via Libc-alpha Reply-To: Carlos O'Donell Cc: fweimer@redhat.com Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" On 7/13/21 3:38 AM, Siddhesh Poyarekar wrote: > Interpose malloc_usable_size to return the correct mcheck value for > malloc_usable_size. OK for 2.34. Tested without regression on x86_64 and i686. Reviewed-by: Carlos O'Donell Tested-by: Carlos O'Donell > --- > malloc/Makefile | 4 +--- > malloc/malloc-debug.c | 8 ++++++-- > malloc/mcheck-impl.c | 6 ++++++ > 3 files changed, 13 insertions(+), 5 deletions(-) > > diff --git a/malloc/Makefile b/malloc/Makefile > index c9504d0916..04c6b09949 100644 > --- a/malloc/Makefile > +++ b/malloc/Makefile > @@ -83,7 +83,7 @@ ifeq ($(have-GLIBC_2.24)$(build-shared),yesyes) > # the tests expect specific internal behavior that is changed due to linking to > # libmcheck.a. > tests-exclude-mcheck = tst-mallocstate \ > - tst-safe-linking tst-malloc-usable \ > + tst-safe-linking \ OK. > tst-malloc-backtrace \ > tst-malloc-fork-deadlock \ > tst-malloc-stats-cancellation \ > @@ -92,8 +92,6 @@ tests-exclude-mcheck = tst-mallocstate \ > tst-malloc-thread-fail \ > tst-malloc-usable-tunables \ > tst-malloc_info \ > - tst-pvalloc-fortify \ > - tst-reallocarray \ OK. > tst-compathooks-off tst-compathooks-on > > tests-mcheck = $(filter-out $(tests-exclude-mcheck), $(tests)) > diff --git a/malloc/malloc-debug.c b/malloc/malloc-debug.c > index ef44546a4e..7968787ad6 100644 > --- a/malloc/malloc-debug.c > +++ b/malloc/malloc-debug.c > @@ -357,8 +357,12 @@ strong_alias (__debug_calloc, calloc) > size_t > malloc_usable_size (void *mem) > { > - return (__is_malloc_debug_enabled (MALLOC_CHECK_HOOK) > - ? malloc_check_get_size (mem) : musable (mem)); > + if (__is_malloc_debug_enabled (MALLOC_MCHECK_HOOK)) > + return mcheck_usable_size (mem); > + if (__is_malloc_debug_enabled (MALLOC_CHECK_HOOK)) > + return malloc_check_get_size (mem); > + > + return musable (mem); OK. > } > > #define LIBC_SYMBOL(sym) libc_ ## sym > diff --git a/malloc/mcheck-impl.c b/malloc/mcheck-impl.c > index 8857e6b179..6597a290a6 100644 > --- a/malloc/mcheck-impl.c > +++ b/malloc/mcheck-impl.c > @@ -404,3 +404,9 @@ __mcheck_initialize (void (*func) (enum mcheck_status), bool in_pedantic) > pedantic = in_pedantic; > return 0; > } > + > +static int > +mcheck_usable_size (struct hdr *h) > +{ > + return (h - 1)->size; > +} OK. > -- Cheers, Carlos.