Message ID | a08289e4a58ff4ad00f0d61ebcdb1cdaca5dc3d5.1614874816.git.szabolcs.nagy@arm.com |
---|---|
State | New |
Headers | show
Return-Path: <libc-alpha-bounces@sourceware.org> X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces@sourceware.org; receiver=<UNKNOWN>) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=DSaxy+Xo; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4DrxK32cgsz9sWg for <incoming@patchwork.ozlabs.org>; Fri, 5 Mar 2021 03:34:15 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3E4493AAA0B4; Thu, 4 Mar 2021 16:34:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3E4493AAA0B4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1614875653; bh=0x6QH0gdG7FbKNEIO+rktMd0OWMCaZlZotP1g1yjI6w=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=DSaxy+XoWUrZiFi9lnVv0pco7UEQvv1rFOGLRyByBKYsiI91ek+ZAJu3ZUzvEK+FE 7caCQSEwOyDOeFxgqVBu3GKitCIpgi9hFCMHiRQ7gRn0EVmvfekBAQcV0s1k4hVwss 8lNtB9xDI3wjI8e+IcXaE1NjNOCb849fP6cEorXU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2077.outbound.protection.outlook.com [40.107.20.77]) by sourceware.org (Postfix) with ESMTPS id 325A9389041C for <libc-alpha@sourceware.org>; Thu, 4 Mar 2021 16:34:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 325A9389041C Received: from AM6P194CA0103.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:8f::44) by VI1PR0802MB2573.eurprd08.prod.outlook.com (2603:10a6:800:b1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.20; Thu, 4 Mar 2021 16:34:08 +0000 Received: from AM5EUR03FT007.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8f:cafe::b6) by AM6P194CA0103.outlook.office365.com (2603:10a6:209:8f::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17 via Frontend Transport; Thu, 4 Mar 2021 16:34:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;sourceware.org; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT007.mail.protection.outlook.com (10.152.16.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17 via Frontend Transport; Thu, 4 Mar 2021 16:34:07 +0000 Received: ("Tessian outbound 72bd4bdd1f59:v71"); Thu, 04 Mar 2021 16:34:07 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 113c3f695b541930 X-CR-MTA-TID: 64aa7808 Received: from ade1f1872e22.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 8217145E-A6A8-4D03-B798-FB8B39F66FAE.1; Thu, 04 Mar 2021 16:33:55 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id ade1f1872e22.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 04 Mar 2021 16:33:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gmwrVmhDhdyB//T3kSiba5ZsjcsCv2pUA9o1Y6BKno88o5VCDjbYDQRM9rv3boLg6EdjSEUmK6hqQ7tjtsx/DVvMXYi9PW2L1fGY+Hf6paQLua4bJ2WQU3pCMg40WtqBFVv5Q0Sq5byMEW/s/EpvZDrZ9WR8R3qGN0xAVJQCTNSwSP7/DmmEOyoSFSmgL2500tGrQgqpCttwc1+rhS2iu9qSofAATYgvlcxKsuxsPXt3TRMrYGV9kVvjTd0Km8GnumnvYKLkuczxYaYWQkLpzBbMNDhrbUjAf+xKnm5hJuYloUuhFJPaQXTrHUIuI+hiAiegXY2LzQO/ePdfsXkM9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0x6QH0gdG7FbKNEIO+rktMd0OWMCaZlZotP1g1yjI6w=; b=LQnzfxGlixH9dmdK7WgOQvuufgiJEb9jiwI+ouExIdXxgyslUWTCAwWVUwfzJ8fZL8aqIU4CxIjkgqMuzez4WLWnST0tv4BmhN9gkFujjTmavjYUtLdmdNFbDrJ9TranPvAu7aojynglMKHExH6MIo2UakNFpOxG8V31LItWYSvKtl7OttzqLJ0FRcIYXh9c60F/QySZvMtsf/iYMY874N+4JZTqfxMC5Nj0z2ZnJhnHLjMq8M5snjwAzgzYj4sYvbVuePOKhn9r35lL5hRXV79SdD8VX85flWfkNpOAXmZBBQ9HLx5EYRP73VfAZBWO4+qw4vhKYTmJeYLxbsQ5Wg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Authentication-Results-Original: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; Received: from PA4PR08MB6320.eurprd08.prod.outlook.com (2603:10a6:102:e5::9) by PA4PR08MB6064.eurprd08.prod.outlook.com (2603:10a6:102:e2::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.20; Thu, 4 Mar 2021 16:33:54 +0000 Received: from PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336]) by PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::60f0:3773:69b8:e336%2]) with mapi id 15.20.3912.021; Thu, 4 Mar 2021 16:33:54 +0000 To: libc-alpha@sourceware.org, Richard.Earnshaw@arm.com, DJ Delorie <dj@redhat.com> Subject: [PATCH 12/16] malloc: Use mtag_enabled instead of USE_MTAG Date: Thu, 4 Mar 2021 16:33:42 +0000 Message-Id: <a08289e4a58ff4ad00f0d61ebcdb1cdaca5dc3d5.1614874816.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <cover.1614874816.git.szabolcs.nagy@arm.com> References: <cover.1614874816.git.szabolcs.nagy@arm.com> Content-Type: text/plain X-Originating-IP: [217.140.106.55] X-ClientProxiedBy: SN4PR0501CA0082.namprd05.prod.outlook.com (2603:10b6:803:22::20) To PA4PR08MB6320.eurprd08.prod.outlook.com (2603:10a6:102:e5::9) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (217.140.106.55) by SN4PR0501CA0082.namprd05.prod.outlook.com (2603:10b6:803:22::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.16 via Frontend Transport; Thu, 4 Mar 2021 16:33:52 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 6fb5957d-014a-4b85-2b7b-08d8df2b5542 X-MS-TrafficTypeDiagnostic: PA4PR08MB6064:|VI1PR0802MB2573: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: <VI1PR0802MB2573223F831DF49B0AA13C4BED979@VI1PR0802MB2573.eurprd08.prod.outlook.com> x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:9508;OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: x3wkPQ4KDYfOtAsWjZVjsfl1RfV3dlvZCBKSyLDC7sVM7RKMbcNpsZJ9qzvzSVJx2An4MTHtx9yb62ZPVk+2l79rSY7XzyOfNKquiwWrEgwqH1U4z6D17xCgPgCb9UOqMeWh9y9Ep0PVhL+ukVqXyKFzGlr5SII5bE/vL3DLyWrCwPuxJ5N9MmvrMx9nv+kDhztPB6m8Xpxh/3XRrZNfaKPAuMzQH/m9IwOcOi4RC0LgVSviTTOXfDV2ZEFeIPyZUNTpB+yh2coTfyw4NcB2+3Spk2ynYx/1KiDt0cTGYOqwdko/b+wpmfyTpWvzByhzmseB0bcZ113AbM4XdAg00P/kCvtQGiJOsq0u5AIMojt2wE1lz6nWTe2W86+aGKSihyD2NP/+367cKeiaZydmYXOS76/CPCOv4O91wjCJY+YJzg4iCyqAiMBBPM3IsMSO5C6LcbFdS7Yh4pjKRrmxePQW8gWGyldaEuk9R3DfyVqfSYMut11kd/ls/rEPezFpH3mHvUk3ZVgsQoFHkgYd1QyhPaYrAAo9/T+DxmysyRQJ2VAwZTyN6+v0VZYNpOTD5B2Xgii5PU4E4J6LY8GXyw== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PA4PR08MB6320.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(136003)(346002)(366004)(376002)(39850400004)(66556008)(66946007)(66476007)(5660300002)(6506007)(26005)(6486002)(316002)(83380400001)(16526019)(2906002)(186003)(44832011)(6666004)(36756003)(8676002)(6512007)(69590400012)(8936002)(478600001)(956004)(86362001)(6916009)(2616005)(52116002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: V/kQSfFF1qQ8ge8PO07EqlvhFfDPlKJohoY7TLvpzmTy4xoQPJ7UYojylVPT2xTn4NW867pB9Rm6AVrZ0q5+xmkfAW0VYLtCjZwOQWD4/19H5Y9sDeljzFsSvfStyH/iBpOl6pRV6PfZCYk+5K2Rfw5bXqXnCUAnIKXpDDJk7i/dBH1MuKgoNCN2KPL9sj3FsQZPsrme7yUDlsK5ilo68wNvtHa/5NJxBGzDZHNrYBduNIKTvSAqatvSnyArCGHJbvg+SfX1Kez+/J1bvLZfFgxVXHN4v1isjeychtsp1XIjKmN7tDqMrNfFP9L8dtTMiDcIKVRC+pf1gj+z52ZM9X1veCNNBJB9ATCbm/5Jo3Ix84F02IRFmtP35677kuNK5rWRf6v48fY9y1bDVEUxx6y894d6vkBbxFk9fmsooDbSJXoVvEhqbJkva+RkExFtuFiZ6CeO0A/KYwEngGxH+gr6dJm4KRSEQXvy5MeZFFKr0WdX9O48JlIU9l+HLrb2q4K/hio0Qd+lipRuqHlil0UEh+t0uRGFXZAMcb0gpB4TrAZ8JfE7q2LIf8e943KFADcEfIp8/1YMLWssYxQcR5L+EGpIN5cSTEvEYdCjjJQDR7ubEHwkj91bdYexjRCrAPNCAWMLbRyB/ra3RydqUb3wUAkwtHk2iXKHephq7ZZzNS9rzodmkVOCR15eGz396/3EwargAf0rr4UfkAEpHbAc3d+0kthXBGWZFE2euPk81gD/oL04c7R4qQBQJCoeujEHDwg/WEfnzK2Y7N3lvGvrWqAkJgddeDhGbMFJjnqYHjG+WxB2HAuR9eIa86swYTomSPXMPY1Iv0NeyKD144B0JFOS3Q1ZscigWOLTLFvG0h5gu9v70WTW/XYPogT0Y7T9sKO8ThrR6wP2AAdcdPSjsIbg/yPeOK+++Nr06kSKnHR3fDseDvpbGkZiafXyrffm9KMhdU+E4Ia1fctVzIP4WEuTeleNfHMK+2G6v71UuekFM/mUjatE606liziK3Ik/ilUlGPA2Ks1tD4SBWsYpo0/sLmfLip4uF06R8ni0fBg10O48edPENiM7O8yArbdynQglOxfQ68myQusWYHOWcWCeSdWX9uHNk3nM5hHyS05QOpqBQ8pYHNHSh8yLcnY7tGJPU5qm8ae8m2r1z3XNlqA9TPT3cA22g8HxL7bzE9EOCzi7KAS/pzpAAU2+sUYR5EWSowiS/Qrk+1G35n5INZKykmr2483Em9f8aBCQugqmtch/tb8Ntj0lJCf5tBEpcMNNUjHmG3m+GuuMz3ikcxyIzGSBAakMBdC3DAj8hJTv6e1E3M9kpRH+ka0t X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6064 Original-Authentication-Results: sourceware.org; dkim=none (message not signed) header.d=none; sourceware.org; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT007.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 307c66c0-2820-414c-4670-08d8df2b4cd6 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zahZONi9zseGfu9+QH4GO8OY6fsq5mhW0OpFO1PKRiV1thxUujF4IoyrysLt5WprUO0ghWt0MTegdgDJgCISQyRV3EXR6CMkdaUcUjjx82evEKepKV7K5QpQfuLT9n5akiuTkGzsuNQXPI6Se3gOMv2imC5sW0l2p04HA80jVWPdXSeY5KLTbH5aZadyAtJkU17kaY6Dl4yJHUhg4vtnBbvVICziEmUG5GCkkNKARVdNgrn9eomqWJDyKoDs82H3FGOOfdgzbnlu6kNJGjQB3Ra600RzQGm1btRmY6FpPdt2EwLzBvsZo3//apfJ81b9MZukpcJ+gK+LvEnW6EKlsjZevzqL04MKhhyAyF9hhLzM1zN1Haw0wdldPpO1vEBBvieI4MtCb9VHtAF2/jdwgH6rcHecDX2QTra1XsLpAj7LQyDR3y4ExroHbLdYIljk2mOdzZO5DIUMtu5RgYQhCYFLvqW4txCGWOcoDJflEABgHakkFSvulKLWriefgAWB/tfQRgzmkiUeyqGBqqjhkDxHEnk6MM3fyocWRa55gyhmPDODna+8LqkXBziggqg6c0eVPtmEEufYY2hPWllEbPGfWlR/a8YTNDA4r5QFzCIe1bipqQusLeVtozy+C6TsiayPZIhJmTnqrKC+hXKrltVZdTQRID2qZxsfNTIlsckbbQDHjwDaowsL/Dhvw0wx X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(4636009)(39850400004)(136003)(396003)(376002)(346002)(46966006)(36840700001)(70206006)(70586007)(81166007)(6862004)(82740400003)(478600001)(356005)(36860700001)(6506007)(83380400001)(69590400012)(2906002)(82310400003)(47076005)(26005)(36756003)(86362001)(8936002)(6512007)(316002)(6486002)(6666004)(2616005)(336012)(44832011)(956004)(8676002)(186003)(16526019)(5660300002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2021 16:34:07.8873 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6fb5957d-014a-4b85-2b7b-08d8df2b5542 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT007.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2573 X-Spam-Status: No, score=-14.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list <libc-alpha.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> From: Szabolcs Nagy via Libc-alpha <libc-alpha@sourceware.org> Reply-To: Szabolcs Nagy <szabolcs.nagy@arm.com> Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" <libc-alpha-bounces@sourceware.org> |
Series |
memory tagging improvements
|
expand
|
diff --git a/malloc/hooks.c b/malloc/hooks.c index d8e304c31c..9474e199c3 100644 --- a/malloc/hooks.c +++ b/malloc/hooks.c @@ -262,11 +262,10 @@ free_check (void *mem, const void *caller) int err = errno; -#ifdef USE_MTAG /* Quickly check that the freed pointer matches the tag for the memory. This gives a useful double-free detection. */ - *(volatile char *)mem; -#endif + if (__glibc_unlikely (mtag_enabled)) + *(volatile char *)mem; __libc_lock_lock (main_arena.mutex); p = mem2chunk_check (mem, NULL); @@ -310,11 +309,10 @@ realloc_check (void *oldmem, size_t bytes, const void *caller) return NULL; } -#ifdef USE_MTAG /* Quickly check that the freed pointer matches the tag for the memory. This gives a useful double-free detection. */ - *(volatile char *)oldmem; -#endif + if (__glibc_unlikely (mtag_enabled)) + *(volatile char *)oldmem; __libc_lock_lock (main_arena.mutex); const mchunkptr oldp = mem2chunk_check (oldmem, &magic_p); diff --git a/malloc/malloc.c b/malloc/malloc.c index 8854afec88..2d96bb085c 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -3286,11 +3286,10 @@ __libc_free (void *mem) if (mem == 0) /* free(0) has no effect */ return; -#ifdef USE_MTAG /* Quickly check that the freed pointer matches the tag for the memory. This gives a useful double-free detection. */ - *(volatile char *)mem; -#endif + if (__glibc_unlikely (mtag_enabled)) + *(volatile char *)mem; int err = errno; @@ -3352,11 +3351,10 @@ __libc_realloc (void *oldmem, size_t bytes) if (oldmem == 0) return __libc_malloc (bytes); -#ifdef USE_MTAG /* Perform a quick check to ensure that the pointer's tag matches the memory's tag. */ - *(volatile char*) oldmem; -#endif + if (__glibc_unlikely (mtag_enabled)) + *(volatile char*) oldmem; /* chunk corresponding to oldmem */ const mchunkptr oldp = mem2chunk (oldmem);