Message ID | 20200624104124.27695-1-szabolcs.nagy@arm.com |
---|---|
State | Committed |
Commit | 087942251f26d5fd5802b8d14e47d460263a0c4d |
Headers |
Return-Path: <libc-alpha-bounces@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 35C49398741A; Wed, 24 Jun 2020 10:41:44 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2087.outbound.protection.outlook.com [40.107.21.87]) by sourceware.org (Postfix) with ESMTPS id 7EA1E389853A for <libc-alpha@sourceware.org>; Wed, 24 Jun 2020 10:41:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7EA1E389853A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Szabolcs.Nagy@arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=N0/o0pU6qL+T2AqNMsZL0mU/syzc0AdqzRGQqKkMw9Y=; b=9ZNufrjG7SxC+MEWqqg5CNEH86oqZNWXT/aYd2VZo7tAtga6TnJ8bGA6dW+z334fR43FaVYXPfUxCli4hhpWYL9lcRlAhE6ZVowEPnPVpZgYgTQX83GphaBV9cKa0MAuaQXGoM0PmmZNPhtaysb9eKRQ8W4R3L/UV6TF1ZnftkA= Received: from DB6PR0301CA0008.eurprd03.prod.outlook.com (2603:10a6:4:3e::18) by DBBPR08MB4236.eurprd08.prod.outlook.com (2603:10a6:10:c8::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.21; Wed, 24 Jun 2020 10:41:39 +0000 Received: from DB5EUR03FT033.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:3e:cafe::42) by DB6PR0301CA0008.outlook.office365.com (2603:10a6:4:3e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.20 via Frontend Transport; Wed, 24 Jun 2020 10:41:39 +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=bestguesspass 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 DB5EUR03FT033.mail.protection.outlook.com (10.152.20.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Wed, 24 Jun 2020 10:41:39 +0000 Received: ("Tessian outbound da41658aa5d4:v59"); Wed, 24 Jun 2020 10:41:39 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: ccac6e2ddd14f77f X-CR-MTA-TID: 64aa7808 Received: from 6ab2697ec47e.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 3B44333A-6AA9-4D53-8544-81E7F05CB0F8.1; Wed, 24 Jun 2020 10:41:32 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 6ab2697ec47e.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 24 Jun 2020 10:41:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iK83Nq/p371sEcalsADxCkDu1Hp5lZ8wCZbIqYnuqBHwYb7vO6SltfVTxZDjEynxmMc1UvnwMTDXCg6WO+AYxJ4z16Agc4CVCW4Qmqn0hNYkB4mNn0I8rKvP/DIFmL5xDl0galQG+Og/0d8rR5gXzf19Nr5J/K72WLVaXlsU9QfFV8eFKSqABk8ZvIwCZV/F1u4FsHkNyDj9QEJNIIHta5O+7jD0z7r+/ymHqAmFuFLhNXYyrRAIZ33vtmcHjcnVZDGnA9RiF3i4brAqBlnH02cQHBlVln0R9IVHagHRJVy54or3FRPWv6BxcinpD6N2C37LacSQevK90k9i7V3suA== 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=N0/o0pU6qL+T2AqNMsZL0mU/syzc0AdqzRGQqKkMw9Y=; b=PtzWP7Pliyn2yKh9ICcc+WFE8CNx9MrtsEK6JEG74w2Hc+ZMlMEkRGjumxvFDFLIz0pMP45QoCoBm6/s+aGXMTTHJdxm+gFvpJKwNlmNG1YoDFxpgttnB548ZW2HPNjuPrHCesw+SUSQpeL1Q/8sgyc44jHK4ArZl7WYmIR6qfKNFKvbrJMwfTmVRakQSYHjJ+6reX3Q8FEvbymmyPyCxcip7OsFkOz8IKh879khJH8AU63JhrKgJei3n24YIuKkQ20fuTmUxghJ6eoWZlZcg4k2yTAtJ6cedBG5F5+3LHeFYNeU0OskiTGDMASbZgC9KRUxU6hu3gvvZLeVaeExaQ== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=N0/o0pU6qL+T2AqNMsZL0mU/syzc0AdqzRGQqKkMw9Y=; b=9ZNufrjG7SxC+MEWqqg5CNEH86oqZNWXT/aYd2VZo7tAtga6TnJ8bGA6dW+z334fR43FaVYXPfUxCli4hhpWYL9lcRlAhE6ZVowEPnPVpZgYgTQX83GphaBV9cKa0MAuaQXGoM0PmmZNPhtaysb9eKRQ8W4R3L/UV6TF1ZnftkA= 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 AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) by AM6PR08MB3592.eurprd08.prod.outlook.com (2603:10a6:20b:4b::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22; Wed, 24 Jun 2020 10:41:31 +0000 Received: from AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c]) by AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c%6]) with mapi id 15.20.3109.027; Wed, 24 Jun 2020 10:41:31 +0000 From: Szabolcs Nagy <szabolcs.nagy@arm.com> To: libc-alpha@sourceware.org Subject: [PATCH] nptl: Don't madvise user provided stack Date: Wed, 24 Jun 2020 11:41:24 +0100 Message-Id: <20200624104124.27695-1-szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 Content-Type: text/plain X-ClientProxiedBy: LO2P265CA0135.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9f::27) To AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (217.140.106.53) by LO2P265CA0135.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9f::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.21 via Frontend Transport; Wed, 24 Jun 2020 10:41:30 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [217.140.106.53] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 809fbc45-23e7-4e97-839b-08d8182b2d19 X-MS-TrafficTypeDiagnostic: AM6PR08MB3592:|DBBPR08MB4236: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: <DBBPR08MB42369CF4BC4064CE3AACD251ED950@DBBPR08MB4236.eurprd08.prod.outlook.com> x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8882;OLM:8882; X-Forefront-PRVS: 0444EB1997 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 3x08H19PmKyKbLYvjOd+8XGTAS39BpvQYvbbCcXGWeDCd0PMkENKa/HvQpsvTthHrSb7UyW4DwmTjILvwpqrPl4ccuhOgAuzmxt84WZ1gJvdLxgLnfZO8FoiMEPzxYXmVRZkZ6uGetxbChTlUgxjkCTaMkczfAHNAGm1X/W104XBhs/Vy60e8NtbhmqGTk6DjwhJYqbgJPCCS2APmFtXxuuheO2tfLkhd1WmcHeMfjQsLxCszE1qTw3tx6U1nfDYWpZDFo0/fMRUVqvoYdcgbELH/4vGqa9e/C2vb2bbLZj+x7RFq60dp4yzfvEdG78q1FUN2fkmvlbL83YjdVUewBNoIBxGshurhhvOP8sYL8JjT1CiYp6T5oAyLXo39bGz X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR08MB3047.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(396003)(39860400002)(366004)(136003)(376002)(346002)(86362001)(44832011)(316002)(2616005)(956004)(66556008)(66946007)(66476007)(69590400007)(6916009)(6486002)(5660300002)(4326008)(6512007)(478600001)(6666004)(8676002)(54906003)(36756003)(8936002)(2906002)(16526019)(83380400001)(6506007)(1076003)(186003)(26005)(52116002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: sKZiSouQc6juYNByOzvVrzrAHfXTjr+ND5Y48A/vT2bKJ+ByeS8U5ZEMd+TpZKKlR+RnYrJFt9+KadR+ebWj5LuY05mjDjXPpkXlerNxZOVn0iIgAB/CBQ5osceKtY1duCZTAqvP5Ag+ZtXWOWP/arec9eXh6liaFbxhp1S9OAjp8sDYpBBLBih8wT2fsIofLZwMmJgbZZkg7+ZEXhM65604XOoYjmPh1hcRR4C5Q5/RMuxNKtv1PYWT7y2nxudnBMBadZCdoYjMfbG3emK5PLoPPhBfaBqCe3Y5xmnmlkgdhbHGgOWemFnORTFQ/Q1D2eL3Ie/jTCz5wbTB3Yt8eWq3nfqzVxb8wDLje8ofSsyF6PmvUD+TCH+zFmpkdduUhF6RNmpNqjR4dh6aJloqoxsCfqYDNz5U6nf089SfZRi8l3ZRwQNLpWORwlwPoNbs0aZjgt75FvJwwwyE3gDW3Oc8mWMkcT+H7ptT0BCv/gkL4tliFZVxXG+FuwbD8dA5 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3592 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: DB5EUR03FT033.eop-EUR03.prod.protection.outlook.com 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; SFTY:; SFS:(4636009)(396003)(39860400002)(376002)(136003)(346002)(46966005)(336012)(16526019)(186003)(26005)(1076003)(82310400002)(47076004)(83380400001)(356005)(82740400003)(70206006)(81166007)(5660300002)(70586007)(6486002)(8676002)(69590400007)(8936002)(6916009)(54906003)(6512007)(478600001)(316002)(6666004)(86362001)(2616005)(956004)(4326008)(44832011)(6506007)(36756003)(2906002); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 00ead51f-1fc2-4aa6-ef6f-08d8182b280a X-Forefront-PRVS: 0444EB1997 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: I/JaIguOlAe9CF7iXVKgJmQsCm8sEQRMTSsMPb1zznsdulJrrRygVvw+VJVz3IW0dZ6qIKVXOWuuNc94404y5En3OZs/2rZzSzpsMohh2eWDJnDh8BlSTlexb4o0MNLZpksTCXJqz3111M6T2osdr1PDIaU7soZluURQE8O2DbOkZ8HTrKyFEu9tdzhmUQc0YsBpITQk+SC57vmZSQOJpfY3lgv/YD4wXRHI/Y7fjjyu9XG/ZxRh7u7t/ThdKiL35GQ403vCcDXWjlt0tkoJoIx6VTIZcST+3XQ+zHQhwYebNlqhBQELFlppn85ZMo3sOFuRGZh3RItbSi9A3S/bun1O0vAkM8cX2tzjLNGQ8Cn4yBKdJlPuftAwbyhkmt/c5RiyhTkW/K5ughlSzx3ZC+ubxNK8bCG+AVrh4E5xI/d1KDF16OQ610GZHNaLuCD4 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2020 10:41:39.2162 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 809fbc45-23e7-4e97-839b-08d8182b2d19 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: DB5EUR03FT033.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4236 X-Spam-Status: No, score=-16.5 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: <http://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: <http://sourceware.org/mailman/listinfo/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> Cc: Richard Earnshaw <Richard.Earnshaw@arm.com>, Catalin Marinas <catalin.marinas@arm.com> Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" <libc-alpha-bounces@sourceware.org> |
Series |
nptl: Don't madvise user provided stack
|
|
Commit Message
Szabolcs Nagy
June 24, 2020, 10:41 a.m. UTC
User provided stack should not be released nor madvised at thread exit because it's owned by the user. If the memory is shared or file based then MADV_DONTNEED can have unwanted effects. With memory tagging on aarch64 linux the tags are dropped and thus it may invalidate pointers. Tested on aarch64-linux-gnu with MTE, it fixes FAIL: nptl/tst-stack3 FAIL: nptl/tst-stack3-mem --- Note: the arm64 MTE linux ABI is still under discussion, but for MADV_DONTNEED the current behaviour seemed most useful. this behaviour is mainly problematic when madivse is used on memory that's allocated and owned by somebody else which is not expected to be common. (MADV_FREE and MADV_WIPEONFORK has similar issues.) --- nptl/pthread_create.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Comments
* Szabolcs Nagy: > + if (!pd->user_stack) > + advise_stack_range (pd->stackblock, pd->stackblock_size, (uintptr_t) pd, > + pd->guardsize); Could we still use MADV_FREE? But the patch as-is looks fine to me. Thanks, Florian
The 06/24/2020 13:05, Florian Weimer wrote: > * Szabolcs Nagy: > > > + if (!pd->user_stack) > > + advise_stack_range (pd->stackblock, pd->stackblock_size, (uintptr_t) pd, > > + pd->guardsize); > > Could we still use MADV_FREE? > > But the patch as-is looks fine to me. MADV_FREE has the same issue (it does not zero the tags immediately, but may do so later) i hope users don't commonly use madvise (or other mmap/munmap/.. operations) on malloced memory, that is unlikely to be supportable with memory tagging.
The 06/24/2020 12:32, Szabolcs Nagy wrote: > The 06/24/2020 13:05, Florian Weimer wrote: > > * Szabolcs Nagy: > > > > > + if (!pd->user_stack) > > > + advise_stack_range (pd->stackblock, pd->stackblock_size, (uintptr_t) pd, > > > + pd->guardsize); > > > > Could we still use MADV_FREE? > > > > But the patch as-is looks fine to me. now committed. > > MADV_FREE has the same issue (it does > not zero the tags immediately, but may > do so later) > > i hope users don't commonly use madvise > (or other mmap/munmap/.. operations) on > malloced memory, that is unlikely to be > supportable with memory tagging.
diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c index 35a9927cf2..6d6ab88960 100644 --- a/nptl/pthread_create.c +++ b/nptl/pthread_create.c @@ -549,8 +549,9 @@ START_THREAD_DEFN } #endif - advise_stack_range (pd->stackblock, pd->stackblock_size, (uintptr_t) pd, - pd->guardsize); + if (!pd->user_stack) + advise_stack_range (pd->stackblock, pd->stackblock_size, (uintptr_t) pd, + pd->guardsize); if (__glibc_unlikely (pd->cancelhandling & SETXID_BITMASK)) {